Re: Constraint exclusion - Mailing list pgsql-sql

From Tom Lane
Subject Re: Constraint exclusion
Date
Msg-id 3618.1182379001@sss.pgh.pa.us
Whole thread Raw
In response to Constraint exclusion  ("Fernando Hevia" <fhevia@ip-tel.com.ar>)
Responses Re: Constraint exclusion  ("Fernando Hevia" <fhevia@ip-tel.com.ar>)
List pgsql-sql
"Fernando Hevia" <fhevia@ip-tel.com.ar> writes:
> -- Constraints: one partition per month
> ALTER TABLE table_p01 ADD CONSTRAINT chk_table_p01_setuptime CHECK
> (EXTRACT(MONTH FROM setuptime) =  1::DOUBLE PRECISION);

The planner is not able to do anything with these constraints, other
than if there is an exact match to them in the query WHERE, which
there is not.  Try simple range constraints on the column, instead.
The system does know about inferences like "colx <= const1 must
imply colx <= const2 if const1 <= const2".  It does not know how
to reason about extract().
        regards, tom lane


pgsql-sql by date:

Previous
From: "Fernando Hevia"
Date:
Subject: Constraint exclusion
Next
From: Bryce Nesbitt
Date:
Subject: Technique for turning time ranges into a graph