From 21233f255ce6290c52f6c05bb2b7d8d49b560ddc Mon Sep 17 00:00:00 2001 From: Matthias van de Meent Date: Mon, 31 Aug 2026 22:22:45 +0200 Subject: [PATCH v3 5/6] Relcache: Use Proxy contexts for "index info" and "index shape" This avoids block-level overheads and enables the use of the system allocator, which frequently has slightly better memory performance/ efficiency for longer-lived allocations. --- src/backend/utils/cache/relcache.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 99c8aec14d1..d1a0cb3b011 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -1528,9 +1528,8 @@ RelationInitIndexAccessInfo(Relation relation) * a context, and not just a couple of pallocs, is so that we won't leak * any subsidiary info attached to fmgr lookup records. */ - indexcxt = AllocSetContextCreate(CacheMemoryContext, - "index info", - ALLOCSET_SMALL_SIZES); + indexcxt = ProxyContextCreate(CacheMemoryContext, "index info"); + relation->rd_indexcxt = indexcxt; MemoryContextCopyAndSetIdentifier(indexcxt, RelationGetRelationName(relation)); @@ -1700,8 +1699,7 @@ IndexSupportInitialize(oidvector *indclass, AttrNumber nKeyAtts, FmgrInfo *supportinfo; MemoryContext shapectx; - shapectx = AllocSetContextCreate(RelShapeContext, "index shape", - ALLOCSET_SMALL_SIZES); + shapectx = ProxyContextCreate(RelShapeContext, "index shape"); if (maxSupportNumber > 0) { @@ -7000,8 +6998,7 @@ load_relcache_init_index(Relation rel, FILE *fp) * prepare index info context --- parameters should match * RelationInitIndexAccessInfo */ - indexcxt = AllocSetContextCreate(CacheMemoryContext, "index info", - ALLOCSET_SMALL_SIZES); + indexcxt = ProxyContextCreate(CacheMemoryContext, "index info"); rel->rd_indexcxt = indexcxt; MemoryContextCopyAndSetIdentifier(indexcxt, RelationGetRelationName(rel)); @@ -7090,8 +7087,7 @@ load_relcache_init_index(Relation rel, FILE *fp) entry->rsc_refcount = 1; - idxshapectx = AllocSetContextCreate(RelShapeContext, "index shape", - ALLOCSET_SMALL_SIZES); + idxshapectx = ProxyContextCreate(RelShapeContext, "index shape"); total_alloc = sizeof(FmgrInfo) * key.nsupport * key.nkeyatts; total_alloc += sizeof(Oid) * 2 * key.nkeyatts; -- 2.54.0 (Apple Git-157)