Re: [PERFORM] Partitioned table - scans through every partitions - Mailing list pgsql-performance

From Justin Pryzby
Subject Re: [PERFORM] Partitioned table - scans through every partitions
Date
Msg-id 20170825154434.GC16287@telsasoft.com
Whole thread Raw
In response to [PERFORM] Partitioned table - scans through every partitions  (Aniko Belim <anikob@spiceworks.com>)
Responses Re: [PERFORM] Partitioned table - scans through every partitions  (Aniko Belim <anikob@spiceworks.com>)
List pgsql-performance
On Fri, Aug 25, 2017 at 03:36:29PM +0000, Aniko Belim wrote:
> Hi,
>
> We have an issue with one of our partitioned tables. It has a column with timestamp without time zone type, and we
hadto partition it daily. To do that, we created the following constraints like this example: 
> CHECK (to_char(impression_time, 'YYYYMMDD'::text) = '20170202'::text)
>
>
> The problem we’re facing is no matter how we’re trying to select from it, it scans through every partitions.


> It scans through every partitions. Shouldn’t it only scan the
dfp_in_network_impressions.dfp_in_network_impressions_20170202child table? Or we missing something? 
> Any advice/help would highly appreciated.

https://www.postgresql.org/docs/9.6/static/ddl-partitioning.html#DDL-PARTITIONING-CAVEATS
|The following caveats apply to constraint exclusion:
|    Constraint exclusion only works when the query's WHERE clause contains
|    constants (or externally supplied parameters). For example, a comparison
|    against a non-immutable function such as CURRENT_TIMESTAMP cannot be
|    optimized, since the planner cannot know which partition the function value
|    might fall into at run time.

...


pgsql-performance by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: [PERFORM] 10x faster sort performance on Skylake CPU vs Ivy Bridge
Next
From: Aniko Belim
Date:
Subject: Re: [PERFORM] Partitioned table - scans through every partitions