

MySQL select 10 random rows from 600K rows fast - morphics
http://stackoverflow.com/questions/4329396/mysql-select-10-random-rows-from-600k-rows-fast

======
broshnat
SELECT * FROM table ORDER BY RAND() LIMIT 10 ?

~~~
eurleif
Try running EXPLAIN on that query. It has to create a temporary table, add a
random column for every row, and then sort on that column. Not very fast.

~~~
broshnat
Ok, how about get the max ID and run a loop of 10 queries matching a random ID
between 1 and maxID?

~~~
eurleif
That's essentially what the top-voted answer does, except it accounts for gaps
in the IDs.

