From cb8b6618cefa1f87197390ae12709b46f5137a35 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 6 Oct 2005 02:29:23 +0000 Subject: Revise pgstats stuff to fix the problems with not counting accesses generated by bitmap index scans. Along the way, simplify and speed up the code for counting sequential and index scans; it was both confusing and inefficient to be taking care of that in the per-tuple loops, IMHO. initdb forced because of internal changes in pg_stat view definitions. --- src/backend/access/index/indexam.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 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 624b53d635..7bf7fcd22f 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.84 2005/06/27 12:45:22 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.85 2005/10/06 02:29:11 tgl Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relation OID @@ -65,9 +65,9 @@ #include "access/genam.h" #include "access/heapam.h" +#include "pgstat.h" #include "utils/relcache.h" -#include "pgstat.h" /* ---------------------------------------------------------------- * macros used in index_ routines @@ -354,8 +354,6 @@ index_rescan(IndexScanDesc scan, ScanKey key) FunctionCall2(procedure, PointerGetDatum(scan), PointerGetDatum(key)); - - pgstat_reset_index_scan(&scan->xs_pgstat_info); } /* ---------------- @@ -521,8 +519,6 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) { bool found; - pgstat_count_index_scan(&scan->xs_pgstat_info); - /* * The AM's gettuple proc finds the next tuple matching the scan * keys. @@ -545,6 +541,8 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) return NULL; /* failure exit */ } + pgstat_count_index_tuples(&scan->xs_pgstat_info, 1); + /* * Fetch the heap tuple and see if it matches the snapshot. */ @@ -583,8 +581,6 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) * initialized to 0, which is the correct state ("on row"). */ - pgstat_count_index_getnext(&scan->xs_pgstat_info); - return heapTuple; } @@ -621,6 +617,9 @@ index_getnext_indexitem(IndexScanDesc scan, PointerGetDatum(scan), Int32GetDatum(direction))); + if (found) + pgstat_count_index_tuples(&scan->xs_pgstat_info, 1); + return found; } @@ -660,6 +659,8 @@ index_getmulti(IndexScanDesc scan, Int32GetDatum(max_tids), PointerGetDatum(returned_tids))); + pgstat_count_index_tuples(&scan->xs_pgstat_info, *returned_tids); + return found; } -- cgit v1.2.1