[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 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? [/snip] 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. 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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]