PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pgstat.h
Go to the documentation of this file.
1/* ----------
2 * pgstat.h
3 *
4 * Definitions for the PostgreSQL cumulative statistics system.
5 *
6 * Copyright (c) 2001-2025, PostgreSQL Global Development Group
7 *
8 * src/include/pgstat.h
9 * ----------
10 */
11#ifndef PGSTAT_H
12#define PGSTAT_H
13
14#include "datatype/timestamp.h"
16#include "postmaster/pgarch.h" /* for MAX_XFN_CHARS */
18#include "utils/backend_progress.h" /* for backward compatibility */ /* IWYU pragma: export */
19#include "utils/backend_status.h" /* for backward compatibility */ /* IWYU pragma: export */
20#include "utils/pgstat_kind.h"
21#include "utils/relcache.h"
22#include "utils/wait_event.h" /* for backward compatibility */ /* IWYU pragma: export */
23
24
25/* ----------
26 * Paths for the statistics files (relative to installation's $PGDATA).
27 * ----------
28 */
29#define PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat"
30#define PGSTAT_STAT_PERMANENT_FILENAME "pg_stat/pgstat.stat"
31#define PGSTAT_STAT_PERMANENT_TMPFILE "pg_stat/pgstat.tmp"
32
33/* Default directory to store temporary statistics data in */
34#define PG_STAT_TMP_DIR "pg_stat_tmp"
35
36/* Values for track_functions GUC variable --- order is significant! */
38{
43
45{
50
51/* Values to track the cause of session termination */
52typedef enum SessionEndType
53{
54 DISCONNECT_NOT_YET, /* still active */
60
61/* ----------
62 * The data type used for counters.
63 * ----------
64 */
66
67
68/* ------------------------------------------------------------
69 * Structures kept in backend local memory while accumulating counts
70 * ------------------------------------------------------------
71 */
72
73/* ----------
74 * PgStat_FunctionCounts The actual per-function counts kept by a backend
75 *
76 * Note that the time counters are in instr_time format here. We convert to
77 * microseconds in PgStat_Counter format when flushing out pending statistics.
78 * ----------
79 */
81{
86
87/*
88 * Working state needed to accumulate per-function-call timing statistics.
89 */
91{
92 /* Link to function's hashtable entry (must still be there at exit!) */
93 /* NULL means we are not tracking the current function call */
95 /* Total time previously charged to function, as of function start */
97 /* Backend-wide total time as of function start */
99 /* system clock as of function start */
102
103/* ----------
104 * PgStat_BackendSubEntry Non-flushed subscription stats.
105 * ----------
106 */
108{
113
114/* ----------
115 * PgStat_TableCounts The actual per-table counts kept by a backend
116 *
117 * This struct should contain only actual event counters, because we make use
118 * of pg_memory_is_all_zeros() to detect whether there are any stats updates
119 * to apply.
120 *
121 * It is a component of PgStat_TableStatus (within-backend state).
122 *
123 * Note: for a table, tuples_returned is the number of tuples successfully
124 * fetched by heap_getnext, while tuples_fetched is the number of tuples
125 * successfully fetched by heap_fetch under the control of bitmap indexscans.
126 * For an index, tuples_returned is the number of index entries returned by
127 * the index AM, while tuples_fetched is the number of tuples successfully
128 * fetched by heap_fetch under the control of simple indexscans for this index.
129 *
130 * tuples_inserted/updated/deleted/hot_updated/newpage_updated count attempted
131 * actions, regardless of whether the transaction committed. delta_live_tuples,
132 * delta_dead_tuples, and changed_tuples are set depending on commit or abort.
133 * Note that delta_live_tuples and delta_dead_tuples can be negative!
134 * ----------
135 */
136typedef struct PgStat_TableCounts
137{
139
142
149
153
157
158/* ----------
159 * PgStat_TableStatus Per-table status within a backend
160 *
161 * Many of the event counters are nontransactional, ie, we count events
162 * in committed and aborted transactions alike. For these, we just count
163 * directly in the PgStat_TableStatus. However, delta_live_tuples,
164 * delta_dead_tuples, and changed_tuples must be derived from event counts
165 * with awareness of whether the transaction or subtransaction committed or
166 * aborted. Hence, we also keep a stack of per-(sub)transaction status
167 * records for every table modified in the current transaction. At commit
168 * or abort, we propagate tuples_inserted/updated/deleted up to the
169 * parent subtransaction level, or out to the parent PgStat_TableStatus,
170 * as appropriate.
171 * ----------
172 */
173typedef struct PgStat_TableStatus
174{
175 Oid id; /* table's OID */
176 bool shared; /* is it a shared catalog? */
177 struct PgStat_TableXactStatus *trans; /* lowest subxact's counts */
178 PgStat_TableCounts counts; /* event counts to be sent */
179 Relation relation; /* rel that is using this entry */
181
182/* ----------
183 * PgStat_TableXactStatus Per-table, per-subtransaction status
184 * ----------
185 */
187{
188 PgStat_Counter tuples_inserted; /* tuples inserted in (sub)xact */
189 PgStat_Counter tuples_updated; /* tuples updated in (sub)xact */
190 PgStat_Counter tuples_deleted; /* tuples deleted in (sub)xact */
191 bool truncdropped; /* relation truncated/dropped in this
192 * (sub)xact */
193 /* tuples i/u/d prior to truncate/drop */
197 int nest_level; /* subtransaction nest level */
198 /* links to other structs for same relation: */
199 struct PgStat_TableXactStatus *upper; /* next higher subxact if any */
200 PgStat_TableStatus *parent; /* per-table status */
201 /* structs of same subxact level are linked here: */
202 struct PgStat_TableXactStatus *next; /* next of same subxact */
204
205
206/* ------------------------------------------------------------
207 * Data structures on disk and in shared memory follow
208 *
209 * PGSTAT_FILE_FORMAT_ID should be changed whenever any of these
210 * data structures change.
211 * ------------------------------------------------------------
212 */
213
214#define PGSTAT_FILE_FORMAT_ID 0x01A5BCB7
215
217{
218 PgStat_Counter archived_count; /* archival successes */
219 char last_archived_wal[MAX_XFN_CHARS + 1]; /* last WAL file
220 * archived */
221 TimestampTz last_archived_timestamp; /* last archival success time */
222 PgStat_Counter failed_count; /* failed archival attempts */
223 char last_failed_wal[MAX_XFN_CHARS + 1]; /* WAL file involved in
224 * last failure */
225 TimestampTz last_failed_timestamp; /* last archival failure time */
228
229/* ---------
230 * PgStat_BgWriterStats Background Writer statistics
231 *
232 * This struct should contain only actual event counters, because we make use
233 * of pg_memory_is_all_zeros() to detect whether there are any stats updates
234 * to apply.
235 * ---------
236 */
238{
244
245/* --------
246 * PgStat_CheckpointerStats Checkpoint statistics
247 *
248 * This struct should contain only actual event counters, because we make use
249 * of pg_memory_is_all_zeros() to detect whether there are any stats updates to
250 * apply.
251 * ---------
252 */
254{
261 PgStat_Counter write_time; /* times in milliseconds */
267
268
269/*
270 * Types related to counting IO operations
271 */
272typedef enum IOObject
273{
278
279#define IOOBJECT_NUM_TYPES (IOOBJECT_WAL + 1)
280
281typedef enum IOContext
282{
289
290#define IOCONTEXT_NUM_TYPES (IOCONTEXT_VACUUM + 1)
291
292/*
293 * Enumeration of IO operations.
294 *
295 * This enum categorizes IO operations into two groups, depending on if
296 * byte operations are supported.
297 *
298 * Ensure IOOP_EXTEND is the first and IOOP_WRITE is the last ones in the
299 * tracked in bytes group and that the groups stay in that order.
300 */
301typedef enum IOOp
302{
303 /* IOs not tracked in bytes */
309
310 /* IOs tracked in bytes */
315
316#define IOOP_NUM_TYPES (IOOP_WRITE + 1)
317
318#define pgstat_is_ioop_tracked_in_bytes(io_op) \
319 (((unsigned int) (io_op)) < IOOP_NUM_TYPES && \
320 ((unsigned int) (io_op)) >= IOOP_EXTEND)
321
322typedef struct PgStat_BktypeIO
323{
328
329typedef struct PgStat_PendingIO
330{
335
336typedef struct PgStat_IO
337{
341
342typedef struct PgStat_StatDBEntry
343{
365 PgStat_Counter blk_read_time; /* times in microseconds */
376
379
381{
383
384 PgStat_Counter total_time; /* times in microseconds */
387
389{
400
401typedef struct PgStat_SLRUStats
402{
412
414{
420
422{
425
428
434
439
442
443 TimestampTz last_vacuum_time; /* user initiated vacuum */
445 TimestampTz last_autovacuum_time; /* autovacuum initiated */
447 TimestampTz last_analyze_time; /* user initiated */
449 TimestampTz last_autoanalyze_time; /* autovacuum initiated */
451
452 PgStat_Counter total_vacuum_time; /* times in milliseconds */
457
458/* ------
459 * PgStat_WalCounters WAL activity data gathered from WalUsage
460 *
461 * This stores all the counters and data gathered from WalUsage for WAL
462 * activity statistics, separated into its own structure so as this can be
463 * shared across multiple Stats structures.
464 * ------
465 */
466typedef struct PgStat_WalCounters
467{
473
474/* -------
475 * PgStat_WalStats WAL statistics
476 * -------
477 */
478typedef struct PgStat_WalStats
479{
483
484/* -------
485 * PgStat_Backend Backend statistics
486 * -------
487 */
488typedef struct PgStat_Backend
489{
494
495/* ---------
496 * PgStat_BackendPending Non-flushed backend stats.
497 * ---------
498 */
500{
501 /*
502 * Backend statistics store the same amount of IO data as PGSTAT_KIND_IO.
503 */
506
507/*
508 * Functions in pgstat.c
509 */
510
511/* functions called from postmaster */
512extern Size StatsShmemSize(void);
513extern void StatsShmemInit(void);
514
515/* Functions called during server startup / shutdown */
516extern void pgstat_restore_stats(void);
517extern void pgstat_discard_stats(void);
518extern void pgstat_before_server_shutdown(int code, Datum arg);
519
520/* Functions for backend initialization */
521extern void pgstat_initialize(void);
522
523/* Functions called from backends */
524extern long pgstat_report_stat(bool force);
525extern void pgstat_force_next_flush(void);
526
527extern void pgstat_reset_counters(void);
528extern void pgstat_reset(PgStat_Kind kind, Oid dboid, uint64 objid);
529extern void pgstat_reset_of_kind(PgStat_Kind kind);
530
531/* stats accessors */
532extern void pgstat_clear_snapshot(void);
533extern TimestampTz pgstat_get_stat_snapshot_timestamp(bool *have_snapshot);
534
535/* helpers */
536extern PgStat_Kind pgstat_get_kind_from_str(char *kind_str);
537extern bool pgstat_have_entry(PgStat_Kind kind, Oid dboid, uint64 objid);
538
539
540/*
541 * Functions in pgstat_archiver.c
542 */
543
544extern void pgstat_report_archiver(const char *xlog, bool failed);
546
547/*
548 * Functions in pgstat_backend.c
549 */
550
551/* used by pgstat_io.c for I/O stats tracked in backends */
552extern void pgstat_count_backend_io_op_time(IOObject io_object,
553 IOContext io_context,
554 IOOp io_op,
555 instr_time io_time);
556extern void pgstat_count_backend_io_op(IOObject io_object,
557 IOContext io_context,
558 IOOp io_op, uint32 cnt,
559 uint64 bytes);
562 BackendType *bktype);
563extern bool pgstat_tracks_backend_bktype(BackendType bktype);
564extern void pgstat_create_backend(ProcNumber procnum);
565
566/*
567 * Functions in pgstat_bgwriter.c
568 */
569
570extern void pgstat_report_bgwriter(void);
572
573
574/*
575 * Functions in pgstat_checkpointer.c
576 */
577
578extern void pgstat_report_checkpointer(void);
580
581
582/*
583 * Functions in pgstat_io.c
584 */
585
586extern bool pgstat_bktype_io_stats_valid(PgStat_BktypeIO *backend_io,
587 BackendType bktype);
588extern void pgstat_count_io_op(IOObject io_object, IOContext io_context,
589 IOOp io_op, uint32 cnt, uint64 bytes);
590extern instr_time pgstat_prepare_io_time(bool track_io_guc);
591extern void pgstat_count_io_op_time(IOObject io_object, IOContext io_context,
593 uint32 cnt, uint64 bytes);
594
595extern PgStat_IO *pgstat_fetch_stat_io(void);
596extern const char *pgstat_get_io_context_name(IOContext io_context);
597extern const char *pgstat_get_io_object_name(IOObject io_object);
598
599extern bool pgstat_tracks_io_bktype(BackendType bktype);
600extern bool pgstat_tracks_io_object(BackendType bktype,
601 IOObject io_object, IOContext io_context);
602extern bool pgstat_tracks_io_op(BackendType bktype, IOObject io_object,
603 IOContext io_context, IOOp io_op);
604
605
606/*
607 * Functions in pgstat_database.c
608 */
609
610extern void pgstat_drop_database(Oid databaseid);
611extern void pgstat_report_autovac(Oid dboid);
612extern void pgstat_report_recovery_conflict(int reason);
613extern void pgstat_report_deadlock(void);
615extern void pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount);
616extern void pgstat_report_connect(Oid dboid);
617extern void pgstat_update_parallel_workers_stats(PgStat_Counter workers_to_launch,
618 PgStat_Counter workers_launched);
619
620#define pgstat_count_buffer_read_time(n) \
621 (pgStatBlockReadTime += (n))
622#define pgstat_count_buffer_write_time(n) \
623 (pgStatBlockWriteTime += (n))
624#define pgstat_count_conn_active_time(n) \
625 (pgStatActiveTime += (n))
626#define pgstat_count_conn_txn_idle_time(n) \
627 (pgStatTransactionIdleTime += (n))
628
630
631
632/*
633 * Functions in pgstat_function.c
634 */
635
636extern void pgstat_create_function(Oid proid);
637extern void pgstat_drop_function(Oid proid);
638
643 bool finalize);
644
647
648
649/*
650 * Functions in pgstat_relation.c
651 */
652
653extern void pgstat_create_relation(Relation rel);
654extern void pgstat_drop_relation(Relation rel);
655extern void pgstat_copy_relation_stats(Relation dst, Relation src);
656
657extern void pgstat_init_relation(Relation rel);
658extern void pgstat_assoc_relation(Relation rel);
659extern void pgstat_unlink_relation(Relation rel);
660
661extern void pgstat_report_vacuum(Oid tableoid, bool shared,
662 PgStat_Counter livetuples, PgStat_Counter deadtuples,
663 TimestampTz starttime);
664extern void pgstat_report_analyze(Relation rel,
665 PgStat_Counter livetuples, PgStat_Counter deadtuples,
666 bool resetcounter, TimestampTz starttime);
667
668/*
669 * If stats are enabled, but pending data hasn't been prepared yet, call
670 * pgstat_assoc_relation() to do so. See its comment for why this is done
671 * separately from pgstat_init_relation().
672 */
673#define pgstat_should_count_relation(rel) \
674 (likely((rel)->pgstat_info != NULL) ? true : \
675 ((rel)->pgstat_enabled ? pgstat_assoc_relation(rel), true : false))
676
677/* nontransactional event counts are simple enough to inline */
678
679#define pgstat_count_heap_scan(rel) \
680 do { \
681 if (pgstat_should_count_relation(rel)) \
682 (rel)->pgstat_info->counts.numscans++; \
683 } while (0)
684#define pgstat_count_heap_getnext(rel) \
685 do { \
686 if (pgstat_should_count_relation(rel)) \
687 (rel)->pgstat_info->counts.tuples_returned++; \
688 } while (0)
689#define pgstat_count_heap_fetch(rel) \
690 do { \
691 if (pgstat_should_count_relation(rel)) \
692 (rel)->pgstat_info->counts.tuples_fetched++; \
693 } while (0)
694#define pgstat_count_index_scan(rel) \
695 do { \
696 if (pgstat_should_count_relation(rel)) \
697 (rel)->pgstat_info->counts.numscans++; \
698 } while (0)
699#define pgstat_count_index_tuples(rel, n) \
700 do { \
701 if (pgstat_should_count_relation(rel)) \
702 (rel)->pgstat_info->counts.tuples_returned += (n); \
703 } while (0)
704#define pgstat_count_buffer_read(rel) \
705 do { \
706 if (pgstat_should_count_relation(rel)) \
707 (rel)->pgstat_info->counts.blocks_fetched++; \
708 } while (0)
709#define pgstat_count_buffer_hit(rel) \
710 do { \
711 if (pgstat_should_count_relation(rel)) \
712 (rel)->pgstat_info->counts.blocks_hit++; \
713 } while (0)
714
716extern void pgstat_count_heap_update(Relation rel, bool hot, bool newpage);
717extern void pgstat_count_heap_delete(Relation rel);
718extern void pgstat_count_truncate(Relation rel);
719extern void pgstat_update_heap_dead_tuples(Relation rel, int delta);
720
722 void *recdata, uint32 len);
724 void *recdata, uint32 len);
725
728 Oid reloid);
730
731
732/*
733 * Functions in pgstat_replslot.c
734 */
735
736extern void pgstat_reset_replslot(const char *name);
737struct ReplicationSlot;
738extern void pgstat_report_replslot(struct ReplicationSlot *slot, const PgStat_StatReplSlotEntry *repSlotStat);
739extern void pgstat_create_replslot(struct ReplicationSlot *slot);
740extern void pgstat_acquire_replslot(struct ReplicationSlot *slot);
741extern void pgstat_drop_replslot(struct ReplicationSlot *slot);
743
744
745/*
746 * Functions in pgstat_slru.c
747 */
748
749extern void pgstat_reset_slru(const char *);
750extern void pgstat_count_slru_page_zeroed(int slru_idx);
751extern void pgstat_count_slru_page_hit(int slru_idx);
752extern void pgstat_count_slru_page_read(int slru_idx);
753extern void pgstat_count_slru_page_written(int slru_idx);
754extern void pgstat_count_slru_page_exists(int slru_idx);
755extern void pgstat_count_slru_flush(int slru_idx);
756extern void pgstat_count_slru_truncate(int slru_idx);
757extern const char *pgstat_get_slru_name(int slru_idx);
758extern int pgstat_get_slru_index(const char *name);
760
761
762/*
763 * Functions in pgstat_subscription.c
764 */
765
766extern void pgstat_report_subscription_error(Oid subid, bool is_apply_error);
768extern void pgstat_create_subscription(Oid subid);
769extern void pgstat_drop_subscription(Oid subid);
771
772
773/*
774 * Functions in pgstat_xact.c
775 */
776
777extern void AtEOXact_PgStat(bool isCommit, bool parallel);
778extern void AtEOSubXact_PgStat(bool isCommit, int nestDepth);
779extern void AtPrepare_PgStat(void);
780extern void PostPrepare_PgStat(void);
781struct xl_xact_stats_item;
782extern int pgstat_get_transactional_drops(bool isCommit, struct xl_xact_stats_item **items);
783extern void pgstat_execute_transactional_drops(int ndrops, struct xl_xact_stats_item *items, bool is_redo);
784
785
786/*
787 * Functions in pgstat_wal.c
788 */
789
790extern void pgstat_report_wal(bool force);
792
793
794/*
795 * Variables in pgstat.c
796 */
797
798/* GUC parameters */
802
803
804/*
805 * Variables in pgstat_bgwriter.c
806 */
807
808/* updated directly by bgwriter and bufmgr */
810
811
812/*
813 * Variables in pgstat_checkpointer.c
814 */
815
816/*
817 * Checkpointer statistics counters are updated directly by checkpointer and
818 * bufmgr.
819 */
821
822
823/*
824 * Variables in pgstat_database.c
825 */
826
827/* Updated by pgstat_count_buffer_*_time macros */
830
831/*
832 * Updated by pgstat_count_conn_*_time macros, called by
833 * pgstat_report_activity().
834 */
837
838/* updated by the traffic cop and in errfinish() */
840
841#endif /* PGSTAT_H */
#define PGDLLIMPORT
Definition: c.h:1291
int64_t int64
Definition: c.h:499
uint64_t uint64
Definition: c.h:503
uint16_t uint16
Definition: c.h:501
uint32_t uint32
Definition: c.h:502
uint32 TransactionId
Definition: c.h:623
size_t Size
Definition: c.h:576
ConflictType
Definition: conflict.h:25
#define CONFLICT_NUM_TYPES
Definition: conflict.h:54
int64 TimestampTz
Definition: timestamp.h:39
#define BACKEND_NUM_TYPES
Definition: miscadmin.h:377
BackendType
Definition: miscadmin.h:338
void * arg
const void size_t len
static time_t start_time
Definition: pg_ctl.c:95
#define MAX_XFN_CHARS
Definition: pgarch.h:26
void pgstat_reset(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition: pgstat.c:869
void pgstat_drop_function(Oid proid)
void pgstat_create_backend(ProcNumber procnum)
void pgstat_drop_subscription(Oid subid)
struct PgStat_TableStatus PgStat_TableStatus
void pgstat_update_parallel_workers_stats(PgStat_Counter workers_to_launch, PgStat_Counter workers_launched)
SessionEndType
Definition: pgstat.h:53
@ DISCONNECT_NOT_YET
Definition: pgstat.h:54
@ DISCONNECT_FATAL
Definition: pgstat.h:57
@ DISCONNECT_KILLED
Definition: pgstat.h:58
@ DISCONNECT_CLIENT_EOF
Definition: pgstat.h:56
@ DISCONNECT_NORMAL
Definition: pgstat.h:55
void pgstat_reset_replslot(const char *name)
instr_time pgstat_prepare_io_time(bool track_io_guc)
Definition: pgstat_io.c:90
IOObject
Definition: pgstat.h:273
@ IOOBJECT_RELATION
Definition: pgstat.h:274
@ IOOBJECT_WAL
Definition: pgstat.h:276
@ IOOBJECT_TEMP_RELATION
Definition: pgstat.h:275
void pgstat_count_io_op(IOObject io_object, IOContext io_context, IOOp io_op, uint32 cnt, uint64 bytes)
Definition: pgstat_io.c:68
void AtPrepare_PgStat(void)
Definition: pgstat_xact.c:191
int pgstat_get_transactional_drops(bool isCommit, struct xl_xact_stats_item **items)
Definition: pgstat_xact.c:272
void pgstat_copy_relation_stats(Relation dst, Relation src)
void pgstat_report_vacuum(Oid tableoid, bool shared, PgStat_Counter livetuples, PgStat_Counter deadtuples, TimestampTz starttime)
void pgstat_unlink_relation(Relation rel)
struct PgStat_CheckpointerStats PgStat_CheckpointerStats
void pgstat_reset_slru(const char *)
Definition: pgstat_slru.c:45
PgStat_StatFuncEntry * pgstat_fetch_stat_funcentry(Oid func_id)
void pgstat_count_slru_page_exists(int slru_idx)
Definition: pgstat_slru.c:71
void pgstat_create_subscription(Oid subid)
void pgstat_count_slru_page_read(int slru_idx)
Definition: pgstat_slru.c:77
void pgstat_count_heap_update(Relation rel, bool hot, bool newpage)
void pgstat_count_io_op_time(IOObject io_object, IOContext io_context, IOOp io_op, instr_time start_time, uint32 cnt, uint64 bytes)
Definition: pgstat_io.c:121
PgStat_FetchConsistency
Definition: pgstat.h:45
@ PGSTAT_FETCH_CONSISTENCY_NONE
Definition: pgstat.h:46
@ PGSTAT_FETCH_CONSISTENCY_CACHE
Definition: pgstat.h:47
@ PGSTAT_FETCH_CONSISTENCY_SNAPSHOT
Definition: pgstat.h:48
bool pgstat_tracks_backend_bktype(BackendType bktype)
void pgstat_execute_transactional_drops(int ndrops, struct xl_xact_stats_item *items, bool is_redo)
Definition: pgstat_xact.c:314
void StatsShmemInit(void)
Definition: pgstat_shmem.c:156
void pgstat_reset_counters(void)
Definition: pgstat.c:850
void pgstat_report_subscription_conflict(Oid subid, ConflictType type)
PgStat_IO * pgstat_fetch_stat_io(void)
Definition: pgstat_io.c:163
struct PgStat_StatSubEntry PgStat_StatSubEntry
void AtEOXact_PgStat(bool isCommit, bool parallel)
Definition: pgstat_xact.c:40
int pgstat_get_slru_index(const char *name)
Definition: pgstat_slru.c:132
PgStat_SLRUStats * pgstat_fetch_slru(void)
Definition: pgstat_slru.c:105
void pgstat_count_slru_page_hit(int slru_idx)
Definition: pgstat_slru.c:65
struct PgStat_PendingIO PgStat_PendingIO
const char * pgstat_get_io_context_name(IOContext io_context)
Definition: pgstat_io.c:248
PgStat_StatReplSlotEntry * pgstat_fetch_replslot(NameData slotname)
bool pgstat_tracks_io_bktype(BackendType bktype)
Definition: pgstat_io.c:359
void pgstat_report_subscription_error(Oid subid, bool is_apply_error)
void pgstat_init_function_usage(struct FunctionCallInfoBaseData *fcinfo, PgStat_FunctionCallUsage *fcu)
void pgstat_twophase_postcommit(TransactionId xid, uint16 info, void *recdata, uint32 len)
void pgstat_report_autovac(Oid dboid)
struct PgStat_TableCounts PgStat_TableCounts
void pgstat_prepare_report_checksum_failure(Oid dboid)
void pgstat_report_analyze(Relation rel, PgStat_Counter livetuples, PgStat_Counter deadtuples, bool resetcounter, TimestampTz starttime)
void pgstat_report_connect(Oid dboid)
void pgstat_initialize(void)
Definition: pgstat.c:638
struct PgStat_BackendSubEntry PgStat_BackendSubEntry
void pgstat_count_backend_io_op(IOObject io_object, IOContext io_context, IOOp io_op, uint32 cnt, uint64 bytes)
void pgstat_assoc_relation(Relation rel)
void pgstat_count_slru_page_zeroed(int slru_idx)
Definition: pgstat_slru.c:59
long pgstat_report_stat(bool force)
Definition: pgstat.c:691
struct PgStat_FunctionCallUsage PgStat_FunctionCallUsage
void pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount)
void pgstat_count_slru_truncate(int slru_idx)
Definition: pgstat_slru.c:95
void pgstat_reset_of_kind(PgStat_Kind kind)
Definition: pgstat.c:891
const char * pgstat_get_io_object_name(IOObject io_object)
Definition: pgstat_io.c:269
struct PgStat_SLRUStats PgStat_SLRUStats
PgStat_StatTabEntry * pgstat_fetch_stat_tabentry_ext(bool shared, Oid reloid)
PGDLLIMPORT int pgstat_fetch_consistency
Definition: pgstat.c:204
struct PgStat_BktypeIO PgStat_BktypeIO
#define IOOP_NUM_TYPES
Definition: pgstat.h:316
void pgstat_twophase_postabort(TransactionId xid, uint16 info, void *recdata, uint32 len)
PgStat_StatTabEntry * pgstat_fetch_stat_tabentry(Oid relid)
IOContext
Definition: pgstat.h:282
@ IOCONTEXT_INIT
Definition: pgstat.h:285
@ IOCONTEXT_NORMAL
Definition: pgstat.h:286
@ IOCONTEXT_VACUUM
Definition: pgstat.h:287
@ IOCONTEXT_BULKREAD
Definition: pgstat.h:283
@ IOCONTEXT_BULKWRITE
Definition: pgstat.h:284
#define IOCONTEXT_NUM_TYPES
Definition: pgstat.h:290
void pgstat_before_server_shutdown(int code, Datum arg)
Definition: pgstat.c:559
void pgstat_report_deadlock(void)
void pgstat_acquire_replslot(struct ReplicationSlot *slot)
void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
void pgstat_report_recovery_conflict(int reason)
void pgstat_force_next_flush(void)
Definition: pgstat.c:829
void pgstat_create_function(Oid proid)
TrackFunctionsLevel
Definition: pgstat.h:38
@ TRACK_FUNC_PL
Definition: pgstat.h:40
@ TRACK_FUNC_ALL
Definition: pgstat.h:41
@ TRACK_FUNC_OFF
Definition: pgstat.h:39
const char * pgstat_get_slru_name(int slru_idx)
Definition: pgstat_slru.c:118
void pgstat_count_slru_page_written(int slru_idx)
Definition: pgstat_slru.c:83
struct PgStat_ArchiverStats PgStat_ArchiverStats
PGDLLIMPORT PgStat_Counter pgStatActiveTime
IOOp
Definition: pgstat.h:302
@ IOOP_EXTEND
Definition: pgstat.h:311
@ IOOP_FSYNC
Definition: pgstat.h:305
@ IOOP_READ
Definition: pgstat.h:312
@ IOOP_WRITEBACK
Definition: pgstat.h:308
@ IOOP_HIT
Definition: pgstat.h:306
@ IOOP_EVICT
Definition: pgstat.h:304
@ IOOP_REUSE
Definition: pgstat.h:307
@ IOOP_WRITE
Definition: pgstat.h:313
void pgstat_clear_snapshot(void)
Definition: pgstat.c:917
TimestampTz pgstat_get_stat_snapshot_timestamp(bool *have_snapshot)
Definition: pgstat.c:1045
bool pgstat_bktype_io_stats_valid(PgStat_BktypeIO *backend_io, BackendType bktype)
Definition: pgstat_io.c:37
PGDLLIMPORT PgStat_Counter pgStatBlockWriteTime
Size StatsShmemSize(void)
Definition: pgstat_shmem.c:127
void pgstat_create_relation(Relation rel)
void PostPrepare_PgStat(void)
Definition: pgstat_xact.c:211
PGDLLIMPORT PgStat_BgWriterStats PendingBgWriterStats
struct PgStat_FunctionCounts PgStat_FunctionCounts
bool pgstat_have_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition: pgstat.c:1062
struct PgStat_StatReplSlotEntry PgStat_StatReplSlotEntry
PGDLLIMPORT PgStat_Counter pgStatBlockReadTime
void pgstat_update_heap_dead_tuples(Relation rel, int delta)
void pgstat_report_wal(bool force)
Definition: pgstat_wal.c:46
PgStat_StatSubEntry * pgstat_fetch_stat_subscription(Oid subid)
PgStat_BgWriterStats * pgstat_fetch_stat_bgwriter(void)
PGDLLIMPORT int pgstat_track_functions
void pgstat_count_heap_delete(Relation rel)
void pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
struct PgStat_Backend PgStat_Backend
void pgstat_restore_stats(void)
Definition: pgstat.c:504
struct PgStat_StatDBEntry PgStat_StatDBEntry
PGDLLIMPORT PgStat_CheckpointerStats PendingCheckpointerStats
PgStat_TableStatus * find_tabstat_entry(Oid rel_id)
void pgstat_count_slru_flush(int slru_idx)
Definition: pgstat_slru.c:89
PGDLLIMPORT PgStat_Counter pgStatTransactionIdleTime
PgStat_Backend * pgstat_fetch_stat_backend_by_pid(int pid, BackendType *bktype)
void pgstat_report_checkpointer(void)
void AtEOSubXact_PgStat(bool isCommit, int nestDepth)
Definition: pgstat_xact.c:113
struct PgStat_WalStats PgStat_WalStats
void pgstat_create_replslot(struct ReplicationSlot *slot)
void pgstat_report_replslot(struct ReplicationSlot *slot, const PgStat_StatReplSlotEntry *repSlotStat)
void pgstat_drop_database(Oid databaseid)
void pgstat_count_backend_io_op_time(IOObject io_object, IOContext io_context, IOOp io_op, instr_time io_time)
struct PgStat_BgWriterStats PgStat_BgWriterStats
struct PgStat_StatTabEntry PgStat_StatTabEntry
bool pgstat_tracks_io_op(BackendType bktype, IOObject io_object, IOContext io_context, IOOp io_op)
Definition: pgstat_io.c:485
void pgstat_count_truncate(Relation rel)
void pgstat_drop_replslot(struct ReplicationSlot *slot)
PgStat_ArchiverStats * pgstat_fetch_stat_archiver(void)
PGDLLIMPORT bool pgstat_track_counts
Definition: pgstat.c:203
void pgstat_drop_relation(Relation rel)
PgStat_StatDBEntry * pgstat_fetch_stat_dbentry(Oid dboid)
PgStat_Backend * pgstat_fetch_stat_backend(ProcNumber procNumber)
struct PgStat_WalCounters PgStat_WalCounters
void pgstat_discard_stats(void)
Definition: pgstat.c:516
PgStat_CheckpointerStats * pgstat_fetch_stat_checkpointer(void)
int64 PgStat_Counter
Definition: pgstat.h:65
bool pgstat_tracks_io_object(BackendType bktype, IOObject io_object, IOContext io_context)
Definition: pgstat_io.c:401
PgStat_WalStats * pgstat_fetch_stat_wal(void)
Definition: pgstat_wal.c:67
void pgstat_report_bgwriter(void)
void pgstat_report_archiver(const char *xlog, bool failed)
#define IOOBJECT_NUM_TYPES
Definition: pgstat.h:279
struct PgStat_TableXactStatus PgStat_TableXactStatus
PgStat_Kind pgstat_get_kind_from_str(char *kind_str)
Definition: pgstat.c:1419
struct PgStat_StatFuncEntry PgStat_StatFuncEntry
PGDLLIMPORT SessionEndType pgStatSessionEndCause
PgStat_FunctionCounts * find_funcstat_entry(Oid func_id)
void pgstat_init_relation(Relation rel)
struct PgStat_BackendPending PgStat_BackendPending
struct PgStat_IO PgStat_IO
#define PgStat_Kind
Definition: pgstat_kind.h:17
uintptr_t Datum
Definition: postgres.h:69
unsigned int Oid
Definition: postgres_ext.h:30
int ProcNumber
Definition: procnumber.h:24
TimestampTz last_failed_timestamp
Definition: pgstat.h:225
TimestampTz stat_reset_timestamp
Definition: pgstat.h:226
TimestampTz last_archived_timestamp
Definition: pgstat.h:221
char last_failed_wal[MAX_XFN_CHARS+1]
Definition: pgstat.h:223
PgStat_Counter failed_count
Definition: pgstat.h:222
PgStat_Counter archived_count
Definition: pgstat.h:218
char last_archived_wal[MAX_XFN_CHARS+1]
Definition: pgstat.h:219
PgStat_PendingIO pending_io
Definition: pgstat.h:504
PgStat_Counter apply_error_count
Definition: pgstat.h:109
PgStat_Counter sync_error_count
Definition: pgstat.h:110
PgStat_Counter conflict_count[CONFLICT_NUM_TYPES]
Definition: pgstat.h:111
TimestampTz stat_reset_timestamp
Definition: pgstat.h:490
PgStat_WalCounters wal_counters
Definition: pgstat.h:492
PgStat_BktypeIO io_stats
Definition: pgstat.h:491
PgStat_Counter buf_written_clean
Definition: pgstat.h:239
PgStat_Counter maxwritten_clean
Definition: pgstat.h:240
PgStat_Counter buf_alloc
Definition: pgstat.h:241
TimestampTz stat_reset_timestamp
Definition: pgstat.h:242
PgStat_Counter times[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]
Definition: pgstat.h:326
uint64 bytes[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]
Definition: pgstat.h:324
PgStat_Counter counts[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]
Definition: pgstat.h:325
PgStat_Counter sync_time
Definition: pgstat.h:262
PgStat_Counter restartpoints_requested
Definition: pgstat.h:259
PgStat_Counter write_time
Definition: pgstat.h:261
PgStat_Counter num_requested
Definition: pgstat.h:256
PgStat_Counter num_performed
Definition: pgstat.h:257
PgStat_Counter restartpoints_timed
Definition: pgstat.h:258
PgStat_Counter num_timed
Definition: pgstat.h:255
PgStat_Counter restartpoints_performed
Definition: pgstat.h:260
PgStat_Counter buffers_written
Definition: pgstat.h:263
TimestampTz stat_reset_timestamp
Definition: pgstat.h:265
PgStat_Counter slru_written
Definition: pgstat.h:264
instr_time save_total
Definition: pgstat.h:98
PgStat_FunctionCounts * fs
Definition: pgstat.h:94
instr_time save_f_total_time
Definition: pgstat.h:96
PgStat_Counter numcalls
Definition: pgstat.h:82
instr_time total_time
Definition: pgstat.h:83
instr_time self_time
Definition: pgstat.h:84
PgStat_BktypeIO stats[BACKEND_NUM_TYPES]
Definition: pgstat.h:339
TimestampTz stat_reset_timestamp
Definition: pgstat.h:338
PgStat_Counter counts[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]
Definition: pgstat.h:332
uint64 bytes[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]
Definition: pgstat.h:331
instr_time pending_times[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES]
Definition: pgstat.h:333
PgStat_Counter blocks_read
Definition: pgstat.h:405
PgStat_Counter blocks_exists
Definition: pgstat.h:407
TimestampTz stat_reset_timestamp
Definition: pgstat.h:410
PgStat_Counter blocks_zeroed
Definition: pgstat.h:403
PgStat_Counter blocks_written
Definition: pgstat.h:406
PgStat_Counter blocks_hit
Definition: pgstat.h:404
PgStat_Counter truncate
Definition: pgstat.h:409
PgStat_Counter flush
Definition: pgstat.h:408
PgStat_Counter blk_write_time
Definition: pgstat.h:366
PgStat_Counter xact_rollback
Definition: pgstat.h:345
PgStat_Counter conflict_startup_deadlock
Definition: pgstat.h:359
PgStat_Counter conflict_lock
Definition: pgstat.h:355
PgStat_Counter tuples_updated
Definition: pgstat.h:351
PgStat_Counter parallel_workers_to_launch
Definition: pgstat.h:374
PgStat_Counter tuples_inserted
Definition: pgstat.h:350
TimestampTz stat_reset_timestamp
Definition: pgstat.h:377
PgStat_Counter conflict_snapshot
Definition: pgstat.h:356
PgStat_Counter sessions_fatal
Definition: pgstat.h:372
TimestampTz last_checksum_failure
Definition: pgstat.h:364
PgStat_Counter tuples_returned
Definition: pgstat.h:348
PgStat_Counter blk_read_time
Definition: pgstat.h:365
PgStat_Counter parallel_workers_launched
Definition: pgstat.h:375
PgStat_Counter xact_commit
Definition: pgstat.h:344
TimestampTz last_autovac_time
Definition: pgstat.h:353
PgStat_Counter deadlocks
Definition: pgstat.h:362
PgStat_Counter temp_bytes
Definition: pgstat.h:361
PgStat_Counter session_time
Definition: pgstat.h:368
PgStat_Counter blocks_hit
Definition: pgstat.h:347
PgStat_Counter temp_files
Definition: pgstat.h:360
PgStat_Counter sessions_abandoned
Definition: pgstat.h:371
PgStat_Counter sessions
Definition: pgstat.h:367
PgStat_Counter active_time
Definition: pgstat.h:369
PgStat_Counter blocks_fetched
Definition: pgstat.h:346
PgStat_Counter conflict_bufferpin
Definition: pgstat.h:358
PgStat_Counter idle_in_transaction_time
Definition: pgstat.h:370
PgStat_Counter conflict_logicalslot
Definition: pgstat.h:357
PgStat_Counter tuples_deleted
Definition: pgstat.h:352
PgStat_Counter sessions_killed
Definition: pgstat.h:373
PgStat_Counter tuples_fetched
Definition: pgstat.h:349
PgStat_Counter checksum_failures
Definition: pgstat.h:363
PgStat_Counter conflict_tablespace
Definition: pgstat.h:354
PgStat_Counter self_time
Definition: pgstat.h:385
PgStat_Counter numcalls
Definition: pgstat.h:382
PgStat_Counter total_time
Definition: pgstat.h:384
TimestampTz stat_reset_timestamp
Definition: pgstat.h:398
PgStat_Counter stream_count
Definition: pgstat.h:394
PgStat_Counter total_txns
Definition: pgstat.h:396
PgStat_Counter total_bytes
Definition: pgstat.h:397
PgStat_Counter spill_txns
Definition: pgstat.h:390
PgStat_Counter stream_txns
Definition: pgstat.h:393
PgStat_Counter spill_count
Definition: pgstat.h:391
PgStat_Counter stream_bytes
Definition: pgstat.h:395
PgStat_Counter spill_bytes
Definition: pgstat.h:392
PgStat_Counter apply_error_count
Definition: pgstat.h:415
PgStat_Counter sync_error_count
Definition: pgstat.h:416
PgStat_Counter conflict_count[CONFLICT_NUM_TYPES]
Definition: pgstat.h:417
TimestampTz stat_reset_timestamp
Definition: pgstat.h:418
PgStat_Counter vacuum_count
Definition: pgstat.h:444
PgStat_Counter tuples_fetched
Definition: pgstat.h:427
PgStat_Counter ins_since_vacuum
Definition: pgstat.h:438
PgStat_Counter blocks_hit
Definition: pgstat.h:441
PgStat_Counter mod_since_analyze
Definition: pgstat.h:437
TimestampTz last_autovacuum_time
Definition: pgstat.h:445
PgStat_Counter analyze_count
Definition: pgstat.h:448
PgStat_Counter tuples_deleted
Definition: pgstat.h:431
PgStat_Counter tuples_hot_updated
Definition: pgstat.h:432
PgStat_Counter tuples_updated
Definition: pgstat.h:430
PgStat_Counter live_tuples
Definition: pgstat.h:435
PgStat_Counter numscans
Definition: pgstat.h:423
PgStat_Counter autovacuum_count
Definition: pgstat.h:446
PgStat_Counter total_autovacuum_time
Definition: pgstat.h:453
PgStat_Counter total_analyze_time
Definition: pgstat.h:454
TimestampTz last_analyze_time
Definition: pgstat.h:447
PgStat_Counter dead_tuples
Definition: pgstat.h:436
PgStat_Counter autoanalyze_count
Definition: pgstat.h:450
PgStat_Counter blocks_fetched
Definition: pgstat.h:440
PgStat_Counter tuples_returned
Definition: pgstat.h:426
TimestampTz last_autoanalyze_time
Definition: pgstat.h:449
PgStat_Counter total_autoanalyze_time
Definition: pgstat.h:455
TimestampTz lastscan
Definition: pgstat.h:424
PgStat_Counter tuples_inserted
Definition: pgstat.h:429
PgStat_Counter total_vacuum_time
Definition: pgstat.h:452
PgStat_Counter tuples_newpage_updated
Definition: pgstat.h:433
TimestampTz last_vacuum_time
Definition: pgstat.h:443
PgStat_Counter blocks_hit
Definition: pgstat.h:155
PgStat_Counter numscans
Definition: pgstat.h:138
PgStat_Counter tuples_hot_updated
Definition: pgstat.h:146
PgStat_Counter tuples_returned
Definition: pgstat.h:140
PgStat_Counter tuples_inserted
Definition: pgstat.h:143
PgStat_Counter delta_live_tuples
Definition: pgstat.h:150
PgStat_Counter changed_tuples
Definition: pgstat.h:152
PgStat_Counter tuples_updated
Definition: pgstat.h:144
PgStat_Counter blocks_fetched
Definition: pgstat.h:154
PgStat_Counter tuples_fetched
Definition: pgstat.h:141
PgStat_Counter tuples_newpage_updated
Definition: pgstat.h:147
PgStat_Counter delta_dead_tuples
Definition: pgstat.h:151
PgStat_Counter tuples_deleted
Definition: pgstat.h:145
PgStat_TableCounts counts
Definition: pgstat.h:178
struct PgStat_TableXactStatus * trans
Definition: pgstat.h:177
Relation relation
Definition: pgstat.h:179
struct PgStat_TableXactStatus * next
Definition: pgstat.h:202
PgStat_Counter deleted_pre_truncdrop
Definition: pgstat.h:196
PgStat_TableStatus * parent
Definition: pgstat.h:200
PgStat_Counter tuples_inserted
Definition: pgstat.h:188
PgStat_Counter tuples_updated
Definition: pgstat.h:189
PgStat_Counter inserted_pre_truncdrop
Definition: pgstat.h:194
PgStat_Counter tuples_deleted
Definition: pgstat.h:190
struct PgStat_TableXactStatus * upper
Definition: pgstat.h:199
PgStat_Counter updated_pre_truncdrop
Definition: pgstat.h:195
PgStat_Counter wal_fpi
Definition: pgstat.h:469
uint64 wal_bytes
Definition: pgstat.h:470
PgStat_Counter wal_buffers_full
Definition: pgstat.h:471
PgStat_Counter wal_records
Definition: pgstat.h:468
TimestampTz stat_reset_timestamp
Definition: pgstat.h:481
PgStat_WalCounters wal_counters
Definition: pgstat.h:480
Definition: c.h:712
static ItemArray items
Definition: test_tidstore.c:48
const char * type
const char * name