From: | Markus Schaber <schabi(at)logix-tt(dot)com> |
---|---|
To: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Index Being Ignored? |
Date: | 2006-06-30 14:29:06 |
Message-ID: | 44A53532.50402@logix-tt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Hi, Joe,
Joe Lester wrote:
> Aggregate (cost=22695.28..22695.28 rows=1 width=0) (actual
> time=2205.688..2205.724 rows=1 loops=1)
> -> Seq Scan on purchase_order_items (cost=0.00..21978.08 rows=286882
> width=0) (actual time=0.535..2184.405 rows=7458 loops=1)
> Filter: (expected_quantity > 0)
The query planner estimates that your filter will hit 286882 rows, while
in reality it hits only 7458 rows. That's why the query planer chooses a
sequential scan.
It seems that the statistics for the column expected_quantity are off.
My suggestions:
- make shure that the statistics are current by analyzing the table
appropriately (e. G. by using the autovacuum daemon from contrib).
- increase the statistics target for this column.
- if you run this query very often, an conditional index might make sense:
CREATE INDEX purchase_order_having_quantity_idx ON purchase_order_items
(expected_quantity) WHERE expected_quantity > 0;
HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org
From | Date | Subject | |
---|---|---|---|
Next Message | Brad Nicholson | 2006-06-30 14:36:03 | Re: newly created database makes queries run 300% faster |
Previous Message | Alvaro Herrera | 2006-06-30 14:14:55 | Re: Index Being Ignored? |