model-writtenrun 8105 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Konstantin Knizhnik reported severe backend memory growth with row-level security and frequent temporary-table creation, and proposed building policy expression trees directly in their destination memory context because pfree freed only their root nodes #1.
- Tom Lane initially suggested deferring policy-cache population until needed #2, while Konstantin clarified that the trace came from an older PostgreSQL version but the expression-tree leak remained #3.
- After inspecting the code, Tom withdrew the deferred-loading proposal because this path did not risk the recursion seen with partition expressions, and supplied a rewrite that also freed expression strings and replaced PG_TRY with memory-context reparenting #4.
- Konstantin confirmed that Tom's rewrite fixed the problem #5, and Tom acknowledged the testing and announced his intention to commit it #6.
- Tom's patch #4 landed unchanged as e55f718fc4 and was backpatched to all supported branches.
- The thread ended with Konstantin reporting that the customer's memory consumption had fallen threefold after applying the patch, significantly improving performance #7.