Constraint exclusion can't process simple constant expressions?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Constraint exclusion can't process simple constant expressions?
Date: 2011-04-20 23:49:17
Message-ID: 4DAF70FD.7000609@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

All,

Apparently our CE is unable to deal with even moderately complex
expressions. For example, given a CE check constraint of:

"chk_start" CHECK (start >= '2011-01-31 00:00:00-05'::timestamp with
time zone AND start < '2011-03-01 00:00:00-05'::timestamp with time zone)

PostgreSQL CE is unable to figure out not to scan this partition for a
query which contains the following filter condition:

WHERE start >= '2010-11-01'::timestamptz
AND start < ('2010-11-30'::timestamptz + '1
day'::interval)::timestamptz

Even though it can figure out this one:

WHERE call_start >= '2010-11-01'::timestamptz
AND call_start < '2010-12-01'::timestamptz

I understand why now() is a problem for CE, but I'd expect that it could
at least handle a simple expression with immutable outputs.

We need a new form of partitioning ...

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2011-04-21 00:48:49 Re: Constraint exclusion can't process simple constant expressions?
Previous Message Shaun Thomas 2011-04-20 15:40:13 Re: postgresql random io test with 2 SSD Kingston V+100 500GB in (software) Raid1