*
* Waste no time on partitioned tables, though.
*/
- if (rel->pgstat_info != NULL &&
+ if (pgstat_relation_should_count(rel) &&
rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
{
PgStat_TableXactStatus *trans;
void
pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
{
- PgStat_TableStatus *pgstat_info = rel->pgstat_info;
-
- if (pgstat_info != NULL)
+ if (pgstat_relation_should_count(rel))
{
- /* We have to log the effect at the proper transactional level */
+ PgStat_TableStatus *pgstat_info = rel->pgstat_info;
int nest_level = GetCurrentTransactionNestLevel();
+ /* We have to log the effect at the proper transactional level */
if (pgstat_info->trans == NULL ||
pgstat_info->trans->nest_level != nest_level)
add_tabstat_xact_level(pgstat_info, nest_level);
void
pgstat_count_heap_update(Relation rel, bool hot)
{
- PgStat_TableStatus *pgstat_info = rel->pgstat_info;
-
- if (pgstat_info != NULL)
+ if (pgstat_relation_should_count(rel))
{
- /* We have to log the effect at the proper transactional level */
+ PgStat_TableStatus *pgstat_info = rel->pgstat_info;
int nest_level = GetCurrentTransactionNestLevel();
+ /* We have to log the effect at the proper transactional level */
if (pgstat_info->trans == NULL ||
pgstat_info->trans->nest_level != nest_level)
add_tabstat_xact_level(pgstat_info, nest_level);
void
pgstat_count_heap_delete(Relation rel)
{
- PgStat_TableStatus *pgstat_info = rel->pgstat_info;
-
- if (pgstat_info != NULL)
+ if (pgstat_relation_should_count(rel))
{
- /* We have to log the effect at the proper transactional level */
+ PgStat_TableStatus *pgstat_info = rel->pgstat_info;
int nest_level = GetCurrentTransactionNestLevel();
+ /* We have to log the effect at the proper transactional level */
if (pgstat_info->trans == NULL ||
pgstat_info->trans->nest_level != nest_level)
add_tabstat_xact_level(pgstat_info, nest_level);
void
pgstat_count_truncate(Relation rel)
{
- PgStat_TableStatus *pgstat_info = rel->pgstat_info;
-
- if (pgstat_info != NULL)
+ if (pgstat_relation_should_count(rel))
{
- /* We have to log the effect at the proper transactional level */
+ PgStat_TableStatus *pgstat_info = rel->pgstat_info;
int nest_level = GetCurrentTransactionNestLevel();
+ /* We have to log the effect at the proper transactional level */
if (pgstat_info->trans == NULL ||
pgstat_info->trans->nest_level != nest_level)
add_tabstat_xact_level(pgstat_info, nest_level);
void
pgstat_update_heap_dead_tuples(Relation rel, int delta)
{
- PgStat_TableStatus *pgstat_info = rel->pgstat_info;
+ if (pgstat_relation_should_count(rel))
+ {
+ PgStat_TableStatus *pgstat_info = rel->pgstat_info;
- if (pgstat_info != NULL)
pgstat_info->t_counts.t_delta_dead_tuples -= delta;
+ }
}
/*
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) \