From: Tom Lane <tgl@sss.pgh.pa.us>
To: Martin Lesser <ml-pgsql@bettercom.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: Partitioning / constrain exlusion not working with %-operator
Date: Mon, 31 Jul 2006 08:42:57 -0400
Message-ID: <13552.1154349777@sss.pgh.pa.us> (raw)
In-Reply-To: <87ejw27yuz.fsf@fs-home.bettercom.de>
References: <87ejw27yuz.fsf@fs-home.bettercom.de>
Martin Lesser <ml-pgsql@bettercom.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
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-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, ml-pgsql@bettercom.de
Subject: Re: Partitioning / constrain exlusion not working with %-operator
In-Reply-To: <13552.1154349777@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