Are you sure you're doing that right? I just tried it myself and got this: COUNT 84482 using_max() took 0.613966941833 seconds using_max2() took 2.08254098892 seconds using_count_and_slice() took 14.112842083 seconds Code here: http://www.peterbe.com/plog/getting-random-rows-postgresql-django/get_random_ones.py
Comment
no, i think the numbers jive, and you're right.
it seems to be a 7x factor using the count/slice method i was talking about.
Parent comment
Are you sure you're doing that right? I just tried it myself and got this: COUNT 84482 using_max() took 0.613966941833 seconds using_max2() took 2.08254098892 seconds using_count_and_slice() took 14.112842083 seconds Code here: http://www.peterbe.com/plog/getting-random-rows-postgresql-django/get_random_ones.py
Replies
Don't think so, out of the 14 seconds about 0.4 seconds is spent getting the counts.