pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Neill <rn214@richardneill.org>
Cc: pgsql-performance@postgresql.org
Subject: Re: Why does the query planner use two full indexes, when a dedicated partial index exists?
Date: Thu, 20 Dec 2012 05:51:57 +0000
Message-ID: <50D2A77D.10809@richardneill.org> (raw)
In-Reply-To: <28778.1355972790@sss.pgh.pa.us>
References: <50D22DE2.4090301@richardneill.org>
	<28778.1355972790@sss.pgh.pa.us>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

Dear Tom,

Thanks very much for your advice.

>> A psql session is below.  This shows that, if I force the planner to use
>> the partial index, by dropping the others, then it's fast. But as soon
>> as I put the full indexes back (which I need for other queries), the
>> query planner chooses them instead, and is slow.
>
> [ experiments with a similar test case ... ]  I think the reason why the
> planner is overestimating the cost of using the partial index is that
> 9.1 and earlier fail to account for the partial-index predicate when
> estimating the number of index rows that will be visited.  Because the
> partial-index predicate is so highly selective in this case, that
> results in a significant overestimate of how much of the index will be
> traversed.

I think that seems likely to me.

I'll try out 9.2 and see if it helps. As it's a production server, I 
have to wait for some downtime, probably Friday night before I can find 
out - will report back.

Best wishes,

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: <50D2A77D.10809@richardneill.org>
Permalink:  ../50D2A77D.10809@richardneill.org/
Also on:    postgresql.org/message-id/50D2A77D.10809@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: <50D2A77D.10809@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