From: | Zach Calvert <zachcalvert(at)hemerasoftware(dot)com> |
---|---|
To: | pgsql-performance(at)postgresql(dot)org |
Subject: | Improve Query |
Date: | 2009-05-27 12:09:48 |
Message-ID: | 89af81ab0905270509v78384f03y2c98d90b668ced87@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
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 (cost=2491.06..2491.07 rows=1 width=0) (actual
time=38.878..38.878 rows=1 loops=1)"
" -> Seq Scan on score (cost=0.00..2391.17 rows=39954 width=0)
(actual time=0.012..30.760 rows=38571 loops=1)"
" Filter: (active AND (score <= 6841) AND (leaderboardid = 35))"
"Total runtime: 38.937 ms"
I have an index on score, I have an index on score and leaderboard and
active. I can't seem to figure out how to create an index that will
turn that "Seq Scan" into an index scan. The biggest problem is that
the query degrades very quickly with a lot more rows and I will be
getting A LOT MORE rows. What can I do to improve the performance of
this query?
Thank you so much,
ZC
From | Date | Subject | |
---|---|---|---|
Next Message | Alan McKay | 2009-05-27 13:24:51 | running bonnie++ |
Previous Message | Thomas Kellerer | 2009-05-27 11:43:10 | L |