Trim TIDs during parallel GIN builds more eagerly
authorTomas Vondra <[email protected]>
Tue, 4 Nov 2025 18:30:17 +0000 (19:30 +0100)
committerTomas Vondra <[email protected]>
Tue, 4 Nov 2025 19:06:01 +0000 (20:06 +0100)
commit1213cb475391640508d2495b2b560329897d152c
tree701ac891cd93a8db7eb937f8de4d1ac52f2ddba3
parent6d2ff1de4d0b66eb0288e21021c3741b9df1df0d
Trim TIDs during parallel GIN builds more eagerly

The parallel GIN builds perform "freezing" of TID lists when merging
chunks built earlier. This means determining what part of the list can
no longer change, depending on the last received chunk. The frozen part
can be evicted from memory and written out.

The code attempted to freeze items right before merging the old and new
TID list, after already attempting to trim the current buffer. That
means part of the data may get frozen based on the new TID list, but
will be trimmed later (on next loop). This increases memory usage.

This inverts the order, so that we freeze data first (before trimming).
The benefits are likely relatively small, but it's also virtually free
with no other downsides.

Discussion: https://postgr.es/m/CAHLJuCWDwn-PE2BMZE4Kux7x5wWt_6RoWtA0mUQffEDLeZ6sfA@mail.gmail.com
src/backend/access/gin/gininsert.c