pgsql: Save a few bytes per CatCTup.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Save a few bytes per CatCTup.
Date: 2026-03-15 22:05:46
Message-ID: E1w1taj-000L9n-1b@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Save a few bytes per CatCTup.

CatalogCacheCreateEntry() computed the space needed for a CatCTup
as sizeof(CatCTup) + MAXIMUM_ALIGNOF. That's not our usual style,
and it wastes memory by allocating more padding than necessary.
On 64-bit machines sizeof(CatCTup) would be maxaligned already
since it contains pointer fields, therefore this code is wasting
8 bytes compared to the more usual MAXALIGN(sizeof(CatCTup)).

While at it, we don't really need to do MemoryContextSwitchTo()
when we're only allocating one block.

Author: ChangAo Chen <cca5507(at)qq(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/tencent_A42E0544C6184FE940CD8E3B14A3F0A39605@qq.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e5a77d876dbb6168e3013d32198794c535f1627d

Modified Files
--------------
src/backend/utils/cache/catcache.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2026-03-15 22:50:34 pgsql: Add all required calls to TupleDescFinalize()
Previous Message Peter Eisentraut 2026-03-15 20:52:09 Re: pgsql: Make typeof and typeof_unqual fallback definitions work on C++11