Re: Partitionin with check functions
От | Tom Lane |
---|---|
Тема | Re: Partitionin with check functions |
Дата | |
Msg-id | 2499.1238420859@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Partitionin with check functions (fatih ozturk <ozturkfa@yahoo.com>) |
Список | pgsql-admin |
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
В списке pgsql-admin по дате отправления: