model-writtenrun 7680 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Tatsuro Yamada reported that foreign keys on tables with 500 partitions consumed about 710 MB of cached-plan memory per backend, creating a risk of exhausting memory with multiple connections #1.
- Keisuke Kuroda traced the growth to duplicate RI plans and large plans for partitioned referenced tables, then supplied a root-constraint-based sharing patch that reduced cached-plan memory to approximately 1466 kB in his example; reducing the size of each individual plan remained outside that fix #2.
- Kyotaro Horiguchi questioned whether differing physical column numbers permitted sharing, and Alvaro Herrera suggested compatibility checks and moving root traversal into ri_BuildQueryKey(); Kuroda subsequently adopted the traversal simplification #3 #4 #12.
- Corey Huinker proposed bypassing SPI with direct index scans, while Tom Lane noted that statement-level checks could benefit from other query plans; this broader redesign was discussed but not implemented here #6 #7 #8.
- Amit Langote supplied an independently developed patch that cached the root constraint OID, explaining that identical SQL plans could be shared even when per-partition constraint metadata differed #9 #13.
- Horiguchi identified stale cached roots after attaching a former root partition beneath another parent, and Amit merged the two authors' ideas with root-aware invalidation and clearer compatibility comments; Kuroda reported that the merged patch passed check-world #11 #15 #22.
- Horiguchi also explored sharing the constraint metadata itself by splitting RI_ConstraintInfo into separate structures, then revised allocation and ownership handling after Herrera questioned memory lifetime and documentation #16 #20 #23.
- The main plan-sharing patch was simplified to use the constraint's own OID as its root for non-inherited constraints, following Horiguchi's suggestion #24 #25.
- Amit found a DETACH PARTITION regression in the metadata-sharing experiment; Herrera urged prioritizing the smaller plan-sharing fix, and Amit agreed, later posting an inline workaround for the experiment's stale shared query key #26 #27 #28 #31.
- After Kuroda reconfirmed check-world success in January, Amit registered the plan-sharing patch for the March commitfest and subsequently marked it ready for a committer #32 #33 #36.
- Tom Lane challenged whether shared plans could reference the correct partitions, prompting Amit to identify the ri_Check_Pk_Match() exception, retain separate plans for that query type, and add a regression test demonstrating the earlier failure #38 #39.
- Andy Fan proposed broader restrictions on partition layouts to reduce complexity and memory usage, and Amit directed that work into a separate discussion #40 #41 #42 #43.
- Lane's further review prompted Amit to remove the redundant parent-ID field and clarify the distinction between shared SPI plans and separate constraint metadata #45 #46.
- Lane committed #46 as c3ffe34863, retaining its tests and sharing rules while revising comments and converting root traversal from recursion to iteration, and announced the push in #47.
- Lane initially suspected the committed patch after a CLOBBER_CACHE_ALWAYS buildfarm crash, but reproduced the failure and determined that another change was responsible; Yamada subsequently reported successful installcheck-parallel testing, leaving the plan-sharing fix landed and the broader metadata-sharing experiment deferred #51 #52 #53.