mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	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
This commit is contained in:
		@@ -18,6 +18,7 @@
 | 
				
			|||||||
#include "access/relscan.h"
 | 
					#include "access/relscan.h"
 | 
				
			||||||
#include "access/spgist_private.h"
 | 
					#include "access/spgist_private.h"
 | 
				
			||||||
#include "miscadmin.h"
 | 
					#include "miscadmin.h"
 | 
				
			||||||
 | 
					#include "pgstat.h"
 | 
				
			||||||
#include "storage/bufmgr.h"
 | 
					#include "storage/bufmgr.h"
 | 
				
			||||||
#include "utils/datum.h"
 | 
					#include "utils/datum.h"
 | 
				
			||||||
#include "utils/memutils.h"
 | 
					#include "utils/memutils.h"
 | 
				
			||||||
@@ -231,6 +232,9 @@ spgrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* set up starting stack entries */
 | 
						/* set up starting stack entries */
 | 
				
			||||||
	resetSpGistScanOpaque(so);
 | 
						resetSpGistScanOpaque(so);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* count an indexscan for stats */
 | 
				
			||||||
 | 
						pgstat_count_index_scan(scan->indexRelation);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user