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:

http://jan.kneschke.de/projects/mysql/order-by-rand/

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

http://jan.kneschke.de/2007/2/22/analyzing-complex-queries

regards,

Nils

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to