> The way to
> enhance this is by selecting an indexed value, such as the following
> where `foo` is indexed
> SELECT `foo` FROM fortunes ORDER BY RAND() LIMIT 1
Why does this help? From the MySQL book I have, the reason ORDER BY
RAND() is slow is because "for each record in the table a random number
must be generated. Then all random numbers are sorted so that the first
n records can be returned.
Is this correct? If so, how does selecting an indexed column help this,
won't it still need to perform all those operations (generate rand-nums,
then sort) regardless of the index?
Using indexes for selection criteria does have an impact, even with
RAND. On a table such as yours it shouldn't matter due to the small