Re: [Bizgres-general] A Guide to Constraint Exclusion (
Luke Lonergan <llonergan@greenplum.com>
From: "Luke Lonergan" <llonergan@greenplum.com>
To: "Simon Riggs" <simon@2ndquadrant.com>
Cc: "Hannu Krosing" <hannu@skype.net>, "bizgres-general" <bizgres-general@pgfoundry.org>, pgsql-hackers@postgresql.org
Date: 2005-07-14T22:44:58Z
Lists: pgsql-hackers
Simon,
> It's the first time I've thought to compare the constraint predicates on
> joined tables based upon the join restriction. That's possible, but
> would take some time to work out.
>
> I've argued that such a construct is not common. I'm open to suggestions
> about what *is* common...
I also don't believe it is commonly used. There are occasions where fact
tables are joined on a common key, but for CE to be effective, the key would
have to be used in a similar way in constructing the partitions.
There are many other ways to accomplish useful patterns, like partitioning
fact tables based on a date based key, then using a constant predicate in
the join, e.g:
SELECT * FROM Fact AND Dimension
WHERE Fact.a = Dimension.a
AND to_char(T1.key,"MONTH") = 'JUNE'
AND to_char(T1.key,"YYYY") = '2003';
With Fact defined with 12 partitions
CHECK(to_char(key,"MONTH") EQUAL 'JANUARY')
...
CHECK(to_char(key,"MONTH") EQUAL 'DECEMBER')
- Luke