pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Neill <rn214@richardneill.org>
To: PostgreSQL Performance <pgsql-performance@postgresql.org>
Subject: Re: Why does the query planner use two full indexes, when a dedicated partial index exists?
Date: Thu, 27 Dec 2012 16:43:38 +0000
Message-ID: <50DC7ABA.5010109@richardneill.org> (raw)
In-Reply-To: <CAMkU=1wGV4KZnDbcqdELyaxE4sMvza05KurjA0VH7m9cTn5J_A@mail.gmail.com>
References: <50D22DE2.4090301@richardneill.org>
	<28778.1355972790@sss.pgh.pa.us>
	<50D3CAC4.3070800@richardneill.org>
	<CAMkU=1w1yqYepDpmKo5fuL9Akkk4t_AOiwoc6u2k5ysfAEt1kQ@mail.gmail.com>
	<CAMkU=1wGV4KZnDbcqdELyaxE4sMvza05KurjA0VH7m9cTn5J_A@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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




-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (30+ messages)  latest in thread

Message-ID: <50DC7ABA.5010109@richardneill.org>
Permalink:  ../50DC7ABA.5010109@richardneill.org/
Also on:    postgresql.org/message-id/50DC7ABA.5010109@richardneill.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: rn214@richardneill.org
  Subject: Re: Why does the query planner use two full indexes, when a dedicated partial index exists?
  In-Reply-To: <50DC7ABA.5010109@richardneill.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox