Re: FW: Constraint exclusion in partitions - Mailing list pgsql-general

From David G. Johnston
Subject Re: FW: Constraint exclusion in partitions
Date
Msg-id CAKFQuwahY0_9+bX0rVkmE-+qVQD0Qose-CTWprR_AOW19k7=qg@mail.gmail.com
Whole thread Raw
In response to FW: Constraint exclusion in partitions  (Daniel Begin <jfd553@hotmail.com>)
List pgsql-general
On Fri, May 22, 2015 at 10:21 AM, Daniel Begin <jfd553@hotmail.com> wrote:

But how constraint exclusion would react with the following queries …

b-      Select * from parent_table where id between 2345 and 6789; -- using a range of ids

​Not sure...

These are constants but I'm not sure how smart the planner is about figuring out inequalities of this form.

I would guess yes but it should be easy enough to confirm this yourself using explain...you already have the tables.

c-       Select * from parent_table where id in(select ids from anothertable); -- using a list of ids from a select

Definitely no...

Constraint exclusion is done by the planner before data is read so there is no possible way for data in a table to be used.​


As for performance the only way to know for sure is to test your usage patterns and data.  Even without constraint exclusion partitioning can provide benefits.

David J.

pgsql-general by date:

Previous
From: Daniel Begin
Date:
Subject: FW: Constraint exclusion in partitions
Next
From: "Stefan Stefanov"
Date:
Subject: Re: About COPY command (and probably file fdw too)