MySQL Forums
Forum List  »  Performance

Re: MySQL rand() is slow on large datasets
Posted by: Jeff Fillmore
Date: May 15, 2008 03:15PM

I found that Jay solution gave a result set that were to close together. For example I would get rows from 7100 - 7150. That was not random enough for me. So here is what I did to get more random of rows with out killing the speed of Jay's query.

SELECT * FROM Table T JOIN (SELECT MAX(ID) AS ID FROM Table) AS x ON T.ID >= FLOOR(x.ID*RAND()) LIMIT 10;



Edited 1 time(s). Last edit at 05/21/2008 02:39PM by Jeff Fillmore.

Options: ReplyQuote


Subject
Views
Written By
Posted
19170
July 24, 2007 08:19AM
7987
September 02, 2007 10:30AM
Re: MySQL rand() is slow on large datasets
7846
May 15, 2008 03:15PM


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.