From 130a248134c03161f62e4a2219f704fd961b4411 Mon Sep 17 00:00:00 2001 From: Matthias van de Meent Date: Mon, 31 Aug 2026 22:22:45 +0200 Subject: [PATCH v2 5/5] 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 a83cb75c58a..6c84b8bbf45 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -1525,9 +1525,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"); allocsize = sizeof(Oid) * 2 * key.nkeyatts; allocsize += sizeof(RegProcedure) * key.nsupport * key.nkeyatts; @@ -6969,8 +6967,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)); @@ -7059,8 +7056,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.50.1 (Apple Git-155)