From: | Richard Neill <rn214(at)richardneill(dot)org> |
---|---|
To: | PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Why does the query planner use two full indexes, when a dedicated partial index exists? |
Date: | 2012-12-27 16:43:38 |
Message-ID: | 50DC7ABA.5010109@richardneill.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On 27/12/12 16:17, Jeff Janes wrote:
>
> I still think your best bet is to get rid of the partial index and trade
> the full one on (parcel_id_code) for one on (parcel_id_code,exit_state).
> I think that will be much less fragile than reindexing in a cron job.
>
So, at the moment, I have 3 indexes:
full: parcel_id_code
full: exit_state
full: parcel_id_code where exit state is null
Am I right that when you suggest just a single, joint index
(parcel_id_code,exit_state)
instead of all 3 of the others,
it will allow me to optimally run all of the following? :
1. SELECT * from tbl_tracker WHERE parcel_id_code=22345 AND exit_state
IS NULL
(this is the one we've been discussing)
2. SELECT * from tbl_tracker where parcel_id_code=44533
3. SELECT * from tbl_tracker where exit_code = 2
(2 and 3 are examples of queries I need to run for other purposes,
unrelated to this thread, but which use the other indexes.).
Thanks,
Richard
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2012-12-27 17:05:18 | Re: Why does the query planner use two full indexes, when a dedicated partial index exists? |
Previous Message | Jeff Janes | 2012-12-27 16:17:16 | Why does the query planner use two full indexes, when a dedicated partial index exists? |