summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2022-11-20 18:53:31 +0000
committerAndres Freund2022-11-20 18:56:32 +0000
commit061bf98fb8f468b9a8c9fb617bb30136db1cc812 (patch)
treebaa03237370992bdb8f5fcf15027a63f6697ba6f
parentb62303794efd97f2afb55f1e1b82fffae2cf8a2d (diff)
pgstat: replace double lookup with IsSharedRelation()
As the list of shared relations is fixed, we can just dispatch based IsSharedRelation(), instead of first trying to look up stats for a non-shared rel and falling back to shared stats. Author: "Drouvot, Bertrand" <[email protected]> Reviewed-by: Bharath Rupireddy <[email protected]> Reviewed-by: Andres Freund <[email protected] Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/backend/utils/activity/pgstat_relation.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/backend/utils/activity/pgstat_relation.c b/src/backend/utils/activity/pgstat_relation.c
index 55a355f583b..f92e16e7af8 100644
--- a/src/backend/utils/activity/pgstat_relation.c
+++ b/src/backend/utils/activity/pgstat_relation.c
@@ -25,6 +25,7 @@
#include "utils/pgstat_internal.h"
#include "utils/rel.h"
#include "utils/timestamp.h"
+#include "catalog/catalog.h"
/* Record that's written to 2PC state file when pgstat state is persisted */
@@ -437,17 +438,7 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
PgStat_StatTabEntry *
pgstat_fetch_stat_tabentry(Oid relid)
{
- PgStat_StatTabEntry *tabentry;
-
- tabentry = pgstat_fetch_stat_tabentry_ext(false, relid);
- if (tabentry != NULL)
- return tabentry;
-
- /*
- * If we didn't find it, maybe it's a shared table.
- */
- tabentry = pgstat_fetch_stat_tabentry_ext(true, relid);
- return tabentry;
+ return pgstat_fetch_stat_tabentry_ext(IsSharedRelation(relid), relid);
}
/*