Forum Moderators: coopster
SELECT * FROM table ORDER BY RAND() LIMIT 10;
Array
(
[0] => rev
[table] => rev
[1] => ALL
[type] => ALL
[2] =>
[possible_keys] =>
[3] =>
[key] =>
[4] =>
[key_len] =>
[5] =>
[ref] =>
[6] => 62998
[rows] => 62998
[7] => Using temporary; Using filesort
[Extra] => Using temporary; Using filesort
)
I haven't used mysql much so this doesn't really mean anything to me... As I said before using that select statement takes a long time. If I use "SELECT rev_id FROM rev ORDER BY RAND() LIMIT 10" it takes 1/100th of the time, I presume because there's an index on rev_id.
I guess the easiest (and quickest) way to do this is with a subquery, something like:
SELECT * FROM rev WHERE rev_id IN (
SELECT rev_id FROM rev ORDER BY RAND() LIMIT 10
)
Thanks for your help coopster!