Comment

Peter Bengtsson

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

Parent comment

hutch

no need, now that i've filled up the database with faked data, we get this: 0.862994 seconds 0.104061 seconds 0.894336 seconds 0.114008 seconds 0.809722 seconds 0.102276 seconds

Replies

hutch

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.

Peter Bengtsson

Don't think so, out of the 14 seconds about 0.4 seconds is spent getting the counts.