Is ORDER BY RAND() LIMIT 1 optimized?
Posted by:
Markus M.
Date: May 27, 2015 05:40PM
Hi,
I'd like to ask if this query is a special case and would have the performance of "just picking one random row" or if it "needs to sort all rows, like with other LIMIT values" and would later perform worse than a other solution.
That other solution would maybe be first picking a random id in PHP and then doing the query with WHERE id=$the_random_id.
When my table grows to 5000 rows, will it make a difference?
Kind regards,
Markus
Subject
Views
Written By
Posted
Is ORDER BY RAND() LIMIT 1 optimized?
6680
May 27, 2015 05:40PM
1897
May 28, 2015 02:18AM
1445
May 28, 2015 07:22AM
1183
May 28, 2015 07:49AM
1273
June 06, 2015 12:16PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.