Quite typical query for reporting applications is to find top X values. If you analyze Web Site logs you would look at most popular web pages or search engine keywords which bring you most of the traffic. If you're looking at ecommerce reporting you may be interested in best selling product or top sales people. This information may often need simple select query, however what if you would like to show percents not just absolute value ?
For illustration purposes I've created a syntetic table filled with some 30mil rows evenly spread in 10.000 groups.
PLAIN TEXT SQL:
- CREATE TABLE `dt` (
- `grp` int(10) UNSIGNED NOT NULL,
- `slack` varchar(50) DEFAULT NULL
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1
And I'm using some silly like query to illustrate some search is required, so count(*) can't be optimized away for MyISAM Tables.
To show …
[Read more]