diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-27 23:31:21 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-27 23:31:21 +0000 |
| commit | 32e8fc4a28dd718aef16b9f617602c88b1f5f7e1 (patch) | |
| tree | 7132d4430bebde31955c392787c1a7b829b0d023 /src/include/utils/rel.h | |
| parent | dd67cf365a76ee875d7bc3aa3788a243fce4776f (diff) | |
| download | postgresql-32e8fc4a28dd718aef16b9f617602c88b1f5f7e1.tar.gz | |
Arrange to cache fmgr lookup information for an index's access method
routines in the index's relcache entry, instead of doing a fresh fmgr_info
on every index access. We were already doing this for the index's opclass
support functions; not sure why we didn't think to do it for the AM
functions too. This supersedes the former method of caching (only)
amgettuple in indexscan scan descriptors; it's an improvement because the
function lookup can be amortized across multiple statements instead of
being repeated for each statement. Even though lookup for builtin
functions is pretty cheap, this seems to drop a percent or two off some
simple benchmarks.
Diffstat (limited to 'src/include/utils/rel.h')
| -rw-r--r-- | src/include/utils/rel.h | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index b6a1712efa..e3f636b83d 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.83 2005/03/29 00:17:18 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.84 2005/05/27 23:31:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,6 +18,7 @@ #include "catalog/pg_am.h" #include "catalog/pg_class.h" #include "catalog/pg_index.h" +#include "fmgr.h" #include "rewrite/prs2lock.h" #include "storage/block.h" #include "storage/relfilenode.h" @@ -100,6 +101,27 @@ typedef struct PgStat_Info /* + * Cached lookup information for the index access method functions defined + * by the pg_am row associated with an index relation. + */ +typedef struct RelationAmInfo +{ + FmgrInfo aminsert; + FmgrInfo ambeginscan; + FmgrInfo amgettuple; + FmgrInfo amgetmulti; + FmgrInfo amrescan; + FmgrInfo amendscan; + FmgrInfo ammarkpos; + FmgrInfo amrestrpos; + FmgrInfo ambuild; + FmgrInfo ambulkdelete; + FmgrInfo amvacuumcleanup; + FmgrInfo amcostestimate; +} RelationAmInfo; + + +/* * Here are the contents of a relation cache entry. */ @@ -150,11 +172,10 @@ typedef struct RelationData * that restriction. */ MemoryContext rd_indexcxt; /* private memory cxt for this stuff */ + RelationAmInfo *rd_aminfo; /* lookup info for funcs found in pg_am */ Oid *rd_operator; /* OIDs of index operators */ RegProcedure *rd_support; /* OIDs of support procedures */ - struct FmgrInfo *rd_supportinfo; /* lookup info for support - * procedures */ - /* "struct FmgrInfo" avoids need to include fmgr.h here */ + FmgrInfo *rd_supportinfo; /* lookup info for support procedures */ List *rd_indexprs; /* index expression trees, if any */ List *rd_indpred; /* index predicate tree, if any */ |
