Re: BUG #15160: planner overestimates number of rows in join when there are more than 200 rows coming from CTE

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: alexey.ermakov@dataegret.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2018-04-17T14:15:38Z
Lists: pgsql-bugs, pgsql-hackers
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> I'm wondering how planner estimates number of rows in that case:

See eqjoinsel_semi, particularly the change in behavior when it thinks
nd2 is or is not a default estimate.

Given the lack of statistics about the output of the WITH clause,
it's hard to see how we'd ever get trustworthy estimates here.
I think the fact that your first example yields an accurate
estimate is mostly luck.

			regards, tom lane


Commits

  1. Clamp semijoin selectivity to be not more than inner-join selectivity.