On Fri, Aug 8, 2025 at 4:03 PM Andres Freund <andres@anarazel.de> wrote:
I'm not convinced that the global counter, be it a 32 or a 64 bit, approach has merit in general, and I'm rather sure it's the wrong thing for toast values. There's no straightforward path to move away from the global counter for plain oids, but I would suggest simply not using the global oid counter for toast IDs.
A large portion of the cases I've seen where toast ID assignments were a problem were when the global OID counter wrapped around due to activity on *other* tables (and/or temporary table creation). If you instead had a per-toast-table sequence for assigning chunk IDs, that problem would largely vanish.
That's been my experience as well. I was actually toying with the idea of simply switching from OIDs to per-table counters when I came across this, specifically to address the problem of OID wraparound induced performance problems.