summaryrefslogtreecommitdiff
path: root/src/include/pgstat.h
diff options
context:
space:
mode:
authorAndres Freund2022-10-14 18:11:34 +0000
committerAndres Freund2022-10-14 18:11:34 +0000
commitc037471832e1ec3327f81eebbd8892e5c1042fe0 (patch)
treef5c6db830b5b183388d3874ec5f70cdd3c9ec47e /src/include/pgstat.h
parent309b2cf2433d1b1454636595600f160b41871ff5 (diff)
pgstat: Track time of the last scan of a relation
It can be useful to know when a relation has last been used, e.g., when evaluating whether an index is still required. It was already possible to infer the time of the last usage by tracking, e.g., pg_stat_all_indexes.idx_scan over time. But far from everybody does so. To make it easier to detect the last time a relation has been scanned, track that time in each relation's pgstat entry. To minimize overhead a) the timestamp is updated only when the backend pending stats entry is flushed to shared stats b) the last transaction's stop timestamp is used as the timestamp. Bumps catalog and stats format versions. Author: Dave Page <dpage@pgadmin.org> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Bruce Momjian <bruce@momjian.us> Reviewed-by: Vik Fearing <vik@postgresfriends.org> Discussion: https://postgr.es/m/CA+OCxozrVHNFVEPkweUHMZje+t1tfY816d9MZYc6eZwOOusOaQ@mail.gmail.com
Diffstat (limited to 'src/include/pgstat.h')
-rw-r--r--src/include/pgstat.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index cc1d1dcb7d..9e2ce6f011 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -242,7 +242,7 @@ typedef struct PgStat_TableXactStatus
* ------------------------------------------------------------
*/
-#define PGSTAT_FILE_FORMAT_ID 0x01A5BCA8
+#define PGSTAT_FILE_FORMAT_ID 0x01A5BCA9
typedef struct PgStat_ArchiverStats
{
@@ -354,6 +354,7 @@ typedef struct PgStat_StatSubEntry
typedef struct PgStat_StatTabEntry
{
PgStat_Counter numscans;
+ TimestampTz lastscan;
PgStat_Counter tuples_returned;
PgStat_Counter tuples_fetched;