model-writtenrun 8985 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Konstantin Knizhnik opened the thread with benchmarks suggesting substantial SPI overhead in procedural functions; Kyotaro Horiguchi questioned cursor usage, and batching cursor fetches substantially improved the C/SPI result #1 #3 #5.
- Konstantin then identified repeated snapshots during simple-expression evaluation as another cost, while Pavel Stehule suggested optimizing expressions using built-in functions; Konstantin posted the first snapshot-skipping patch #6 #7 #8.
- Pavel warned that applications sometimes deliberately mislabel database-reading functions as immutable, prompting Konstantin to add pg_catalog restrictions and operator handling in the next patch #9 #11 #12.
- David Fetter argued that user-supplied immutability declarations should be trusted, while Robert Haas distinguished tolerable incorrect results from unacceptable server crashes caused by mislabeling #13 #15.
- September profiling exposed additional interpreter, tuple-processing and plan-cache costs, but the work remained focused on snapshot overhead; in November Pavel reported approximately 25 percent improvement on a simple loop, passing tests, and supplied warning fixes and formatting cleanup #18 #19 #20.
- Kyotaro questioned the walker's incomplete node coverage, and Tom Lane identified missed function-bearing node types and weaknesses in pg_catalog checks; Tom recommended the existing contain_mutable_functions() helper to avoid maintaining another expression walker #21 #25.
- Konstantin accepted that approach and submitted a much smaller patch using contain_mutable_functions(), dropping both the custom walker and the restriction to catalog functions #26 #29.
- Pavel questioned whether stable functions also needed fresh snapshots, and Tom explained that they must see updates already made by a volatile caller, preserving the final patch's immutable-only optimization #30 #31.
- Pavel's further experiments raised existing visibility problems with mislabeled functions and prompted proposals for WRITE, READ and PURE flags; Konstantin and Kyotaro argued against expanding the classification scheme and emphasized the function author's responsibility #34 #35 #38.
- Tom committed #29 with light naming, comment and organization changes as 73b06cf893, whose message reports roughly 45 percent improvement on a simple loop; his closing message confirms the push and rejects costly additional enforcement, leaving broader classification and performance proposals outside the landed change #39.