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

From Daniel Begin
Subject FW: Constraint exclusion in partitions
Date
Msg-id COL129-DS2742F0E91BEB7BE773D3BE94C00@phx.gbl
Whole thread Raw
Responses Re: FW: Constraint exclusion in partitions  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: FW: Constraint exclusion in partitions  (Francisco Olarte <folarte@peoplecall.com>)
List pgsql-general

Sent that on pgsql-novice list but did not get any answers yet.

Maybe someone could help me understand here J

 

 

Hi all,

 

I have split a large table (billions of records) into multiple partitions, hoping the access would be faster. I used an ID to make partitions check (check (id >= 100 AND id < 200)…) and created over 80 tables (children) that are now filled with data.  

 

However, after I did it, I read a second time the following sentence in the documentation and started wondering what it actually means …  “Constraint exclusion only works when the query's WHERE clause contains constants (or externally supplied parameters)”

 

I understand that the following query will use constraint exclusion and will run faster…  

a-      Select * from parent_table where id >=9999; -- using a constant

 

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

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

 

Since I mostly use queries of type b and c, I am wondering if partitioning the large table was appropriate and if the queries are going to be longer to run…

Thank in advance

 

Daniel

 

Doc: http://www.postgresql.org/docs/9.3/static/ddl-partitioning.html

pgsql-general by date:

Previous
From: Bill Moran
Date:
Subject: Re: Allowing postgresql to accept 0xff syntax for data types that it makes sense for?
Next
From: "David G. Johnston"
Date:
Subject: Re: FW: Constraint exclusion in partitions