I saw many websites that do not use ORDER BY RAND (), for example http://forge.mysql.com/wiki/Top10SQLPerformanceTips So, I run the test, I tested the speed and performance in a table of 20 thousand records, 10 thousand records, among them there is a username = "username":
SELECT username FROM testingspeed WHERE username='username' ORDER BY RAND();
Result:
Showing rows 0 - 29 (10,000 total, Query took 0.0119 sec). id = 1 select_type = SIMPLE table = testingspeed type = ref posible_keys = username key = username key_len = 32 ref = const rows = 3225 Extra = Using where; Using index; Using temporary; Using filesort
since it took 0.0119 seconds just to complete the request, it should be very good speed, why do people still say DO NOT use ORDER BY RAND ()? Why only 3225 lines? Why won't 10,000 rows suffer?
source share