3 ms·
It doesn't seem to me as a common requirement. "ORDER BY RAND()" means exactly as it says ... fetch the result-set in a random order, and it applies to the who
by bad_user 17y ago
It doesn't seem to me as a common requirement.
"ORDER BY RAND()" means exactly as it says ... fetch the result-set in a random order, and it applies to the whole result-set, (probably) having the same performance characteristics as any other unoptimized "ORDER BY", which is executed before "LIMIT" (I like it because it's consistent).
Many people are using "ORDER BY RAND()" to fetch multiple rows, not just one ... which is also pretty bad. But in such a case other optimizations are in order ... if you're selecting 30 random items, you wouldn't want to issue 30 queries to the database.