random rows question
Posted: Wed Jan 20, 2010 10:00 pm
How to select eg. 20 random rows from a big table (10.000 - 100.000 rows)?
RAND() is way to slow.
additional table info:
Something that works for you well?
RAND() is way to slow.
additional table info:
I thought of this - but have doubts:1. empty rows, e.g.: 401, 402, ?, 404
2. there are two types of rows - one should be used for random rows selection, another type should be excluded.
Has anyone come across some good way to handle that?If it was not for #2, I would go for php random numbers generation and used them in IN(random numbers).
What I'm afraid of is that e.g. I select 20 random numbers and some will be from these rows, which are excluded, I'm in trouble, as I cannot select enough rows.
Same may happen if I select 50 random numbers and 40 of them will be from excluded rows, or even all of them.
Something that works for you well?