Bug #59253 | implementation of order by rand() | ||
---|---|---|---|
Submitted: | 2 Jan 2011 21:16 | Modified: | 2 May 2012 18:40 |
Reporter: | Harald Reindl | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: General | Severity: | S4 (Feature request) |
Version: | 5.5.8 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[2 Jan 2011 21:16]
Harald Reindl
[2 Jan 2011 21:30]
Harald Reindl
Better sample to show how weak rand() is implemented * Updated all records to 'A', so we are on 200 MB table size * fetching 5 random records also make a temp-file with all data select * from mytest order by rand() limit 5; 5 rows in set (40.42 sec) 5 rows in set (14.68 sec) 5 rows in set (14.25 sec) select * from mytest order by rand() limit 2; 2 rows in set (16.56 sec) 2 rows in set (15.71 sec) 2 rows in set (15.79 sec) | 1 | SIMPLE | mytest | ALL | NULL | NULL | NULL | NULL | 7044704 | Using temporary; Using filesort |
[12 Jan 2011 3:42]
Alexey Kishkin
as far as I understand it's not a bug but rather feature request
[12 Jan 2011 4:31]
Harald Reindl
i agree :-) in my applications i fetch since years the pri-keys in a array and do the random in php since i noticed that display a random shop-item is running two seconds instead 0.012 seconds whole generate-times but how many others do not realize that as long tables have only few records and the load is low so nobody notices the temp-tables by luck :-)
[2 May 2012 18:40]
Sveta Smirnova
There is verified bug #65177 about very same problem. So closing this one as duplicate of that.