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