diff options
Diffstat (limited to 'src/include/pgstat.h')
| -rw-r--r-- | src/include/pgstat.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 95f595353dc..3499c86dbfe 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -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) \ |
