Re: Partitioning table - explain said that all partition tables are scanned - Mailing list pgsql-novice

From Tom Lane
Subject Re: Partitioning table - explain said that all partition tables are scanned
Date
Msg-id 1379.1144709070@sss.pgh.pa.us
Whole thread Raw
In response to Partitioning table - explain said that all partition tables are scanned  ("Pazargic Antonel Ernest" <antonel.pazargic@gmail.com>)
List pgsql-novice
"Pazargic Antonel Ernest" <antonel.pazargic@gmail.com> writes:
> DDL-s
> Master table:
> create table master(masterid integer default nextval('seq_master'), nume
> varchar(25) not null, timpul timestamp not null, constraint pk_master
> primary key (masterid), constraint uq1_master unique (nume));

> Partition tables:
> create table master_012006(constraint ck1_master012006 check (timpul >=
> DATE '2006-01-01' AND timpul < DATE '2006-02-01') ) inherits (master);

Oh, there's your problem: you need to lose the unnecessary DATE type
coercions and just let the constants in the constraints be timestamps.

The way you've set this up, the constraints involve cross-datatype
comparisons (timestamp vs date) and the planner is not very good about
proving inferences involving cross-type comparisons.  The difficulty
is basically that it can't assume that '>' on dates has anything to do
with '>' on timestamps --- there is nothing in the system catalogs that
justifies assuming that they sort in compatible fashions.

            regards, tom lane

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Explain query on table with partition tables
Next
From: Richard Broersma Jr
Date:
Subject: Re: PostgreSQL a slow DB?