Re: [PERFORM] Improve Query

2009-05-27 Thread Heikki Linnakangas
Zach Calvert wrote: Still getting a seq scan after doing vacuum analyze. Any other ideas? Try CLUSTERing the table on the (leaderboardid, active, score) index. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com -- Sent via pgsql-performance mailing list (pgsql-performance@p

Re: [PERFORM] Improve Query

2009-05-27 Thread Zach Calvert
Still getting a seq scan after doing vacuum analyze. Any other ideas? 2009/5/27 Grzegorz Jaśkiewicz : > you have to vacuum analyze after you've created index, afaik. > No, count(*) is still counting rows. > -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make ch

Re: [PERFORM] Improve Query

2009-05-27 Thread Grzegorz Jaśkiewicz
you have to vacuum analyze after you've created index, afaik. No, count(*) is still counting rows. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance

Re: [PERFORM] Improve Query

2009-05-27 Thread Zach Calvert
I'm running the inserts now via a JDBC call I have, which is then followed up by the query I'm showing and a few others. I have run tests on all of the others, and all others run index scans and are very fast, 10 ms or less. This one started at 2 milliseconds when the table is empty and is up to

Re: [PERFORM] Improve Query

2009-05-27 Thread Nikolas Everett
The plan ought to be different when there are more scores and the table is analyzed and your statistics target is high enough. At this point you don't have enough data to merit doing anything but a seq scan. The overhead is simply not worth it. You could try inserting a lot more rows. I'd creat

Re: [PERFORM] Improve Query

2009-05-27 Thread Grzegorz Jaśkiewicz
try creating index on all three columns. Btw, 38ms is pretty fast. If you run that query very often, do prepare it, cos I reckon it takes few ms to actually create plan for it. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http

[PERFORM] Improve Query

2009-05-27 Thread Zach Calvert
So Google hasn't been helpful and I'm not entirely sure what to look for in the mailing lists to find the answer to my problem, so here goes. I have a query and I have run explain analyze select count(*) from score where leaderboardid=35 and score <= 6841 and active The result is "Aggregate (co