Re: Partitioned/inherited tables with check constraints causing slower query plans - Mailing list pgsql-performance

From Tom Lane
Subject Re: Partitioned/inherited tables with check constraints causing slower query plans
Date
Msg-id 7297.1336149542@sss.pgh.pa.us
Whole thread Raw
In response to Partitioned/inherited tables with check constraints causing slower query plans  (Richard Jones <rj@metabrew.com>)
Responses Re: Partitioned/inherited tables with check constraints causing slower query plans
List pgsql-performance
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=ef03b34550e3577c4be3baa25b70787f5646c57b
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

pgsql-performance by date:

Previous
From: Jeff Janes
Date:
Subject: Re: Configuration Recommendations
Next
From: Richard Jones
Date:
Subject: Re: Partitioned/inherited tables with check constraints causing slower query plans