Hi all, (Relevant folks in CC.) While hacking on the area of pgstat_*.c, I have noticed the existence of named_on_disk in PgStat_KindInfo, that is here to track the fact that replication slots are a particular case in the PgStat_HashKey for the dshash table of the stats because this kind of stats requires a mapping between the replication slot name and the hash key.
As far as I can see, this field is not required and is used nowhere, because the code relies on the existence of the to_serialized_name and from_serialized_name callbacks to do the mapping. Wouldn't it make sense to remove it? This field is defined since 5891c7a8ed8f that introduced the shmem stats, and has never been used since. This frees an extra bit in PgStat_KindInfo, which is going to help me a bit with what I'm doing with this area of the code while keeping the structure size the same. Thoughts? -- Michael
From 68c6e8401baea7ba1f0c616bbcd74c19daab770e Mon Sep 17 00:00:00 2001 From: Michael Paquier <mich...@paquier.xyz> Date: Fri, 7 Jun 2024 14:04:06 +0900 Subject: [PATCH] Remove PgStat_KindInfo.named_on_disk This field is used to track a special case for replication slots that need a mapping between the dshash key and the slot names, but it is used nowhere as callbacks take care of sanity checks. --- src/include/utils/pgstat_internal.h | 8 +------- src/backend/utils/activity/pgstat.c | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/include/utils/pgstat_internal.h b/src/include/utils/pgstat_internal.h index dbbca31602..f6031995a9 100644 --- a/src/include/utils/pgstat_internal.h +++ b/src/include/utils/pgstat_internal.h @@ -193,12 +193,6 @@ typedef struct PgStat_KindInfo */ bool accessed_across_databases:1; - /* - * For variable-numbered stats: Identified on-disk using a name, rather - * than PgStat_HashKey. Probably only needed for replication slot stats. - */ - bool named_on_disk:1; - /* * The size of an entry in the shared stats hash table (pointed to by * PgStatShared_HashEntry->body). @@ -239,7 +233,7 @@ typedef struct PgStat_KindInfo void (*reset_timestamp_cb) (PgStatShared_Common *header, TimestampTz ts); /* - * For variable-numbered stats with named_on_disk. Optional. + * For variable-numbered stats. Optional. */ void (*to_serialized_name) (const PgStat_HashKey *key, const PgStatShared_Common *header, NameData *name); diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index dcc2ad8d95..44f0d3ede7 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -307,7 +307,6 @@ static const PgStat_KindInfo pgstat_kind_infos[PGSTAT_NUM_KINDS] = { .fixed_amount = false, .accessed_across_databases = true, - .named_on_disk = true, .shared_size = sizeof(PgStatShared_ReplSlot), .shared_data_off = offsetof(PgStatShared_ReplSlot, stats), -- 2.43.0
signature.asc
Description: PGP signature