Michael Stassen wrote:
Don't bother. This is a very expensive solution. You get nearly a Cartesian product on each JOIN. I've got a 40 row test table with 20 values in each of 2 groups. The top 3 version of this examines 2302 rows to produce the 3 values for each of the 2 groups. The top 10 version has been running for several minutes...
It just finished:
+------+-------+--------+-------+--------+-------+-------+---------+--------+-------+-------+
| g | first | second | third | fourth | fifth | sixth | seventh | eighth | ninth | tenth |
+------+-------+--------+-------+--------+-------+-------+---------+--------+-------+-------+
| a | 392 | 339 | 332 | 330 | 304 | 279 | 271 | 250 | 183 | 179 |
| b | 390 | 338 | 302 | 273 | 272 | 268 | 245 | 215 | 211 | 189 |
+------+-------+--------+-------+--------+-------+-------+---------+--------+-------+-------+
2 rows in set (7 min 41.06 sec)
Nearly 8 minutes to get the top 10 for two 20-row groups. This definitely doesn't scale.
Michael
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]