model-writtenrun 8676 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Pavel Stehule opened the thread with profiling showing substantial plan-cache overhead in a simple PL/pgSQL arithmetic loop, which ran slower than PostgreSQL 8.2 on his machine #1.
- Amit Langote proposed bypassing the planner for simple expressions, reporting a substantial speedup but also a serious slowdown when an expression contained an inlineable SQL function #3.
- Pavel proposed excluding SQL functions from the bypass, and Amit implemented an inlineability check that retained normal planning for those expressions before polishing the patch #4 #5 #6.
- Pavel confirmed the speedup but found a regression-output mismatch; Amit corrected the expected error context and added arithmetic and SQL-function regression cases, after which Pavel reported successful testing #7 #8 #9 #10 #11.
- Pavel subsequently reported apparent memory-context corruption with plpgsql_check, but after a gap and renewed investigation he could no longer reproduce it and withdrew that concern #13 #14 #19 #21.
- More realistic arithmetic testing exposed a different problem: skipping planning prevented constant casts from being folded, making common numeric-constant expressions substantially slower #22.
- Tom Lane rejected the bypass design because it also missed search-path invalidation, domain-related dependencies, and required planner transformations; his replacement retained planning while adding fast validity checks, transaction-lifetime plan references, search-path generation tracking, and invalidation tests #23.
- Pavel tested Tom's replacement with both PostgreSQL and plpgsql_check regressions and confirmed a stable improvement of about 30 percent on the pi-estimation example #24 #25.
- Andres Freund reviewed the replacement's resource-owner lifetimes and suggested broader lock-check and search-path optimizations; Tom kept those broader changes outside this patch while investigating the DO-block cleanup questions #28 #30 #31 #32.
- Amit questioned the separation between initial eligibility checks and subsequent validity checks, and Tom initially defended separate functions as cheaper for repeated evaluation and more flexible for future callers #34 #36.
- Tom revised resource cleanup to use ResourceOwnerReleaseAllPlanCacheRefs(), made the shared owner a child of the transaction owner while keeping DO-block owners independent, and documented their lifetimes; testing also exposed missing parallel-worker transaction callbacks #35 #37.
- Andres reviewed the revised patch and its parallel-worker implications, while Tom accepted additional comment references and concluded that the pre-existing cleanup omission deserved backpatching even without demonstrated core user-visible damage #38 #39 #40.
- Tom first extracted the parallel-worker callback fix and DO-block commentary from the final series into 86e5badd22, preserving the performance work for a separate commit #37.
- The remaining final-series changes landed as 8f59f6b9c0, combining fast validation, transaction-level references, search-path optimization, and regression tests with only comment edits beyond the posted implementation #37.
- Buildfarm failures then showed that cache invalidation during planning could leave a valid derived plan attached to an invalid plansource; in the thread's last message Tom explained that initial acceptance must allow this case and defer replanning until the next use #41.
- At the last message the main work had landed and Tom was preparing that follow-up; it subsequently landed as fbc7a71608, separating initial acceptance from later validity checking without an attached patch revision #41.