1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

Cache fmgr lookup data for index's getnext() function in IndexScanDesc,

so that the fmgr lookup only has to happen once per index scan and not
once per tuple.  Seems to save 5% or so of CPU time for an indexscan.
This commit is contained in:
Tom Lane
2000-03-14 23:52:01 +00:00
parent 6456810078
commit 34235a295b
3 changed files with 21 additions and 6 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.40 2000/01/26 05:55:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.41 2000/03/14 23:52:01 tgl Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
@@ -329,17 +329,28 @@ RetrieveIndexResult
index_getnext(IndexScanDesc scan,
ScanDirection direction)
{
RegProcedure procedure;
RetrieveIndexResult result;
SCAN_CHECKS;
GET_SCAN_PROCEDURE(getnext, amgettuple);
/* ----------------
* Look up the access procedure only once per scan.
* ----------------
*/
if (scan->fn_getnext.fn_oid == InvalidOid)
{
RegProcedure procedure;
GET_SCAN_PROCEDURE(getnext, amgettuple);
fmgr_info(procedure, &scan->fn_getnext);
}
/* ----------------
* have the am's gettuple proc do all the work.
* ----------------
*/
result = (RetrieveIndexResult) fmgr(procedure, scan, direction);
result = (RetrieveIndexResult)
(*fmgr_faddr(&scan->fn_getnext)) (scan, direction);
return result;
}