Skip site navigation (1) Skip section navigation (2)

Re: Partitioning / constrain exlusion not working with %-operator

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martin Lesser <ml-pgsql(at)bettercom(dot)de>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Partitioning / constrain exlusion not working with %-operator
Date: 2006-07-31 12:42:57
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
Martin Lesser <ml-pgsql(at)bettercom(dot)de> writes:
> I try to partition a large table (~ 120 mio. rows) into 50 smaller
> tables but using the IMO immutable %-function constraint exclusion
> does not work as expected:

The constraint exclusion mechanism is not as bright as you think.
There are some very limited cases where it can make a deduction that
a WHERE clause implies a CHECK constraint that's not an exact textual
equivalent ... but all those cases have to do with related b-tree
operators, and % is not one.

It's usually better to use partitioning rules that have something to
do with the WHERE-clauses you'd be using anyway.  For instance, try
to partition on ranges of id1 instead of id1 % 50.  That works because
the CHECK clauses will be like "id1 >= x and id1 < y" and those
operators are btree-related to the "id1 = z" clauses you'll have in
the query.

			regards, tom lane

In response to


pgsql-performance by date

Next:From: Jonathan BalletDate: 2006-07-31 12:53:24
Subject: Performances with new Intel Core* processors
Previous:From: Martin LesserDate: 2006-07-31 12:17:08
Subject: Partitioning / constrain exlusion not working with %-operator

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group