⬅︎ Back to Optimization of getting random rows out of a PostgreSQL in Django
no need, now that i've filled up the database with faked data, we get this:0.862994 seconds0.104061 seconds0.894336 seconds0.114008 seconds0.809722 seconds0.102276 seconds
Do it on a proper database like postgres and copy and paste the SQL that Django generates then run it like this: mydatabase# EXPLAIN ANALYZE ;
Are you sure you're doing that right? I just tried it myself and got this:COUNT 84482using_max() took 0.613966941833 secondsusing_max2() took 2.08254098892 secondsusing_count_and_slice() took 14.112842083 secondsCode here: http://www.peterbe.com/plog/getting-random-rows-postgresql-django/get_random_ones.py
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.
Don't think so, out of the 14 seconds about 0.4 seconds is spent getting the counts.
Comment
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
Parent comment
Do it on a proper database like postgres and copy and paste the SQL that Django generates then run it like this: mydatabase# EXPLAIN ANALYZE;
Replies
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
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.
Don't think so, out of the 14 seconds about 0.4 seconds is spent getting the counts.