Tim Starling schrieb:
Taking the SQL query used in Special:Randompage from
CVS and modifying
it very slightly...
SELECT cur_id,cur_title,cur_random
FROM cur USE INDEX (cur_random)
WHERE cur_namespace=0 AND cur_is_redirect=0
AND cur_random>RAND()
ORDER BY cur_random
LIMIT 20
I guess that's why this doesn't work:
MySQL processes the query in the following order:
1. Fetching
2. Ordering
3. Limiting
1. MySQL fetches rows from the table until there ist no more row with
cur_random greater than the recently generated RAND() (it generates a
new RAND() on every fetch). This should return on avarage half of the
rows from the table.
2. MySQL orders the fetched rows by cur_random in ascending order.
3. MySQL returns the 20 rows with the lowest cur_random from the subset.
-- WeißNix