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