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/backend/utils/cache/relcache.c | |
parent | dd67cf365a76ee875d7bc3aa3788a243fce4776f (diff) | |
download | postgresql-32e8fc4a28dd718aef16b9f617602c88b1f5f7e1.tar.gz postgresql-32e8fc4a28dd718aef16b9f617602c88b1f5f7e1.zip |
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/backend/utils/cache/relcache.c')
-rw-r--r-- | src/backend/utils/cache/relcache.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index c4dc65f784a..3123eca518e 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.223 2005/05/11 01:26:02 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.224 2005/05/27 23:31:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -904,6 +904,9 @@ RelationInitIndexAccessInfo(Relation relation) /* * Allocate arrays to hold data */ + relation->rd_aminfo = (RelationAmInfo *) + MemoryContextAllocZero(indexcxt, sizeof(RelationAmInfo)); + if (amstrategies > 0) operator = (Oid *) MemoryContextAllocZero(indexcxt, @@ -931,8 +934,8 @@ RelationInitIndexAccessInfo(Relation relation) relation->rd_supportinfo = supportinfo; /* - * Fill the operator and support procedure OID arrays. (supportinfo is - * left as zeroes, and is filled on-the-fly when used) + * Fill the operator and support procedure OID arrays. (aminfo and + * supportinfo are left as zeroes, and are filled on-the-fly when used) */ IndexSupportInitialize(relation->rd_indclass, operator, support, @@ -3015,7 +3018,9 @@ load_relcache_init_file(void) rel->rd_support = support; - /* add a zeroed support-fmgr-info vector */ + /* set up zeroed fmgr-info vectors */ + rel->rd_aminfo = (RelationAmInfo *) + MemoryContextAllocZero(indexcxt, sizeof(RelationAmInfo)); nsupport = relform->relnatts * am->amsupport; rel->rd_supportinfo = (FmgrInfo *) MemoryContextAllocZero(indexcxt, nsupport * sizeof(FmgrInfo)); @@ -3031,6 +3036,7 @@ load_relcache_init_file(void) Assert(rel->rd_indclass == NULL); Assert(rel->rd_am == NULL); Assert(rel->rd_indexcxt == NULL); + Assert(rel->rd_aminfo == NULL); Assert(rel->rd_operator == NULL); Assert(rel->rd_support == NULL); Assert(rel->rd_supportinfo == NULL); |