mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
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.
This commit is contained in:
14
src/backend/utils/cache/relcache.c
vendored
14
src/backend/utils/cache/relcache.c
vendored
@ -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);
|
||||
|
Reference in New Issue
Block a user