mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
pgstat: introduce pgstat_relation_should_count().
A later commit will make the check more complicated than the current (rel)->pgstat_info != NULL. It also just seems nicer to have a central copy of the logic, even while still simple. Author: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20220303021600.hs34ghqcw6zcokdh@alap3.anarazel.de
This commit is contained in:
@ -1104,41 +1104,44 @@ extern PgStat_BackendFunctionEntry *find_funcstat_entry(Oid func_id);
|
||||
|
||||
extern void pgstat_initstats(Relation rel);
|
||||
|
||||
#define pgstat_relation_should_count(rel) \
|
||||
(likely((rel)->pgstat_info != NULL))
|
||||
|
||||
/* nontransactional event counts are simple enough to inline */
|
||||
|
||||
#define pgstat_count_heap_scan(rel) \
|
||||
do { \
|
||||
if ((rel)->pgstat_info != NULL) \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_numscans++; \
|
||||
} while (0)
|
||||
#define pgstat_count_heap_getnext(rel) \
|
||||
do { \
|
||||
if ((rel)->pgstat_info != NULL) \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_tuples_returned++; \
|
||||
} while (0)
|
||||
#define pgstat_count_heap_fetch(rel) \
|
||||
do { \
|
||||
if ((rel)->pgstat_info != NULL) \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_tuples_fetched++; \
|
||||
} while (0)
|
||||
#define pgstat_count_index_scan(rel) \
|
||||
do { \
|
||||
if ((rel)->pgstat_info != NULL) \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_numscans++; \
|
||||
} while (0)
|
||||
#define pgstat_count_index_tuples(rel, n) \
|
||||
do { \
|
||||
if ((rel)->pgstat_info != NULL) \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_tuples_returned += (n); \
|
||||
} while (0)
|
||||
#define pgstat_count_buffer_read(rel) \
|
||||
do { \
|
||||
if ((rel)->pgstat_info != NULL) \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_blocks_fetched++; \
|
||||
} while (0)
|
||||
#define pgstat_count_buffer_hit(rel) \
|
||||
do { \
|
||||
if ((rel)->pgstat_info != NULL) \
|
||||
if (pgstat_relation_should_count(rel)) \
|
||||
(rel)->pgstat_info->t_counts.t_blocks_hit++; \
|
||||
} while (0)
|
||||
#define pgstat_count_buffer_read_time(n) \
|
||||
|
Reference in New Issue
Block a user