Seeding the rand() Generator

Nils Ruettershoff nils at
Thu Aug 6 23:28:29 CEST 2009

Hi Fred,

I just saw your SQL Statement
> 	An example would be: SELECT first, second, third, fourth,
> fifth, sixth from sometable order by rand() limit 1
and I feel  me  constrained to give you an advice. Don't use this SQL 
statement to pick up a random row, your user and maybe DBA would much 
appreciate it.
You are certainly asking why. Lets have a brief look what you are asking 
your mysql DB:

Fetch all rows from 'sometable', but only with attribute 'first, 
second,...' sort them all starting at 'random row' and afterward through 
anything away you did before, but the first line

If you have a table with 100000 rows you would fetch and sort up to 
100000 rows, pick up one row and discard up to 99999 rows. That sounds 
not very clever, right?

So please take a look at this site to get a better alternate way for 
that approach:

if you want to know more please check this article too:



More information about the Python-list mailing list