Skip to content

Commit 87ae9e7

Browse files
committed
Remove some unused and seldom used fields from RelationAmInfo.
This saves some memory from each index relcache entry. At least on a 64-bit machine, it saves just enough to shrink a typical relcache entry's memory usage from 2k to 1k. That's nice if you have a lot of backends and a lot of indexes.
1 parent c74d586 commit 87ae9e7

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/backend/access/index/indexam.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ do { \
114114
} \
115115
} while(0)
116116

117+
#define GET_UNCACHED_REL_PROCEDURE(pname) \
118+
do { \
119+
if (!RegProcedureIsValid(indexRelation->rd_am->pname)) \
120+
elog(ERROR, "invalid %s regproc", CppAsString(pname)); \
121+
fmgr_info(indexRelation->rd_am->pname, &procedure); \
122+
} while(0)
123+
117124
#define GET_SCAN_PROCEDURE(pname) \
118125
do { \
119126
procedure = &scan->indexRelation->rd_aminfo->pname; \
@@ -671,14 +678,14 @@ index_bulk_delete(IndexVacuumInfo *info,
671678
void *callback_state)
672679
{
673680
Relation indexRelation = info->index;
674-
FmgrInfo *procedure;
681+
FmgrInfo procedure;
675682
IndexBulkDeleteResult *result;
676683

677684
RELATION_CHECKS;
678-
GET_REL_PROCEDURE(ambulkdelete);
685+
GET_UNCACHED_REL_PROCEDURE(ambulkdelete);
679686

680687
result = (IndexBulkDeleteResult *)
681-
DatumGetPointer(FunctionCall4(procedure,
688+
DatumGetPointer(FunctionCall4(&procedure,
682689
PointerGetDatum(info),
683690
PointerGetDatum(stats),
684691
PointerGetDatum((Pointer) callback),
@@ -698,14 +705,14 @@ index_vacuum_cleanup(IndexVacuumInfo *info,
698705
IndexBulkDeleteResult *stats)
699706
{
700707
Relation indexRelation = info->index;
701-
FmgrInfo *procedure;
708+
FmgrInfo procedure;
702709
IndexBulkDeleteResult *result;
703710

704711
RELATION_CHECKS;
705-
GET_REL_PROCEDURE(amvacuumcleanup);
712+
GET_UNCACHED_REL_PROCEDURE(amvacuumcleanup);
706713

707714
result = (IndexBulkDeleteResult *)
708-
DatumGetPointer(FunctionCall2(procedure,
715+
DatumGetPointer(FunctionCall2(&procedure,
709716
PointerGetDatum(info),
710717
PointerGetDatum(stats)));
711718

src/include/utils/rel.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ typedef LockInfoData *LockInfo;
4747

4848

4949
/*
50-
* Cached lookup information for the index access method functions defined
51-
* by the pg_am row associated with an index relation.
50+
* Cached lookup information for the frequently used index access method
51+
* functions, defined by the pg_am row associated with an index relation.
5252
*/
5353
typedef struct RelationAmInfo
5454
{
@@ -60,13 +60,7 @@ typedef struct RelationAmInfo
6060
FmgrInfo amendscan;
6161
FmgrInfo ammarkpos;
6262
FmgrInfo amrestrpos;
63-
FmgrInfo ambuild;
64-
FmgrInfo ambuildempty;
65-
FmgrInfo ambulkdelete;
66-
FmgrInfo amvacuumcleanup;
6763
FmgrInfo amcanreturn;
68-
FmgrInfo amcostestimate;
69-
FmgrInfo amoptions;
7064
} RelationAmInfo;
7165

7266

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy