model-writtenrun 3669 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- William Duclot reported that a prepared MIN/MAX query switched after five executions to a generic plan over 6500 times slower, with force_custom_plan providing a workaround #1.
- David Rowley proposed avoiding the redundant IS NOT NULL condition introduced by MIN/MAX rewriting, using Andy Fan’s NOT NULL attribute tracking, while Tom Lane cautioned that general use required awareness of outer-join nulling #3 #7.
- Rowley posted a two-patch prototype that fixed the reported plan but required questionable movement of aggregate preprocessing, then favored general removal of redundant restrictions; Lane agreed that removal should happen later when the required information was available #9 #10.
- After Andres Freund challenged the scan costing, Lane explained that missing ordering-correlation information made LIMIT assume qualifying rows would appear quickly, leaving the underlying estimation problem unresolved #11 #12.
- Almost a year later, Rowley resumed the work with a general check in restriction distribution that discarded IS NOT NULL conditions on NOT NULL columns #13.
- Richard Guo proposed and implemented OR-expression and join-clause handling using varnullingrels, then added regression tests at Rowley’s request and corrected postgres_fdw coverage #14 #15 #16 #17 #18.
- Rowley experimented with reducing IS NULL to FALSE and transforming join restrictions after distribution, but Guo found broken serial-number equivalence, duplicate restrictions, and an assertion failure; Rowley suggested limiting scope rather than allowing these complications to block the work #19 #20 #21.
- Guo returned to the earlier restriction-distribution structure and added constant-FALSE replacement that preserved the original restriction metadata and serial number, retaining both base and join support while accepting unsimplified FALSE-and-other-condition expressions #22.
- Andrei Lepikhov rebased the patch and suggested simplifying more deeply nested conditions; Guo’s subsequent revision demonstrated benefits for self-join elimination but deferred deeper expression analysis to keep the initial mechanism straightforward #23 #24.
- Rowley refreshed the patch and requested documentation of serial-number reuse plus clearer, more durable tests; Guo supplied those changes and strengthened the outer-join cases #25 #26.
- Rowley moved the discussion to pgsql-hackers with comment improvements and judged the patch ready, explicitly leaving removal of individual false OR branches for future work #27.
- Andy Fan proposed deriving non-nullability from filters and joins, Guo pointed to existing constraint-exclusion support, and Rowley kept filter-derived knowledge separate because it would not safely justify optimizations before those filters execute #28 #29 #30 #32.
- The final attachment refreshed expected plans for new regression cases and added a dropped-column assertion in NOT NULL attribute collection #33.
- Rowley committed b262ad440e from #33 with light comment and formatting changes, crediting himself, Guo, and Fan as authors and confirming the push in #34.
- Guo acknowledged the landing in the final message, completing the NULL-test optimization while broader costing improvements, deeper OR simplification, and filter-derived non-nullability remained outside the committed work #35 #12 #27 #32.