diff options
author | Michael Paquier <michael@paquier.xyz> | 2025-10-08 12:43:40 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2025-10-08 12:43:40 +0900 |
commit | b71bae41a0cdda879db39d9946d2cc4af910bed1 (patch) | |
tree | 2a92bc7489ef681fede095f08e46a4dcf4d856d1 /src/include | |
parent | 035b09131daab84f2ed9a4a3f766bf4781fd5cbf (diff) |
Add stats_reset to pg_stat_user_functions
It is possible to call pg_stat_reset_single_function_counters() for a
single function, but the reset time was missing the system view showing
its statistics. Like all the fields of pg_stat_user_functions, the GUC
track_functions needs to be enabled to show the statistics about
function executions.
Bump catalog version.
Bump PGSTAT_FILE_FORMAT_ID, as a result of the new field added to
PgStat_StatFuncEntry.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/aONjnsaJSx-nEdfU@paquier.xyz
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
-rw-r--r-- | src/include/catalog/pg_proc.dat | 4 | ||||
-rw-r--r-- | src/include/pgstat.h | 3 | ||||
-rw-r--r-- | src/include/utils/pgstat_internal.h | 1 |
4 files changed, 8 insertions, 2 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 642abe5217e..00b3bce1e12 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -57,6 +57,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 202510062 +#define CATALOG_VERSION_NO 202510081 #endif diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7c20180637f..6bb31892d1d 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -6071,6 +6071,10 @@ proname => 'pg_stat_get_function_self_time', provolatile => 's', proparallel => 'r', prorettype => 'float8', proargtypes => 'oid', prosrc => 'pg_stat_get_function_self_time' }, +{ oid => '8745', descr => 'statistics: last reset for a function', + proname => 'pg_stat_get_function_stat_reset_time', provolatile => 's', + proparallel => 'r', prorettype => 'timestamptz', proargtypes => 'oid', + prosrc => 'pg_stat_get_function_stat_reset_time' }, { oid => '3037', descr => 'statistics: number of scans done for table/index in current transaction', diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 8e8adb01176..d24bf864a22 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -212,7 +212,7 @@ typedef struct PgStat_TableXactStatus * ------------------------------------------------------------ */ -#define PGSTAT_FILE_FORMAT_ID 0x01A5BCB8 +#define PGSTAT_FILE_FORMAT_ID 0x01A5BCB9 typedef struct PgStat_ArchiverStats { @@ -384,6 +384,7 @@ typedef struct PgStat_StatFuncEntry PgStat_Counter total_time; /* times in microseconds */ PgStat_Counter self_time; + TimestampTz stat_reset_timestamp; } PgStat_StatFuncEntry; typedef struct PgStat_StatReplSlotEntry diff --git a/src/include/utils/pgstat_internal.h b/src/include/utils/pgstat_internal.h index dc42d8043b5..4d2b8aa6081 100644 --- a/src/include/utils/pgstat_internal.h +++ b/src/include/utils/pgstat_internal.h @@ -691,6 +691,7 @@ extern void pgstat_database_reset_timestamp_cb(PgStatShared_Common *header, Time */ extern bool pgstat_function_flush_cb(PgStat_EntryRef *entry_ref, bool nowait); +extern void pgstat_function_reset_timestamp_cb(PgStatShared_Common *header, TimestampTz ts); /* |