This is probably old knowledge, but for some reason I never ran into it until this week. You should almost never use the RAND() function of MySQL in an ORDER BY.
The ORDER BY RAND() operation actually re-queries each row of your table, assigns a random number ID and then delivers the results. This takes a large amount of processing time for table of more than 500 rows.
We had a script with a query like this:
SELECT id,title,publishDate FROM mytable ORDER BY RAND() LIMIT 5
This took 1400ms to run because the table had 5000+ records.
We changed it to query for a full list of IDs, then randomly choose 5 IDs using ColdFusion and randrange(), then requeried for just those 5 records. Even with two queries instead of one, it is MUCH faster – at 15ms total for the database transactions.
So, as a general rule, AVOID USING ORDER BY RAND(). If you have a really small table it is fine, but it does not scale well at all.