model-writtenrun 3639 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Alexander Kuzmenkov reported that MergeAppend charged child sorts for all table tuples rather than the rows remaining after filtering, potentially favoring Sort + Append; Ashutosh Bapat agreed after comparing other cost_sort() callers and requested a regression test #1 #2.
- Alexander submitted a one-line fix using subpath->rows and an inheritance regression test, and Aleksander Alekseev confirmed the intended plan change and passing tests #3 #4.
- David Rowley approved the code fix but requested a smaller test, explaining that UNION ALL would not reproduce the bug because its tuple estimate already comes from the subquery's output rows; Alexander reduced the test to 1,000 smallint rows per table #5 #6.
- David supplied a further reduction to 400 and 200 integer rows and initially favored backpatching; Ashutosh tested that case, confirmed the plan change, and supported master while raising concerns about plan regressions in stable releases #7 #8 #10.
- Alexander argued that correcting the existing cost model should improve filtered MergeAppend plans, but Alvaro Herrera and Daniel Westermann cautioned against unexpected plan changes in minor releases, and Tom Lane reiterated the policy against backpatching such changes #11 #12 #13 #14 #15.
- David committed the latest patchset with the unchanged costing fix and lightly revised regression test as 9d1a5354f5, choosing no backpatch because plans could change #6 #7.
- David announced that the fix had landed on master, and Alexander thanked him; the thread ended with the fix committed and no remaining patch revisions pending #16 #17.