I have this query SELECT DISTINCT `test` FROM `testdb` order by rand() limit 10 Code (markup): The problem is that it is using A LOT of resources.
SELECT COUNT(*) AS cnt FROM `testdb` OR SELECT MAX(id) AS cnt FROM `testdb` generate random number between 0 and cnt-1 in code/SQL then SELECT `test` FROM `testdb` LIMIT $generated_number, 1
Depending on your requirements you could pregenerate a column with random numbers then you could query like this : SELECT DISTINCT ' test' FROM ' testdb' ORDER BY columnrandom LIMIT 10. If needed you can use windows scheduled tasks or Unix cronjobs to create a new random order at certain intervals. If this is usable for you depends on your requirements.