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" <bertranddrouvot.pg@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de
Discussion: https://postgr.es/m/
8c1851a2-a98e-e1bc-7729-
37b0b95f66ec@gmail.com
#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 */
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);
}
/*