When estimating without benefit of MCV lists (suggesting that one or both
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 23 Oct 2008 00:24:50 +0000 (00:24 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 23 Oct 2008 00:24:50 +0000 (00:24 +0000)
commit4f9b0b457a88ddf9b11a79fd1fe6c7b365ceeec9
treec5d4aabe6cc0f2b40dac18030be999c4d0f42136
parente80fde56022593d576f7cc0dd069e79febb17217
When estimating without benefit of MCV lists (suggesting that one or both
inputs is unique or nearly so), make eqjoinsel() clamp the ndistinct estimates
to be not more than the estimated number of rows coming from the input
relations.  This allows the estimate to change in response to the selectivity
of restriction conditions on the inputs.

This is a pretty narrow patch and maybe we should be more aggressive about
similarly clamping ndistinct in other cases; but I'm worried about
double-counting the effects of the restriction conditions.  However, it seems
to help for the case exhibited by Grzegorz Jaskiewicz (antijoin against a
small subset of a relation), so let's try this for awhile.
src/backend/utils/adt/selfuncs.c