RE: Selecting a random row

2004-12-06 Thread Dathan Pattishall
return 1st row; } -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Joshua Beall Sent: Monday, December 06, 2004 12:40 PM To: [EMAIL PROTECTED] Subject: Selecting a random row Hi All, I understand that I can get a random row out of a table by doing something like SELEC

RE: Selecting a random row

2004-12-06 Thread Jay Blanchard
[snip] > The way to > enhance this is by selecting an indexed value, such as the following > where `foo` is indexed > > SELECT `foo` FROM fortunes ORDER BY RAND() LIMIT 1 Why does this help? From the MySQL book I have, the reason ORDER BY RAND() is slow is because "for each record in the table a

RE: Selecting a random row

2004-12-06 Thread Joshua Beall
> How many rows do you anticipate that the table will have? Have you > tested this on your server? I would have to bet that if you > have only a few K rows that speed/performance will not be an issue. I doubt I will have more than 100. Perhaps I shouldn't worry about it, then. > The way to > en

RE: Selecting a random row

2004-12-06 Thread Jay Blanchard
[snip] I understand that I can get a random row out of a table by doing something like SELECT * FROM fortunes ORDER BY RAND() LIMIT 1 But I have also been told that this is a very slow operation. I am building a script that will display a random saying, user testimonial, whatever, on a web pag

Selecting a random row

2004-12-06 Thread Joshua Beall
Hi All, I understand that I can get a random row out of a table by doing something like SELECT * FROM fortunes ORDER BY RAND() LIMIT 1 But I have also been told that this is a very slow operation. I am building a script that will display a random saying, user testimonial, whatever, on a web p