pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Jones <rj@metabrew.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Partitioned/inherited tables with check constraints causing slower query plans
Date: Fri, 04 May 2012 12:39:02 -0400
Message-ID: <7297.1336149542@sss.pgh.pa.us> (raw)
In-Reply-To: <CACmxXrAbbM7JevUssCL+DFAkLvOC5GwRUjg=oarU7nVqXd1aRw@mail.gmail.com>
References: <CACmxXrAbbM7JevUssCL+DFAkLvOC5GwRUjg=oarU7nVqXd1aRw@mail.gmail.com>

Richard Jones <rj@metabrew.com> writes:
> I'm seeing poor query performance using partitioned tables with check
> constraints, seems like the plan is much worse than when querying the
> individual partitions manually.

> select version(); --> PostgreSQL 9.1.1 on x86_64-unknown-linux-gnu,
> compiled by gcc (Debian 4.4.5-8) 4.4.5, 64-bit

I get a reasonable-looking plan when I try to duplicate this issue in
9.1 branch tip.  I think the reason you're not getting the right
behavior is that you are missing this as-yet-unreleased patch:
http://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=ef03b34550e3577c4be3baa25b...
which means it can't figure out that the available index on the child
table produces the desired sort order.  If you're in a position to
compile from source, a current nightly snapshot of the 9.1 branch
ought to work for you; otherwise, wait for 9.1.4.

(Note: although that patch is a one-liner, I would *not* recommend
trying to just cherry-pick the patch by itself; I think it probably
interacts with other planner fixes made since 9.1.1.)

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <7297.1336149542@sss.pgh.pa.us>
Permalink:  ../7297.1336149542@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7297.1336149542@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, rj@metabrew.com
  Subject: Re: Partitioned/inherited tables with check constraints causing slower query plans
  In-Reply-To: <7297.1336149542@sss.pgh.pa.us>

* 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