* Statistics are loaded from the filesystem during startup (by the startup
* process), unless preceded by a crash, in which case all stats are
* discarded. They are written out by the checkpointer process just before
- * shutting down, except when shutting down in immediate mode.
+ * shutting down (if the stats kind allows it), except when shutting down in
+ * immediate mode.
*
* Fixed-numbered stats are stored in plain (non-dynamic) shared memory.
*
.name = "database",
.fixed_amount = false,
+ .write_to_file = true,
/* so pg_stat_database entries can be seen in all databases */
.accessed_across_databases = true,
.name = "relation",
.fixed_amount = false,
+ .write_to_file = true,
.shared_size = sizeof(PgStatShared_Relation),
.shared_data_off = offsetof(PgStatShared_Relation, stats),
.name = "function",
.fixed_amount = false,
+ .write_to_file = true,
.shared_size = sizeof(PgStatShared_Function),
.shared_data_off = offsetof(PgStatShared_Function, stats),
.name = "replslot",
.fixed_amount = false,
+ .write_to_file = true,
.accessed_across_databases = true,
.name = "subscription",
.fixed_amount = false,
+ .write_to_file = true,
/* so pg_stat_subscription_stats entries can be seen in all databases */
.accessed_across_databases = true,
.name = "archiver",
.fixed_amount = true,
+ .write_to_file = true,
.snapshot_ctl_off = offsetof(PgStat_Snapshot, archiver),
.shared_ctl_off = offsetof(PgStat_ShmemControl, archiver),
.name = "bgwriter",
.fixed_amount = true,
+ .write_to_file = true,
.snapshot_ctl_off = offsetof(PgStat_Snapshot, bgwriter),
.shared_ctl_off = offsetof(PgStat_ShmemControl, bgwriter),
.name = "checkpointer",
.fixed_amount = true,
+ .write_to_file = true,
.snapshot_ctl_off = offsetof(PgStat_Snapshot, checkpointer),
.shared_ctl_off = offsetof(PgStat_ShmemControl, checkpointer),
.name = "io",
.fixed_amount = true,
+ .write_to_file = true,
.snapshot_ctl_off = offsetof(PgStat_Snapshot, io),
.shared_ctl_off = offsetof(PgStat_ShmemControl, io),
.name = "slru",
.fixed_amount = true,
+ .write_to_file = true,
.snapshot_ctl_off = offsetof(PgStat_Snapshot, slru),
.shared_ctl_off = offsetof(PgStat_ShmemControl, slru),
.name = "wal",
.fixed_amount = true,
+ .write_to_file = true,
.snapshot_ctl_off = offsetof(PgStat_Snapshot, wal),
.shared_ctl_off = offsetof(PgStat_ShmemControl, wal),
if (pgstat_is_kind_builtin(kind))
Assert(info->snapshot_ctl_off != 0);
+ /* skip if no need to write to file */
+ if (!info->write_to_file)
+ continue;
+
pgstat_build_snapshot_fixed(kind);
if (pgstat_is_kind_builtin(kind))
ptr = ((char *) &pgStatLocal.snapshot) + info->snapshot_ctl_off;
/* if not dropped the valid-entry refcount should exist */
Assert(pg_atomic_read_u32(&ps->refcount) > 0);
+ /* skip if no need to write to file */
+ if (!kind_info->write_to_file)
+ continue;
+
if (!kind_info->to_serialized_name)
{
/* normal stats entry, identified by PgStat_HashKey */