aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/index/indexam.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-03-14 23:52:01 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-03-14 23:52:01 +0000
commit34235a295b307d3c50b2a74b20936f01b4ba76be (patch)
tree4accf8dd3e60c2cde3d3da5948e583c6d5cf921c /src/backend/access/index/indexam.c
parent64568100787a5d03d036e70b32147385a35245e2 (diff)
downloadpostgresql-34235a295b307d3c50b2a74b20936f01b4ba76be.tar.gz
postgresql-34235a295b307d3c50b2a74b20936f01b4ba76be.zip
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.
Diffstat (limited to 'src/backend/access/index/indexam.c')
-rw-r--r--src/backend/access/index/indexam.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index f4f0d25768b..23356931198 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -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;
}