Re: Reducing relcache memory usage 2: shrink sizeof(RelationData)

From: David Geier <geidav(dot)pg(at)gmail(dot)com>
To: David Geier <geidav(dot)pg(at)gmail(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reducing relcache memory usage 2: shrink sizeof(RelationData)
Date: 2026-10-05 11:48:10
Message-ID: e8c52d3a-b35b-4351-9896-12310323e465@googlemail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>> - 0005: Replaces the embedded partition key, descriptors, partition
>>> qual, validity flag, and memory contexts with one lazily allocated
>>> RelationPartitionInfo pointer.
>>> => sizeof(RelationData) == 264 bytes

Since patch set v2, this happens in patch 0006. All patches moved by 1
because I added a new patch 0001 (use SLAB context for all RelationData
objects).

>> I haven't worked on partitioning, so I'm not fully confident that this
>> has sufficiently low additional overhead to be worth applying.
>
> I'll run a partitioned pgbench and report if I could measure any
> regressions.

I ran pgbench with 1000 partitions and scale factor 1 to put maximum
pressure on planning which I assumed uses the relcache most:

pgbench -i -s 1 --partitions=1000 postgres
pgbench -c 1 -j 1 -T 60 -S -M simple postgres

I ran against master and my patch, while having turbo boost, frequency
scaling, CPU idle states, ASLR and hyper threading disabled. I used a
single client to further stabilize results. The runs are still a little
bit noisy but FWICS don't show a regression.

TPS master | TPS patched
------------+------------
46,633 | 46,488
45,560 | 46,437
46,445 | 45,866

I've also attached v3 which is v2 rebased on latest master. No other
changes.

--
David Geier

Attachment Content-Type Size
v3-0008-Remove-rd_index.patch text/x-patch 114.2 KB
v3-0007-Remove-rd_fkeyvalid.patch text/x-patch 4.1 KB
v3-0006-Move-out-partition-members.patch text/x-patch 20.6 KB
v3-0005-Remove-rd_lockinfo.patch text/x-patch 20.4 KB
v3-0004-Use-union.patch text/x-patch 26.7 KB
v3-0003-Move-RelationData-to-new-include.patch text/x-patch 22.1 KB
v3-0002-Allocate-RelationData-structs-in-a-dedicated-slab.patch text/x-patch 4.2 KB
v3-0001-Remove-unnecessary-CacheMemoryContext-existence-c.patch text/x-patch 1.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2026-10-05 11:48:16 Re: pg_dump/restore failure (dependency?) on BF serinus
Previous Message Alvaro Herrera 2026-10-05 11:35:00 Re: REPACK (CONCURRENTLY) might keep dropped-column data