=?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