Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 762A2633D58 for ; Mon, 30 Mar 2009 10:47:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 99910-01 for ; Mon, 30 Mar 2009 10:47:35 -0300 (ADT) Received: from mx1.hub.org (mx1.hub.org [200.46.208.106]) by mail.postgresql.org (Postfix) with ESMTP id 14562633D4E for ; Mon, 30 Mar 2009 10:47:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mx1.hub.org (Postfix) with ESMTP id 919CE125A956 for ; Mon, 30 Mar 2009 10:47:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n2UDlddq002500; Mon, 30 Mar 2009 09:47:40 -0400 (EDT) To: fatih ozturk cc: pgsql-admin@postgresql.org Subject: Re: Partitionin with check functions In-reply-to: <20867.32524.qm@web111513.mail.gq1.yahoo.com> References: <20867.32524.qm@web111513.mail.gq1.yahoo.com> Comments: In-reply-to fatih ozturk message dated "Mon, 30 Mar 2009 01:34:52 -0700" Date: Mon, 30 Mar 2009 09:47:39 -0400 Message-ID: <2499.1238420859@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.224 tagged_above=0 required=5 tests=AWL=-0.186, SUBJECT_FUZZY_TION=0.41 X-Spam-Level: X-Archive-Number: 200903/247 X-Sequence-Number: 31747 fatih ozturk writes: > My problem in partitioning is about using functions in table check constraints. By and large, you can't. Per the fine manual: Keep the partitioning constraints simple, else the planner may not be able to prove that partitions don't need to be visited. Use simple equality conditions for list partitioning, or simple range tests for range partitioning, as illustrated in the preceding examples. A good rule of thumb is that partitioning constraints should contain only comparisons of the partitioning column(s) to constants using B-tree-indexable operators. In particular, a constraint like "sel=123" is *not* going to lead the planner to draw any conclusions about the value of "mod(sel,6)". Now, if you'd written "WHERE mod(sel,6)=3", I think it would draw the right conclusions. The underlying issue here is that "a=b" does not imply "f(a)=f(b)" for all functions f, not even if "=" is known to be a btree equality operator. Several of PG's standard datatypes have counterexamples, so the planner *must* take this seriously. regards, tom lane