model-writtenrun 6413 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Tomas Vondra opened the thread after inserting one million rows took about 2.1 seconds with batches of 100 but 41 seconds with batches of 32,767, tracing the slowdown to repeated slot creation and resource-owner bookkeeping and proposing slot reuse in #1.
- Andres Freund proposed copying tuple descriptors to avoid reference-count bookkeeping in #2, while Tom Lane confirmed that both resource addition and removal could degrade in #3; their discussion in #4 and #5 explored broader resource-owner limitations without producing a redesign here.
- Tomas reported that descriptor copying and slot reuse reduced the large-batch case to about 1.37 seconds in #6, then attached those changes alongside a parameter-limit adjustment in #7.
- After the parameter-limit adjustment landed separately, as recorded in #11, Tomas resent the two remaining slot patches with a nested-loop correction in #8; Bharath Rupireddy's crash report in #9 prompted the remaining array-index correction in #10, and Bharath reported faster regression tests in #11.
- Tomas committed the two patches from #10 as b676ac443b, adding explanatory comments, renaming the initialized-slot counter, and changing cleanup to iterate over all initialized slots, then announced the landing in #12.
- Alexander Pyhalov reported that the optimization caused duplicate-key failures and supplied a partitioned-table reproducer with primary keys in #13, exposing a correctness problem that the existing row-count-only tests had missed.
- Tomas explained in #14 that reused slots retained old values because copying occurred only during initialization, and supplied a fix that copies every row plus a smaller regression test checking both uniqueness and inserted values.
- The fix from #14 landed as 99cea49d65, with the existing large-batch INSERT test restored to active execution; Tomas confirmed the push after further testing in #15, leaving both the optimization and its corrective fix committed.