From 34235a295b307d3c50b2a74b20936f01b4ba76be Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 14 Mar 2000 23:52:01 +0000 Subject: 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. --- src/backend/access/index/indexam.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/backend/access/index/indexam.c') diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index f4f0d25768..2335693119 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; } -- cgit v1.2.1