Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 85C481337B68 for ; Wed, 20 Apr 2011 20:49:25 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 32289-08 for ; Wed, 20 Apr 2011 23:49:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-1.01.com (smtp-1.01.com [38.102.63.180]) by mail.postgresql.org (Postfix) with ESMTP id 304721337B47 for ; Wed, 20 Apr 2011 20:49:18 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp-1.01.com (Postfix) with ESMTP id 6F8F236453F for ; Wed, 20 Apr 2011 18:49:18 -0500 (CDT) Received: from smtp-1.01.com ([127.0.0.1]) by localhost (smtp-1.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xo2IU+74n0iK for ; Wed, 20 Apr 2011 18:49:18 -0500 (CDT) Received: by smtp-1.01.com (Postfix, from userid 99) id 567B0365512; Wed, 20 Apr 2011 18:49:18 -0500 (CDT) Received: from Sidney-Stratton.local (70-36-143-243.dsl.dynamic.sonic.net [70.36.143.243]) by smtp-1.01.com (Postfix) with ESMTPSA id 1E0DC36453F for ; Wed, 20 Apr 2011 18:49:18 -0500 (CDT) Message-ID: <4DAF70FD.7000609@agliodbs.com> Date: Wed, 20 Apr 2011 16:49:17 -0700 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Constraint exclusion can't process simple constant expressions? X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201104/283 X-Sequence-Number: 43345 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