List:General Discussion« Previous MessageNext Message »
From:Joshua Beall Date:December 6 2004 8:39pm
Subject:Selecting a random row
View as plain text  
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 page.  Since this is a public page (i.e., not an admin 
backend), I have to be concerned about speed.  What is the best way to get a 
random row out of a database for this sort of application?  It's the sort of 
thing you see all the time, so I'm sure others have thought about this 
before.  Any pointers?

Sincerely,
  -Josh 



Thread
Selecting a random rowJoshua Beall6 Dec
RE: Selecting a random rowJay Blanchard6 Dec
  • RE: Selecting a random rowJoshua Beall6 Dec
RE: Selecting a random rowJay Blanchard6 Dec
RE: Selecting a random rowDathan Pattishall6 Dec