Re: Reducing relcache memory usage: deduping index shapes

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Yilin Zhang <jiezhilove(at)126(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, David Geier <geidav(dot)pg(at)gmail(dot)com>
Subject: Re: Reducing relcache memory usage: deduping index shapes
Date: 2026-10-12 18:21:55
Message-ID: CAEze2Wh7X6dM2omJxzBuDC1tkG6yYtDs2m=603wV_=-_94-qcw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 12 Oct 2026 at 13:35, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Wed, 7 Oct 2026 at 11:01, Matthias van de Meent
> <boekewurm+postgres(at)gmail(dot)com> wrote:
> > 0004/0005:
> > * Unchanged
>
> I had a conversation with Andres about the Proxy context. He mentioned
> that he gave it that name when he was experimenting with making it
> work by putting the allocation in another memory context. I mentioned
> using the "Direct" name, and he suggested "System", which I agreed was
> a good name. We then agreed that we shouldn't call the .c file
> system.c. systemcxt.c is likely ok.
Thanks for the review.

I've renamed the context type and file names accordingly.

> Another review of 0004:
>
> 1. You could probably get rid of the allocSize variable in ProxyContextCreate()

Done.

> 2. struct ProxyBlock could use a few comments.

Done.

> 3. README:
[...]
> It might be worth mentioning how it works here as that'll help explain
> to the reader why it's best suited for those cases. Maybe something
> like:
[...]
> Because we're getting so many context types now, I feel it's more
> important than ever to have a central place that gives enough
> information about each to allow someone to select the one that suits
> their needs best.

Adjusted, WDYT?

> 4. The following existing text claims there are "three" other
> allocators, but the patch makes that false since it introduces another
> one:

Adjusted; "three" has been replaced with "several other"

> 5. In ProxyRealloc(), can you clarify the following comment to mention
> "When the size is being increased, randomize the new portion".

Adjusted.

> 6. ProxyReset(). The following Assert() should be using
> PROXY_CONTEXTSIZE as that's what ProxyContextCreate() set it to. It
> just so happens to work because the size of the struct is already a
> multiple of 8 bytes. Perhaps there are some systems where it won't
> work.

Done.

-----

Attached is v4, which has the following changes:

0001-0002: Unmodified

0003:
* Renamed "Proxy" memory context type to System,
* various other changes to align with David's review
0004/0005: Adjust for Proxy -> System /SystemCxt rename

Kind regards,

Matthias van de Meent
Databricks (https://www.databricks.com)

Attachment Content-Type Size
v4-0004-Relcache-Use-System-contexts-for-index-info-and-i.patch application/octet-stream 2.5 KB
v4-0001-relcache-refactor-RelationInitIndexAccessInfo.patch application/octet-stream 5.6 KB
v4-0005-Relcache-Reduce-number-of-allocations-into-shape-.patch application/octet-stream 2.6 KB
v4-0003-MemCTX-Add-minimal-system-context-type.patch application/octet-stream 22.4 KB
v4-0002-Deduplicate-some-index-attributes-in-the-relcache.patch application/octet-stream 42.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Haibo Yan 2026-10-12 18:28:16 Re: [PATCH] Fix grouping-set nulling of variable-free grouping expressions
Previous Message surya poondla 2026-10-12 18:07:01 Re: Wrong LSN in WAL decoding error messages