pgstat_assoc_fix_for_views.patch
application/octet-stream
Filename: pgstat_assoc_fix_for_views.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/utils/activity/pgstat_relation.c | 4 | 11 |
diff --git a/src/backend/utils/activity/pgstat_relation.c b/src/backend/utils/activity/pgstat_relation.c
index f92e16e..09546b5 100644
--- a/src/backend/utils/activity/pgstat_relation.c
+++ b/src/backend/utils/activity/pgstat_relation.c
@@ -85,6 +85,10 @@ pgstat_copy_relation_stats(Relation dst, Relation src)
* We assume that a relcache entry's pgstat_info field is zeroed by relcache.c
* when the relcache entry is made; thereafter it is long-lived data.
*
+ * Ideally we wouldn't need to unlink relations from views as we don't count
+ * stats for relations without storage but some operations can change a relation
+ * to a view, in which case the previous relation should be unlinked.
+ *
* This does not create a reference to a stats entry in shared memory, nor
* allocate memory for the pending stats. That happens in
* pgstat_assoc_relation().
@@ -92,17 +96,6 @@ pgstat_copy_relation_stats(Relation dst, Relation src)
void
pgstat_init_relation(Relation rel)
{
- char relkind = rel->rd_rel->relkind;
-
- /*
- * We only count stats for relations with storage and partitioned tables
- */
- if (!RELKIND_HAS_STORAGE(relkind) && relkind != RELKIND_PARTITIONED_TABLE)
- {
- rel->pgstat_enabled = false;
- rel->pgstat_info = NULL;
- return;
- }
if (!pgstat_track_counts)
{