From: Tom Lane <tgl@sss.pgh.pa.us>
To: fatih ozturk <ozturkfa@yahoo.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Partitionin with check functions
Date: Mon, 30 Mar 2009 09:47:39 -0400
Message-ID: <2499.1238420859@sss.pgh.pa.us> (raw)
In-Reply-To: <20867.32524.qm@web111513.mail.gq1.yahoo.com>
References: <20867.32524.qm@web111513.mail.gq1.yahoo.com>
fatih ozturk <ozturkfa@yahoo.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, ozturkfa@yahoo.com
Subject: Re: Partitionin with check functions
In-Reply-To: <2499.1238420859@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox