Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f4d242e

Browse files
committed
Remove some unnecessary tests of pgstat_track_counts.
We may as well make pgstat_count_heap_scan() and related macros just count whenever rel->pgstat_info isn't null. Testing pgstat_track_counts buys nothing at all in the normal case where that flag is ON; and when it's OFF, the pgstat_info link will be null, so it's still a useless test. This change is unlikely to buy any noticeable performance improvement, but a cycle shaved is a cycle earned; and my investigations earlier today convinced me that we're down to the point where individual instructions in the inner execution loops are starting to matter.
1 parent 82659e0 commit f4d242e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/backend/postmaster/pgstat.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ pgstat_count_heap_insert(Relation rel)
16601660
{
16611661
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
16621662

1663-
if (pgstat_track_counts && pgstat_info != NULL)
1663+
if (pgstat_info != NULL)
16641664
{
16651665
/* We have to log the effect at the proper transactional level */
16661666
int nest_level = GetCurrentTransactionNestLevel();
@@ -1681,7 +1681,7 @@ pgstat_count_heap_update(Relation rel, bool hot)
16811681
{
16821682
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
16831683

1684-
if (pgstat_track_counts && pgstat_info != NULL)
1684+
if (pgstat_info != NULL)
16851685
{
16861686
/* We have to log the effect at the proper transactional level */
16871687
int nest_level = GetCurrentTransactionNestLevel();
@@ -1706,7 +1706,7 @@ pgstat_count_heap_delete(Relation rel)
17061706
{
17071707
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
17081708

1709-
if (pgstat_track_counts && pgstat_info != NULL)
1709+
if (pgstat_info != NULL)
17101710
{
17111711
/* We have to log the effect at the proper transactional level */
17121712
int nest_level = GetCurrentTransactionNestLevel();
@@ -1732,7 +1732,7 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
17321732
{
17331733
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
17341734

1735-
if (pgstat_track_counts && pgstat_info != NULL)
1735+
if (pgstat_info != NULL)
17361736
pgstat_info->t_counts.t_delta_dead_tuples -= delta;
17371737
}
17381738

src/include/pgstat.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -705,37 +705,37 @@ extern void pgstat_initstats(Relation rel);
705705

706706
#define pgstat_count_heap_scan(rel) \
707707
do { \
708-
if (pgstat_track_counts && (rel)->pgstat_info != NULL) \
708+
if ((rel)->pgstat_info != NULL) \
709709
(rel)->pgstat_info->t_counts.t_numscans++; \
710710
} while (0)
711711
#define pgstat_count_heap_getnext(rel) \
712712
do { \
713-
if (pgstat_track_counts && (rel)->pgstat_info != NULL) \
713+
if ((rel)->pgstat_info != NULL) \
714714
(rel)->pgstat_info->t_counts.t_tuples_returned++; \
715715
} while (0)
716716
#define pgstat_count_heap_fetch(rel) \
717717
do { \
718-
if (pgstat_track_counts && (rel)->pgstat_info != NULL) \
718+
if ((rel)->pgstat_info != NULL) \
719719
(rel)->pgstat_info->t_counts.t_tuples_fetched++; \
720720
} while (0)
721721
#define pgstat_count_index_scan(rel) \
722722
do { \
723-
if (pgstat_track_counts && (rel)->pgstat_info != NULL) \
723+
if ((rel)->pgstat_info != NULL) \
724724
(rel)->pgstat_info->t_counts.t_numscans++; \
725725
} while (0)
726726
#define pgstat_count_index_tuples(rel, n) \
727727
do { \
728-
if (pgstat_track_counts && (rel)->pgstat_info != NULL) \
728+
if ((rel)->pgstat_info != NULL) \
729729
(rel)->pgstat_info->t_counts.t_tuples_returned += (n); \
730730
} while (0)
731731
#define pgstat_count_buffer_read(rel) \
732732
do { \
733-
if (pgstat_track_counts && (rel)->pgstat_info != NULL) \
733+
if ((rel)->pgstat_info != NULL) \
734734
(rel)->pgstat_info->t_counts.t_blocks_fetched++; \
735735
} while (0)
736736
#define pgstat_count_buffer_hit(rel) \
737737
do { \
738-
if (pgstat_track_counts && (rel)->pgstat_info != NULL) \
738+
if ((rel)->pgstat_info != NULL) \
739739
(rel)->pgstat_info->t_counts.t_blocks_hit++; \
740740
} while (0)
741741

0 commit comments

Comments
 (0)