model-writtenrun 9887 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Alexey Ermakov reported that increasing a CTE result from 200 to 201 rows changed the estimated join output from 200 to 500,000 rows; Tom Lane traced the discontinuity to eqjoinsel_semi’s handling of default distinct-value estimates and the absence of CTE statistics #1 #2.
- Months later, Maxim Boguk demonstrated the same problem without a CTE and described its impact on larger joins; Tom responded with a patch bounding semijoin output by the equivalent inner-join estimate while sharing statistics lookup between the estimators #3 #4.
- Melanie Plageman verified the original reproducer and regression tests, questioned the estimation formulas and parameter choices, and requested clearer comments; Tom defended retaining default-estimate safeguards and explained why filtered inner-side distinct counts require special treatment #5 #6.
- Melanie supplied a refactoring delta moving null-fraction and fallback calculations into eqjoinsel(), but Tom declined it to preserve the separation between information lookup and selectivity calculation and avoid unused calculations #7 #8.
- Melanie marked the patch ready for committer and suggested clearer Ssemi/Sinner notation plus a possible cardinality-estimation test harness; in the final message, Tom promised to rewrite the comment and said he had not felt a need for that additional harness #9 #10.
- Tom subsequently committed the original patch with only the clamp comment revised as a314c34079, credited Melanie’s review, and declined backpatching to avoid destabilizing stable-branch plans; the optional refactoring and test-harness idea were not included.