3 ms·MySQL select 10 random rows from 600K rows fast1 points by morphics 14y agobroshnat 14y agoSELECT * FROM table ORDER BY RAND() LIMIT 10 ?eurleif 14y agoTry 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 14y agoOk, how about get the max ID and run a loop of 10 queries matching a random ID between 1 and maxID?eurleif 14y agoThat's essentially what the top-voted answer does, except it accounts for gaps in the IDs.