On Thu, Mar 28, 2024 at 10:59 AM Tom Lane <t...@sss.pgh.pa.us> wrote: > Yeah. The whole ResourceOwner mechanism is not exactly lightweight, > but it's hard to argue that we don't need it. I wonder whether we > could get anywhere by deeming that a "small enough" subtransaction > doesn't need to have its resources cleaned up instantly, and > instead re-use its ResourceOwner to accumulate resources of the > next subtransaction, and the next, until there's enough to be > worth cleaning up.
Hmm, I wonder if that's actually where the cycles are going. There's an awful lot of separate function calls inside CommitSubTransaction(), and in the common case, each one of them has to individually decide that it doesn't need to do anything. Sure, they're all fast, but if you have enough of them, it's still going to add up, at least a bit. In that sense, the resource owner mechanism seems like it should, or at least could, be better. I'm not sure this is quite the way it works now, but if you had one single list/array/thingamabob that listed all of the resources that needed releasing, that should in theory be better when there's a lot of kinds of resources that you COULD hold but only a small number of kinds of resources that you actually do hold -- and it also shouldn't be any worse if it turns out that you hold a whole lot of resources of many different types. But I haven't done any benchmarking of this area in a long time. -- Robert Haas EDB: http://www.enterprisedb.com