I am running MySQL version 5.0
mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (x86_64) using readline 5.2
On my large database (more than one million records) i wanted to pick a random article and this was amazingly slow, of course I was using the standard syntax
select page_namespace,page_id,page_title
from page
where 1 order by RAND() limit 1;
With a little search, I found this syntax that significatively reduces my query time.
SELECT page_namespace,page_id,page_title
FROM page T
JOIN (SELECT CEIL(MAX(page_id)*RAND()) AS ID FROM page) AS x
ON T.page_id >= x.ID LIMIT 1;