Re: join removal

Lawrence, Ramon <ramon.lawrence@ubc.ca>

From: "Lawrence, Ramon" <ramon.lawrence@ubc.ca>
To: "Robert Haas" <robertmhaas@gmail.com>
Cc: <pgsql-hackers@postgresql.org>
Date: 2009-08-10T15:30:44Z
Lists: pgsql-hackers

Attachments

> I took at a first crack at coding up an implementation of
> relation_is_distinct_for() tonight.

I am not sure if this will help or not, but on the 8.4 code base we
implemented two functions:

- getCandidateKeys() - would recursively traverse a tree from a given
node to the leaf nodes and determine the candidate keys for the
intermediate relation produced by that node

- getJoinCard() - determined the join cardinality of a hash join node
(1:1, 1:N, etc.) based on the candidate keys of the two input relations

It worked pretty well for our tests with equi-joins, but I am sure it is
missing many cases.  I have attached the code which we used
(cardinalityFuncs.c).  Some of the helper functions may also be useful
(convertUniqueIndexesToCandidateKeys, getJoinAttrs).

--
Ramon Lawrence