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/executor/nodeBitmapHeapscan.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/backend/executor/nodeBitmapHeapscan.c') diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 16d9bf0611c..3c3c1fd96f1 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.2 2005/05/06 17:24:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.3 2005/10/06 02:29:16 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -39,6 +39,7 @@ #include "executor/execdebug.h" #include "executor/nodeBitmapHeapscan.h" #include "parser/parsetree.h" +#include "pgstat.h" #include "utils/memutils.h" @@ -328,6 +329,9 @@ ExecBitmapHeapReScan(BitmapHeapScanState *node, ExprContext *exprCtxt) /* rescan to release any page pin */ heap_rescan(node->ss.ss_currentScanDesc, NULL); + /* undo bogus "seq scan" count (see notes in ExecInitBitmapHeapScan) */ + pgstat_discount_heap_scan(&node->ss.ss_currentScanDesc->rs_pgstat_info); + if (node->tbm) tbm_free(node->tbm); node->tbm = NULL; @@ -475,6 +479,13 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate) 0, NULL); + /* + * One problem is that heap_beginscan counts a "sequential scan" start, + * when we actually aren't doing any such thing. Reverse out the added + * scan count. (Eventually we may want to count bitmap scans separately.) + */ + pgstat_discount_heap_scan(&scanstate->ss.ss_currentScanDesc->rs_pgstat_info); + /* * get the scan type from the relation descriptor. */ -- cgit v1.2.3