Re: join removal
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Greg Stark <stark@mit.edu>, "<pgsql-hackers@postgresql.org>" <pgsql-hackers@postgresql.org>
Date: 2009-08-28T03:23:48Z
Lists: pgsql-hackers
Attachments
- join_removal.wip.2009-08-27.patch (text/x-patch) patch
On Sun, Aug 16, 2009 at 5:31 PM, Robert Haas<robertmhaas@gmail.com> wrote: > It seems that the needed checks are very similar to the ones that we > already implement when setting restrictinfo->mergeopfamilies. That is > filled in by get_mergejoin_opfamilies(), which checks for btree > opfamilies where the strategy number is BTEqualStrategyNumber. This > might cease to be the correct check in the (not-too-distant?) future > if we end up implementing other kinds of unique indices, but right now > btrees are all there is. > > One possibility would be to have relation_is_distinct_for() call > get_mergejoin_opfamilies() for each operator; then for each index we > can check whether the opfamily of the relevant index column is in the > returned list. This seems a bit wasteful, though, since I believe > that relation_is_distinct_for() would be called from joinpath.c, which > has access to restrictinfo->mergeopfamilies already. > > I'm wondering whether it would make more sense to modify the proposed > API for relation_is_distinct_for() in some way so that we don't lose > this information. Here is an attempt at the latter approach. This doesn't actually remove the join yet; it just checks whether the join can be removed. I haven't tested it extensively yet, but am hoping for some feedback on the basic approach. ...Robert