]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Improve eqjoinsel's ndistinct clamping to work for multiple levels of join.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 31 Aug 2011 20:05:05 +0000 (16:05 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 31 Aug 2011 20:05:05 +0000 (16:05 -0400)
commit46f775144e4f8a55812af9ba164efd4891ddaac5
treec689c100fd546df009bc216757fb61167c905a31
parent201646d16f87f2720e337269004ae0340a695aa9
Improve eqjoinsel's ndistinct clamping to work for multiple levels of join.

This patch fixes an oversight in my commit
7f3eba30c9d622d1981b1368f2d79ba0999cdff2 of 2008-10-23.  That patch
accounted for baserel restriction clauses that reduced the number of rows
coming out of a table (and hence the number of possibly-distinct values of
a join variable), but not for join restriction clauses that might have been
applied at a lower level of join.  To account for the latter, look up the
sizes of the min_lefthand and min_righthand inputs of the current join,
and clamp with those in the same way as for the base relations.

Noted while investigating a complaint from Ben Chobot, although this in
itself doesn't seem to explain his report.

Back-patch to 8.4; previous versions used different estimation methods
for which this heuristic isn't relevant.
src/backend/utils/adt/selfuncs.c