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

From: David Geier <geidav(dot)pg(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: Haibo Yan <tristan(dot)yim(at)gmail(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, peter(at)eisentraut(dot)org
Subject: Re: Reducing relcache memory usage 2: shrink sizeof(RelationData)
Date: 2026-11-24 16:30:14
Message-ID: 629effbf-28a6-415c-98b7-10a40232a424@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/18/26 13:42, David Geier wrote:
>>> Move the definition of RelationData into utils/rel_internal.h. Otherwise,
>>> gen_node_support.pl cannot process rel.h after the anonymous unions are
>>> introduced by the following commit, because the script does not support
>>> parsing anonymous unions.
>>
>> I really dislike this. Why not do it the other way around, and put the
>> one struct that gen_node_support.pl wants in a separate file instead?
>> As in the attached WIP. New file name TBD, of course.
> That's indeed nicer.
>
> I had moved struct RelationData to rel_internal.h as a quick workaround
> when I started to be able to make progress without bothering. Now it's
> time to fix this properly.
>
> We can do what you suggest, or alternatively, teach gen_node_support.pl
> to skip anonymous structs/unions in non-node structs. Then we can keep
> all code as before in rel.h. See attached patch.
>
> Once we settle on how to go forward, I'll update the main patch set.
Since there were no objections, I went ahead and changed
gen_node_support.pl to skip anonymous unions inside structs, see patch
0003. This way there's no longer the need to move struct RelationData to
a new header.

Attached is the new patch set, also rebased on master.

--
David Geier

Attachment Content-Type Size
v7-0001-Assert-CacheMemoryContext-exists-in-relcache-call.patch text/x-patch 1.7 KB
v7-0002-Allocate-RelationData-structs-in-a-dedicated-slab.patch text/x-patch 4.1 KB
v7-0003-gen_node_support.pl-skips-anonymous-structs-union.patch text/x-patch 2.4 KB
v7-0004-Overlay-relation-kind-specific-relcache-fields.patch text/x-patch 39.5 KB
v7-0005-Allocate-partition-cache-data-lazily.patch text/x-patch 20.5 KB
v7-0006-Pack-RelationData-to-eliminate-padding.patch text/x-patch 5.1 KB
v7-0007-Compute-relation-lock-identifiers-on-demand.patch text/x-patch 20.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-11-24 17:36:01 Prevent stack overflow in exprLocation while parsing long queries
Previous Message Tom Lane 2026-11-24 16:12:48 Re: [PATCH] Fix encoding-dependent LIKE/regex selectivity estimates