aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-08-27 19:42:42 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-08-27 19:42:42 -0400
commit7c1b0f4c35354edf5460cf6e87c63a4a65be1e00 (patch)
tree961e799e2671dcc13b83a7a0346ae786a5be1ee7
parent05fec0b74facdc7a0f96fd1bc18e5d402f497f7c (diff)
downloadpostgresql-7c1b0f4c35354edf5460cf6e87c63a4a65be1e00.tar.gz
postgresql-7c1b0f4c35354edf5460cf6e87c63a4a65be1e00.zip
Count SP-GiST index scans in pg_stat statistics.
Somehow, spgist overlooked the need to call pgstat_count_index_scan(). Hence, pg_stat_all_indexes.idx_scan and equivalent columns never became nonzero for an SP-GiST index, although the related per-tuple counters worked fine. This fix works a bit differently from other index AMs, in that the counter increment occurs in spgrescan not spggettuple/spggetbitmap. It looks like this won't make the user-visible semantics noticeably different, so I won't go to the trouble of introducing an is-this- the-first-call flag just to make the counter bumps happen in the same places. Per bug #17163 from Christian Quest. Back-patch to all supported versions. Discussion: https://postgr.es/m/17163-b8c5cc88322a5e92@postgresql.org
-rw-r--r--src/backend/access/spgist/spgscan.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/access/spgist/spgscan.c b/src/backend/access/spgist/spgscan.c
index aede1a76cbf..bf07641da2f 100644
--- a/src/backend/access/spgist/spgscan.c
+++ b/src/backend/access/spgist/spgscan.c
@@ -18,6 +18,7 @@
#include "access/relscan.h"
#include "access/spgist_private.h"
#include "miscadmin.h"
+#include "pgstat.h"
#include "storage/bufmgr.h"
#include "utils/datum.h"
#include "utils/memutils.h"
@@ -231,6 +232,9 @@ spgrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
/* set up starting stack entries */
resetSpGistScanOpaque(so);
+
+ /* count an indexscan for stats */
+ pgstat_count_index_scan(scan->indexRelation);
}
void