diff options
Diffstat (limited to 'src/include/access')
-rw-r--r-- | src/include/access/genam.h | 34 | ||||
-rw-r--r-- | src/include/access/relscan.h | 11 |
2 files changed, 42 insertions, 3 deletions
diff --git a/src/include/access/genam.h b/src/include/access/genam.h index 1be8739573f..5b2ab181b5f 100644 --- a/src/include/access/genam.h +++ b/src/include/access/genam.h @@ -27,6 +27,27 @@ struct IndexInfo; /* + * Struct for statistics maintained by amgettuple and amgetbitmap + * + * Note: IndexScanInstrumentation can't contain any pointers, since it is + * copied into a SharedIndexScanInstrumentation during parallel scans + */ +typedef struct IndexScanInstrumentation +{ + /* Index search count (incremented with pgstat_count_index_scan call) */ + uint64 nsearches; +} IndexScanInstrumentation; + +/* + * Struct for every worker's IndexScanInstrumentation, stored in shared memory + */ +typedef struct SharedIndexScanInstrumentation +{ + int num_workers; + IndexScanInstrumentation winstrument[FLEXIBLE_ARRAY_MEMBER]; +} SharedIndexScanInstrumentation; + +/* * Struct for statistics returned by ambuild */ typedef struct IndexBuildResult @@ -157,9 +178,11 @@ extern void index_insert_cleanup(Relation indexRelation, extern IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, + IndexScanInstrumentation *instrument, int nkeys, int norderbys); extern IndexScanDesc index_beginscan_bitmap(Relation indexRelation, Snapshot snapshot, + IndexScanInstrumentation *instrument, int nkeys); extern void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, @@ -168,13 +191,20 @@ extern void index_endscan(IndexScanDesc scan); extern void index_markpos(IndexScanDesc scan); extern void index_restrpos(IndexScanDesc scan); extern Size index_parallelscan_estimate(Relation indexRelation, - int nkeys, int norderbys, Snapshot snapshot); + int nkeys, int norderbys, Snapshot snapshot, + bool instrument, bool parallel_aware, + int nworkers); extern void index_parallelscan_initialize(Relation heapRelation, Relation indexRelation, Snapshot snapshot, + bool instrument, bool parallel_aware, + int nworkers, + SharedIndexScanInstrumentation **sharedinfo, ParallelIndexScanDesc target); extern void index_parallelrescan(IndexScanDesc scan); extern IndexScanDesc index_beginscan_parallel(Relation heaprel, - Relation indexrel, int nkeys, int norderbys, + Relation indexrel, + IndexScanInstrumentation *instrument, + int nkeys, int norderbys, ParallelIndexScanDesc pscan); extern ItemPointer index_getnext_tid(IndexScanDesc scan, ScanDirection direction); diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h index dc6e0184284..b5e0fb386c0 100644 --- a/src/include/access/relscan.h +++ b/src/include/access/relscan.h @@ -123,6 +123,8 @@ typedef struct IndexFetchTableData Relation rel; } IndexFetchTableData; +struct IndexScanInstrumentation; + /* * We use the same IndexScanDescData structure for both amgettuple-based * and amgetbitmap-based index scans. Some fields are only relevant in @@ -151,6 +153,12 @@ typedef struct IndexScanDescData void *opaque; /* access-method-specific info */ /* + * Instrumentation counters maintained by all index AMs during both + * amgettuple calls and amgetbitmap calls (unless field remains NULL) + */ + struct IndexScanInstrumentation *instrument; + + /* * In an index-only scan, a successful amgettuple call must fill either * xs_itup (and xs_itupdesc) or xs_hitup (and xs_hitupdesc) to provide the * data returned by the scan. It can fill both, in which case the heap @@ -188,7 +196,8 @@ typedef struct ParallelIndexScanDescData { RelFileLocator ps_locator; /* physical table relation to scan */ RelFileLocator ps_indexlocator; /* physical index relation to scan */ - Size ps_offset; /* Offset in bytes of am specific structure */ + Size ps_offset_ins; /* Offset to SharedIndexScanInstrumentation */ + Size ps_offset_am; /* Offset to am-specific structure */ char ps_snapshot_data[FLEXIBLE_ARRAY_MEMBER]; } ParallelIndexScanDescData; |