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-2022, 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"
15 #include "portability/instr_time.h"
16 #include "postmaster/pgarch.h" /* for MAX_XFN_CHARS */
17 #include "utils/backend_progress.h" /* for backward compatibility */
18 #include "utils/backend_status.h" /* for backward compatibility */
19 #include "utils/relcache.h"
20 #include "utils/wait_event.h" /* for backward compatibility */
21 
22 
23 /* ----------
24  * Paths for the statistics files (relative to installation's $PGDATA).
25  * ----------
26  */
27 #define PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat"
28 #define PGSTAT_STAT_PERMANENT_FILENAME "pg_stat/pgstat.stat"
29 #define PGSTAT_STAT_PERMANENT_TMPFILE "pg_stat/pgstat.tmp"
30 
31 /* Default directory to store temporary statistics data in */
32 #define PG_STAT_TMP_DIR "pg_stat_tmp"
33 
34 /* The types of statistics entries */
35 typedef enum PgStat_Kind
36 {
37  /* use 0 for INVALID, to catch zero-initialized data */
39 
40  /* stats for variable-numbered objects */
41  PGSTAT_KIND_DATABASE, /* database-wide statistics */
42  PGSTAT_KIND_RELATION, /* per-table statistics */
43  PGSTAT_KIND_FUNCTION, /* per-function statistics */
44  PGSTAT_KIND_REPLSLOT, /* per-slot statistics */
45  PGSTAT_KIND_SUBSCRIPTION, /* per-subscription statistics */
46 
47  /* stats for fixed-numbered objects */
54 
55 #define PGSTAT_KIND_FIRST_VALID PGSTAT_KIND_DATABASE
56 #define PGSTAT_KIND_LAST PGSTAT_KIND_WAL
57 #define PGSTAT_NUM_KINDS (PGSTAT_KIND_LAST + 1)
58 
59 /* Values for track_functions GUC variable --- order is significant! */
60 typedef enum TrackFunctionsLevel
61 {
66 
68 {
73 
74 /* Values to track the cause of session termination */
75 typedef enum SessionEndType
76 {
77  DISCONNECT_NOT_YET, /* still active */
83 
84 /* ----------
85  * The data type used for counters.
86  * ----------
87  */
88 typedef int64 PgStat_Counter;
89 
90 
91 /* ------------------------------------------------------------
92  * Structures kept in backend local memory while accumulating counts
93  * ------------------------------------------------------------
94  */
95 
96 /* ----------
97  * PgStat_FunctionCounts The actual per-function counts kept by a backend
98  *
99  * This struct should contain only actual event counters, because we memcmp
100  * it against zeroes to detect whether there are any pending stats.
101  *
102  * Note that the time counters are in instr_time format here. We convert to
103  * microseconds in PgStat_Counter format when flushing out pending statistics.
104  * ----------
105  */
106 typedef struct PgStat_FunctionCounts
107 {
112 
113 /* ----------
114  * PgStat_BackendFunctionEntry Non-flushed function stats.
115  * ----------
116  */
118 {
121 
122 /*
123  * Working state needed to accumulate per-function-call timing statistics.
124  */
126 {
127  /* Link to function's hashtable entry (must still be there at exit!) */
128  /* NULL means we are not tracking the current function call */
130  /* Total time previously charged to function, as of function start */
132  /* Backend-wide total time as of function start */
134  /* system clock as of function start */
137 
138 /* ----------
139  * PgStat_BackendSubEntry Non-flushed subscription stats.
140  * ----------
141  */
143 {
147 
148 /* ----------
149  * PgStat_TableCounts The actual per-table counts kept by a backend
150  *
151  * This struct should contain only actual event counters, because we memcmp
152  * it against zeroes to detect whether there are any stats updates to apply.
153  * It is a component of PgStat_TableStatus (within-backend state).
154  *
155  * Note: for a table, tuples_returned is the number of tuples successfully
156  * fetched by heap_getnext, while tuples_fetched is the number of tuples
157  * successfully fetched by heap_fetch under the control of bitmap indexscans.
158  * For an index, tuples_returned is the number of index entries returned by
159  * the index AM, while tuples_fetched is the number of tuples successfully
160  * fetched by heap_fetch under the control of simple indexscans for this index.
161  *
162  * tuples_inserted/updated/deleted/hot_updated count attempted actions,
163  * regardless of whether the transaction committed. delta_live_tuples,
164  * delta_dead_tuples, and changed_tuples are set depending on commit or abort.
165  * Note that delta_live_tuples and delta_dead_tuples can be negative!
166  * ----------
167  */
168 typedef struct PgStat_TableCounts
169 {
171 
174 
180 
184 
188 
189 /* ----------
190  * PgStat_TableStatus Per-table status within a backend
191  *
192  * Many of the event counters are nontransactional, ie, we count events
193  * in committed and aborted transactions alike. For these, we just count
194  * directly in the PgStat_TableStatus. However, delta_live_tuples,
195  * delta_dead_tuples, and changed_tuples must be derived from event counts
196  * with awareness of whether the transaction or subtransaction committed or
197  * aborted. Hence, we also keep a stack of per-(sub)transaction status
198  * records for every table modified in the current transaction. At commit
199  * or abort, we propagate tuples_inserted/updated/deleted up to the
200  * parent subtransaction level, or out to the parent PgStat_TableStatus,
201  * as appropriate.
202  * ----------
203  */
204 typedef struct PgStat_TableStatus
205 {
206  Oid t_id; /* table's OID */
207  bool t_shared; /* is it a shared catalog? */
208  struct PgStat_TableXactStatus *trans; /* lowest subxact's counts */
209  PgStat_TableCounts t_counts; /* event counts to be sent */
210  Relation relation; /* rel that is using this entry */
212 
213 /* ----------
214  * PgStat_TableXactStatus Per-table, per-subtransaction status
215  * ----------
216  */
218 {
219  PgStat_Counter tuples_inserted; /* tuples inserted in (sub)xact */
220  PgStat_Counter tuples_updated; /* tuples updated in (sub)xact */
221  PgStat_Counter tuples_deleted; /* tuples deleted in (sub)xact */
222  bool truncdropped; /* relation truncated/dropped in this
223  * (sub)xact */
224  /* tuples i/u/d prior to truncate/drop */
228  int nest_level; /* subtransaction nest level */
229  /* links to other structs for same relation: */
230  struct PgStat_TableXactStatus *upper; /* next higher subxact if any */
231  PgStat_TableStatus *parent; /* per-table status */
232  /* structs of same subxact level are linked here: */
233  struct PgStat_TableXactStatus *next; /* next of same subxact */
235 
236 
237 /* ------------------------------------------------------------
238  * Data structures on disk and in shared memory follow
239  *
240  * PGSTAT_FILE_FORMAT_ID should be changed whenever any of these
241  * data structures change.
242  * ------------------------------------------------------------
243  */
244 
245 #define PGSTAT_FILE_FORMAT_ID 0x01A5BCA7
246 
247 typedef struct PgStat_ArchiverStats
248 {
249  PgStat_Counter archived_count; /* archival successes */
250  char last_archived_wal[MAX_XFN_CHARS + 1]; /* last WAL file
251  * archived */
252  TimestampTz last_archived_timestamp; /* last archival success time */
253  PgStat_Counter failed_count; /* failed archival attempts */
254  char last_failed_wal[MAX_XFN_CHARS + 1]; /* WAL file involved in
255  * last failure */
256  TimestampTz last_failed_timestamp; /* last archival failure time */
259 
260 typedef struct PgStat_BgWriterStats
261 {
267 
269 {
272  PgStat_Counter checkpoint_write_time; /* times in milliseconds */
278 
279 typedef struct PgStat_StatDBEntry
280 {
301  PgStat_Counter n_block_read_time; /* times in microseconds */
310 
313 
314 typedef struct PgStat_StatFuncEntry
315 {
317 
318  PgStat_Counter f_total_time; /* times in microseconds */
321 
323 {
335 
336 typedef struct PgStat_SLRUStats
337 {
347 
348 typedef struct PgStat_StatSubEntry
349 {
354 
355 typedef struct PgStat_StatTabEntry
356 {
358 
361 
366 
371 
374 
375  TimestampTz vacuum_timestamp; /* user initiated vacuum */
377  TimestampTz autovac_vacuum_timestamp; /* autovacuum initiated */
379  TimestampTz analyze_timestamp; /* user initiated */
381  TimestampTz autovac_analyze_timestamp; /* autovacuum initiated */
384 
385 typedef struct PgStat_WalStats
386 {
389  uint64 wal_bytes;
397 
398 
399 /*
400  * Functions in pgstat.c
401  */
402 
403 /* functions called from postmaster */
404 extern Size StatsShmemSize(void);
405 extern void StatsShmemInit(void);
406 
407 /* Functions called during server startup / shutdown */
408 extern void pgstat_restore_stats(void);
409 extern void pgstat_discard_stats(void);
410 extern void pgstat_before_server_shutdown(int code, Datum arg);
411 
412 /* Functions for backend initialization */
413 extern void pgstat_initialize(void);
414 
415 /* Functions called from backends */
416 extern long pgstat_report_stat(bool force);
417 extern void pgstat_force_next_flush(void);
418 
419 extern void pgstat_reset_counters(void);
420 extern void pgstat_reset(PgStat_Kind kind, Oid dboid, Oid objectid);
421 extern void pgstat_reset_of_kind(PgStat_Kind kind);
422 
423 /* stats accessors */
424 extern void pgstat_clear_snapshot(void);
425 extern TimestampTz pgstat_get_stat_snapshot_timestamp(bool *have_snapshot);
426 
427 /* helpers */
428 extern PgStat_Kind pgstat_get_kind_from_str(char *kind_str);
429 extern bool pgstat_have_entry(PgStat_Kind kind, Oid dboid, Oid objoid);
430 
431 
432 /*
433  * Functions in pgstat_archiver.c
434  */
435 
436 extern void pgstat_report_archiver(const char *xlog, bool failed);
438 
439 
440 /*
441  * Functions in pgstat_bgwriter.c
442  */
443 
444 extern void pgstat_report_bgwriter(void);
446 
447 
448 /*
449  * Functions in pgstat_checkpointer.c
450  */
451 
452 extern void pgstat_report_checkpointer(void);
454 
455 
456 /*
457  * Functions in pgstat_database.c
458  */
459 
460 extern void pgstat_drop_database(Oid databaseid);
461 extern void pgstat_report_autovac(Oid dboid);
462 extern void pgstat_report_recovery_conflict(int reason);
463 extern void pgstat_report_deadlock(void);
464 extern void pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount);
465 extern void pgstat_report_checksum_failure(void);
466 extern void pgstat_report_connect(Oid dboid);
467 
468 #define pgstat_count_buffer_read_time(n) \
469  (pgStatBlockReadTime += (n))
470 #define pgstat_count_buffer_write_time(n) \
471  (pgStatBlockWriteTime += (n))
472 #define pgstat_count_conn_active_time(n) \
473  (pgStatActiveTime += (n))
474 #define pgstat_count_conn_txn_idle_time(n) \
475  (pgStatTransactionIdleTime += (n))
476 
478 
479 /*
480  * Functions in pgstat_function.c
481  */
482 
483 extern void pgstat_create_function(Oid proid);
484 extern void pgstat_drop_function(Oid proid);
485 
490  bool finalize);
491 
494 
495 
496 /*
497  * Functions in pgstat_relation.c
498  */
499 
500 extern void pgstat_create_relation(Relation rel);
501 extern void pgstat_drop_relation(Relation rel);
502 extern void pgstat_copy_relation_stats(Relation dstrel, Relation srcrel);
503 
504 extern void pgstat_init_relation(Relation rel);
505 extern void pgstat_assoc_relation(Relation rel);
506 extern void pgstat_unlink_relation(Relation rel);
507 
508 extern void pgstat_report_vacuum(Oid tableoid, bool shared,
509  PgStat_Counter livetuples, PgStat_Counter deadtuples);
510 extern void pgstat_report_analyze(Relation rel,
511  PgStat_Counter livetuples, PgStat_Counter deadtuples,
512  bool resetcounter);
513 
514 /*
515  * If stats are enabled, but pending data hasn't been prepared yet, call
516  * pgstat_assoc_relation() to do so. See its comment for why this is done
517  * separately from pgstat_init_relation().
518  */
519 #define pgstat_should_count_relation(rel) \
520  (likely((rel)->pgstat_info != NULL) ? true : \
521  ((rel)->pgstat_enabled ? pgstat_assoc_relation(rel), true : false))
522 
523 /* nontransactional event counts are simple enough to inline */
524 
525 #define pgstat_count_heap_scan(rel) \
526  do { \
527  if (pgstat_should_count_relation(rel)) \
528  (rel)->pgstat_info->t_counts.t_numscans++; \
529  } while (0)
530 #define pgstat_count_heap_getnext(rel) \
531  do { \
532  if (pgstat_should_count_relation(rel)) \
533  (rel)->pgstat_info->t_counts.t_tuples_returned++; \
534  } while (0)
535 #define pgstat_count_heap_fetch(rel) \
536  do { \
537  if (pgstat_should_count_relation(rel)) \
538  (rel)->pgstat_info->t_counts.t_tuples_fetched++; \
539  } while (0)
540 #define pgstat_count_index_scan(rel) \
541  do { \
542  if (pgstat_should_count_relation(rel)) \
543  (rel)->pgstat_info->t_counts.t_numscans++; \
544  } while (0)
545 #define pgstat_count_index_tuples(rel, n) \
546  do { \
547  if (pgstat_should_count_relation(rel)) \
548  (rel)->pgstat_info->t_counts.t_tuples_returned += (n); \
549  } while (0)
550 #define pgstat_count_buffer_read(rel) \
551  do { \
552  if (pgstat_should_count_relation(rel)) \
553  (rel)->pgstat_info->t_counts.t_blocks_fetched++; \
554  } while (0)
555 #define pgstat_count_buffer_hit(rel) \
556  do { \
557  if (pgstat_should_count_relation(rel)) \
558  (rel)->pgstat_info->t_counts.t_blocks_hit++; \
559  } while (0)
560 
562 extern void pgstat_count_heap_update(Relation rel, bool hot);
563 extern void pgstat_count_heap_delete(Relation rel);
564 extern void pgstat_count_truncate(Relation rel);
565 extern void pgstat_update_heap_dead_tuples(Relation rel, int delta);
566 
567 extern void pgstat_twophase_postcommit(TransactionId xid, uint16 info,
568  void *recdata, uint32 len);
569 extern void pgstat_twophase_postabort(TransactionId xid, uint16 info,
570  void *recdata, uint32 len);
571 
574  Oid relid);
576 
577 
578 /*
579  * Functions in pgstat_replslot.c
580  */
581 
582 extern void pgstat_reset_replslot(const char *name);
583 struct ReplicationSlot;
584 extern void pgstat_report_replslot(struct ReplicationSlot *slot, const PgStat_StatReplSlotEntry *repSlotStat);
585 extern void pgstat_create_replslot(struct ReplicationSlot *slot);
586 extern void pgstat_acquire_replslot(struct ReplicationSlot *slot);
587 extern void pgstat_drop_replslot(struct ReplicationSlot *slot);
589 
590 
591 /*
592  * Functions in pgstat_slru.c
593  */
594 
595 extern void pgstat_reset_slru(const char *);
596 extern void pgstat_count_slru_page_zeroed(int slru_idx);
597 extern void pgstat_count_slru_page_hit(int slru_idx);
598 extern void pgstat_count_slru_page_read(int slru_idx);
599 extern void pgstat_count_slru_page_written(int slru_idx);
600 extern void pgstat_count_slru_page_exists(int slru_idx);
601 extern void pgstat_count_slru_flush(int slru_idx);
602 extern void pgstat_count_slru_truncate(int slru_idx);
603 extern const char *pgstat_get_slru_name(int slru_idx);
604 extern int pgstat_get_slru_index(const char *name);
605 extern PgStat_SLRUStats *pgstat_fetch_slru(void);
606 
607 
608 /*
609  * Functions in pgstat_subscription.c
610  */
611 
612 extern void pgstat_report_subscription_error(Oid subid, bool is_apply_error);
613 extern void pgstat_create_subscription(Oid subid);
614 extern void pgstat_drop_subscription(Oid subid);
616 
617 
618 /*
619  * Functions in pgstat_xact.c
620  */
621 
622 extern void AtEOXact_PgStat(bool isCommit, bool parallel);
623 extern void AtEOSubXact_PgStat(bool isCommit, int nestDepth);
624 extern void AtPrepare_PgStat(void);
625 extern void PostPrepare_PgStat(void);
626 struct xl_xact_stats_item;
627 extern int pgstat_get_transactional_drops(bool isCommit, struct xl_xact_stats_item **items);
628 extern void pgstat_execute_transactional_drops(int ndrops, struct xl_xact_stats_item *items, bool is_redo);
629 
630 
631 /*
632  * Functions in pgstat_wal.c
633  */
634 
635 extern void pgstat_report_wal(bool force);
637 
638 
639 /*
640  * Variables in pgstat.c
641  */
642 
643 /* GUC parameters */
644 extern PGDLLIMPORT bool pgstat_track_counts;
647 
648 
649 /*
650  * Variables in pgstat_bgwriter.c
651  */
652 
653 /* updated directly by bgwriter and bufmgr */
655 
656 
657 /*
658  * Variables in pgstat_checkpointer.c
659  */
660 
661 /*
662  * Checkpointer statistics counters are updated directly by checkpointer and
663  * bufmgr.
664  */
666 
667 
668 /*
669  * Variables in pgstat_database.c
670  */
671 
672 /* Updated by pgstat_count_buffer_*_time macros */
675 
676 /*
677  * Updated by pgstat_count_conn_*_time macros, called by
678  * pgstat_report_activity().
679  */
682 
683 /* updated by the traffic cop and in errfinish() */
685 
686 
687 /*
688  * Variables in pgstat_wal.c
689  */
690 
691 /* updated directly by backends and background processes */
693 
694 
695 #endif /* PGSTAT_H */
unsigned short uint16
Definition: c.h:440
unsigned int uint32
Definition: c.h:441
#define PGDLLIMPORT
Definition: c.h:1331
uint32 TransactionId
Definition: c.h:587
size_t Size
Definition: c.h:540
int64 TimestampTz
Definition: timestamp.h:39
const char * name
Definition: encode.c:561
struct timeval instr_time
Definition: instr_time.h:150
void * arg
const void size_t len
#define MAX_XFN_CHARS
Definition: pgarch.h:26
void pgstat_drop_function(Oid proid)
void pgstat_drop_subscription(Oid subid)
struct PgStat_TableStatus PgStat_TableStatus
SessionEndType
Definition: pgstat.h:76
@ DISCONNECT_NOT_YET
Definition: pgstat.h:77
@ DISCONNECT_FATAL
Definition: pgstat.h:80
@ DISCONNECT_KILLED
Definition: pgstat.h:81
@ DISCONNECT_CLIENT_EOF
Definition: pgstat.h:79
@ DISCONNECT_NORMAL
Definition: pgstat.h:78
void pgstat_reset_replslot(const char *name)
void pgstat_reset(PgStat_Kind kind, Oid dboid, Oid objectid)
Definition: pgstat.c:704
PGDLLIMPORT PgStat_WalStats PendingWalStats
Definition: pgstat_wal.c:24
void AtPrepare_PgStat(void)
Definition: pgstat_xact.c:196
int pgstat_get_transactional_drops(bool isCommit, struct xl_xact_stats_item **items)
Definition: pgstat_xact.c:278
void pgstat_unlink_relation(Relation rel)
struct PgStat_CheckpointerStats PgStat_CheckpointerStats
void pgstat_reset_slru(const char *)
Definition: pgstat_slru.c:45
PgStat_Kind
Definition: pgstat.h:36
@ PGSTAT_KIND_DATABASE
Definition: pgstat.h:41
@ PGSTAT_KIND_REPLSLOT
Definition: pgstat.h:44
@ PGSTAT_KIND_ARCHIVER
Definition: pgstat.h:48
@ PGSTAT_KIND_SLRU
Definition: pgstat.h:51
@ PGSTAT_KIND_BGWRITER
Definition: pgstat.h:49
@ PGSTAT_KIND_INVALID
Definition: pgstat.h:38
@ PGSTAT_KIND_SUBSCRIPTION
Definition: pgstat.h:45
@ PGSTAT_KIND_CHECKPOINTER
Definition: pgstat.h:50
@ PGSTAT_KIND_FUNCTION
Definition: pgstat.h:43
@ PGSTAT_KIND_WAL
Definition: pgstat.h:52
@ PGSTAT_KIND_RELATION
Definition: pgstat.h:42
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
PgStat_FetchConsistency
Definition: pgstat.h:68
@ PGSTAT_FETCH_CONSISTENCY_NONE
Definition: pgstat.h:69
@ PGSTAT_FETCH_CONSISTENCY_CACHE
Definition: pgstat.h:70
@ PGSTAT_FETCH_CONSISTENCY_SNAPSHOT
Definition: pgstat.h:71
void pgstat_execute_transactional_drops(int ndrops, struct xl_xact_stats_item *items, bool is_redo)
Definition: pgstat_xact.c:320
void StatsShmemInit(void)
Definition: pgstat_shmem.c:140
void pgstat_reset_counters(void)
Definition: pgstat.c:685
struct PgStat_StatSubEntry PgStat_StatSubEntry
PgStat_BgWriterStats * pgstat_fetch_stat_bgwriter(void)
PgStat_StatSubEntry * pgstat_fetch_stat_subscription(Oid subid)
void AtEOXact_PgStat(bool isCommit, bool parallel)
Definition: pgstat_xact.c:41
int pgstat_get_slru_index(const char *name)
Definition: pgstat_slru.c:132
void pgstat_count_slru_page_hit(int slru_idx)
Definition: pgstat_slru.c:65
void pgstat_count_heap_update(Relation rel, bool hot)
void pgstat_report_subscription_error(Oid subid, bool is_apply_error)
void pgstat_init_function_usage(struct FunctionCallInfoBaseData *fcinfo, PgStat_FunctionCallUsage *fcu)
PgStat_StatTabEntry * pgstat_fetch_stat_tabentry_ext(bool shared, Oid relid)
void pgstat_twophase_postcommit(TransactionId xid, uint16 info, void *recdata, uint32 len)
void pgstat_report_autovac(Oid dboid)
struct PgStat_TableCounts PgStat_TableCounts
PgStat_TableStatus * find_tabstat_entry(Oid rel_id)
void pgstat_report_connect(Oid dboid)
void pgstat_initialize(void)
Definition: pgstat.c:522
bool pgstat_have_entry(PgStat_Kind kind, Oid dboid, Oid objoid)
Definition: pgstat.c:882
struct PgStat_BackendSubEntry PgStat_BackendSubEntry
PgStat_StatDBEntry * pgstat_fetch_stat_dbentry(Oid dbid)
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:564
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_report_checksum_failure(void)
void pgstat_reset_of_kind(PgStat_Kind kind)
Definition: pgstat.c:726
void pgstat_report_analyze(Relation rel, PgStat_Counter livetuples, PgStat_Counter deadtuples, bool resetcounter)
struct PgStat_SLRUStats PgStat_SLRUStats
PGDLLIMPORT int pgstat_fetch_consistency
Definition: pgstat.c:186
PgStat_StatFuncEntry * pgstat_fetch_stat_funcentry(Oid funcid)
void pgstat_twophase_postabort(TransactionId xid, uint16 info, void *recdata, uint32 len)
void pgstat_before_server_shutdown(int code, Datum arg)
Definition: pgstat.c:447
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:664
void pgstat_create_function(Oid proid)
TrackFunctionsLevel
Definition: pgstat.h:61
@ TRACK_FUNC_PL
Definition: pgstat.h:63
@ TRACK_FUNC_ALL
Definition: pgstat.h:64
@ TRACK_FUNC_OFF
Definition: pgstat.h:62
void pgstat_count_slru_page_written(int slru_idx)
Definition: pgstat_slru.c:83
struct PgStat_ArchiverStats PgStat_ArchiverStats
PGDLLIMPORT PgStat_Counter pgStatActiveTime
PgStat_SLRUStats * pgstat_fetch_slru(void)
Definition: pgstat_slru.c:105
void pgstat_clear_snapshot(void)
Definition: pgstat.c:751
const char * pgstat_get_slru_name(int slru_idx)
Definition: pgstat_slru.c:118
TimestampTz pgstat_get_stat_snapshot_timestamp(bool *have_snapshot)
Definition: pgstat.c:868
PGDLLIMPORT PgStat_Counter pgStatBlockWriteTime
Size StatsShmemSize(void)
Definition: pgstat_shmem.c:126
void pgstat_create_relation(Relation rel)
void PostPrepare_PgStat(void)
Definition: pgstat_xact.c:216
PGDLLIMPORT PgStat_BgWriterStats PendingBgWriterStats
struct PgStat_FunctionCounts PgStat_FunctionCounts
struct PgStat_StatReplSlotEntry PgStat_StatReplSlotEntry
PGDLLIMPORT PgStat_Counter pgStatBlockReadTime
PgStat_StatTabEntry * pgstat_fetch_stat_tabentry(Oid relid)
void pgstat_update_heap_dead_tuples(Relation rel, int delta)
void pgstat_report_wal(bool force)
Definition: pgstat_wal.c:43
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:392
struct PgStat_StatDBEntry PgStat_StatDBEntry
PGDLLIMPORT PgStat_CheckpointerStats PendingCheckpointerStats
void pgstat_count_slru_flush(int slru_idx)
Definition: pgstat_slru.c:89
PGDLLIMPORT PgStat_Counter pgStatTransactionIdleTime
PgStat_StatReplSlotEntry * pgstat_fetch_replslot(NameData slotname)
void pgstat_report_checkpointer(void)
void AtEOSubXact_PgStat(bool isCommit, int nestDepth)
Definition: pgstat_xact.c:117
struct PgStat_WalStats PgStat_WalStats
void pgstat_create_replslot(struct ReplicationSlot *slot)
void pgstat_report_replslot(struct ReplicationSlot *slot, const PgStat_StatReplSlotEntry *repSlotStat)
PgStat_WalStats * pgstat_fetch_stat_wal(void)
Definition: pgstat_wal.c:53
void pgstat_drop_database(Oid databaseid)
void pgstat_report_vacuum(Oid tableoid, bool shared, PgStat_Counter livetuples, PgStat_Counter deadtuples)
struct PgStat_BackendFunctionEntry PgStat_BackendFunctionEntry
struct PgStat_BgWriterStats PgStat_BgWriterStats
struct PgStat_StatTabEntry PgStat_StatTabEntry
void pgstat_count_truncate(Relation rel)
void pgstat_drop_replslot(struct ReplicationSlot *slot)
PGDLLIMPORT bool pgstat_track_counts
Definition: pgstat.c:185
void pgstat_drop_relation(Relation rel)
void pgstat_discard_stats(void)
Definition: pgstat.c:404
int64 PgStat_Counter
Definition: pgstat.h:88
void pgstat_report_bgwriter(void)
PgStat_CheckpointerStats * pgstat_fetch_stat_checkpointer(void)
PgStat_BackendFunctionEntry * find_funcstat_entry(Oid func_id)
void pgstat_report_archiver(const char *xlog, bool failed)
struct PgStat_TableXactStatus PgStat_TableXactStatus
PgStat_Kind pgstat_get_kind_from_str(char *kind_str)
Definition: pgstat.c:1189
void pgstat_copy_relation_stats(Relation dstrel, Relation srcrel)
struct PgStat_StatFuncEntry PgStat_StatFuncEntry
PGDLLIMPORT SessionEndType pgStatSessionEndCause
PgStat_ArchiverStats * pgstat_fetch_stat_archiver(void)
void pgstat_init_relation(Relation rel)
uintptr_t Datum
Definition: postgres.h:411
unsigned int Oid
Definition: postgres_ext.h:31
TimestampTz last_failed_timestamp
Definition: pgstat.h:256
TimestampTz stat_reset_timestamp
Definition: pgstat.h:257
TimestampTz last_archived_timestamp
Definition: pgstat.h:252
char last_failed_wal[MAX_XFN_CHARS+1]
Definition: pgstat.h:254
PgStat_Counter failed_count
Definition: pgstat.h:253
PgStat_Counter archived_count
Definition: pgstat.h:249
char last_archived_wal[MAX_XFN_CHARS+1]
Definition: pgstat.h:250
PgStat_FunctionCounts f_counts
Definition: pgstat.h:119
PgStat_Counter apply_error_count
Definition: pgstat.h:144
PgStat_Counter sync_error_count
Definition: pgstat.h:145
PgStat_Counter buf_written_clean
Definition: pgstat.h:262
PgStat_Counter maxwritten_clean
Definition: pgstat.h:263
PgStat_Counter buf_alloc
Definition: pgstat.h:264
TimestampTz stat_reset_timestamp
Definition: pgstat.h:265
PgStat_Counter buf_written_backend
Definition: pgstat.h:275
PgStat_Counter checkpoint_sync_time
Definition: pgstat.h:273
PgStat_Counter checkpoint_write_time
Definition: pgstat.h:272
PgStat_Counter requested_checkpoints
Definition: pgstat.h:271
PgStat_Counter timed_checkpoints
Definition: pgstat.h:270
PgStat_Counter buf_fsync_backend
Definition: pgstat.h:276
PgStat_Counter buf_written_checkpoints
Definition: pgstat.h:274
instr_time save_total
Definition: pgstat.h:133
PgStat_FunctionCounts * fs
Definition: pgstat.h:129
instr_time f_start
Definition: pgstat.h:135
instr_time save_f_total_time
Definition: pgstat.h:131
instr_time f_total_time
Definition: pgstat.h:109
PgStat_Counter f_numcalls
Definition: pgstat.h:108
instr_time f_self_time
Definition: pgstat.h:110
PgStat_Counter blocks_read
Definition: pgstat.h:340
PgStat_Counter blocks_exists
Definition: pgstat.h:342
TimestampTz stat_reset_timestamp
Definition: pgstat.h:345
PgStat_Counter blocks_zeroed
Definition: pgstat.h:338
PgStat_Counter blocks_written
Definition: pgstat.h:341
PgStat_Counter blocks_hit
Definition: pgstat.h:339
PgStat_Counter truncate
Definition: pgstat.h:344
PgStat_Counter flush
Definition: pgstat.h:343
PgStat_Counter n_sessions_killed
Definition: pgstat.h:309
PgStat_Counter total_session_time
Definition: pgstat.h:304
TimestampTz stat_reset_timestamp
Definition: pgstat.h:311
TimestampTz last_checksum_failure
Definition: pgstat.h:300
PgStat_Counter n_sessions_fatal
Definition: pgstat.h:308
PgStat_Counter total_idle_in_xact_time
Definition: pgstat.h:306
PgStat_Counter n_temp_bytes
Definition: pgstat.h:297
PgStat_Counter n_tuples_deleted
Definition: pgstat.h:289
PgStat_Counter n_xact_commit
Definition: pgstat.h:281
PgStat_Counter n_tuples_updated
Definition: pgstat.h:288
TimestampTz last_autovac_time
Definition: pgstat.h:290
PgStat_Counter n_xact_rollback
Definition: pgstat.h:282
PgStat_Counter n_conflict_lock
Definition: pgstat.h:292
PgStat_Counter total_active_time
Definition: pgstat.h:305
PgStat_Counter n_checksum_failures
Definition: pgstat.h:299
PgStat_Counter n_blocks_fetched
Definition: pgstat.h:283
PgStat_Counter n_deadlocks
Definition: pgstat.h:298
PgStat_Counter n_tuples_fetched
Definition: pgstat.h:286
PgStat_Counter n_block_read_time
Definition: pgstat.h:301
PgStat_Counter n_sessions
Definition: pgstat.h:303
PgStat_Counter n_conflict_tablespace
Definition: pgstat.h:291
PgStat_Counter n_sessions_abandoned
Definition: pgstat.h:307
PgStat_Counter n_block_write_time
Definition: pgstat.h:302
PgStat_Counter n_conflict_bufferpin
Definition: pgstat.h:294
PgStat_Counter n_tuples_inserted
Definition: pgstat.h:287
PgStat_Counter n_tuples_returned
Definition: pgstat.h:285
PgStat_Counter n_blocks_hit
Definition: pgstat.h:284
PgStat_Counter n_conflict_startup_deadlock
Definition: pgstat.h:295
PgStat_Counter n_temp_files
Definition: pgstat.h:296
PgStat_Counter n_conflict_snapshot
Definition: pgstat.h:293
PgStat_Counter f_self_time
Definition: pgstat.h:319
PgStat_Counter f_total_time
Definition: pgstat.h:318
PgStat_Counter f_numcalls
Definition: pgstat.h:316
TimestampTz stat_reset_timestamp
Definition: pgstat.h:333
PgStat_Counter stream_count
Definition: pgstat.h:329
PgStat_Counter total_txns
Definition: pgstat.h:331
PgStat_Counter total_bytes
Definition: pgstat.h:332
PgStat_Counter spill_txns
Definition: pgstat.h:325
PgStat_Counter stream_txns
Definition: pgstat.h:328
PgStat_Counter spill_count
Definition: pgstat.h:326
PgStat_Counter stream_bytes
Definition: pgstat.h:330
PgStat_Counter spill_bytes
Definition: pgstat.h:327
PgStat_Counter apply_error_count
Definition: pgstat.h:350
PgStat_Counter sync_error_count
Definition: pgstat.h:351
TimestampTz stat_reset_timestamp
Definition: pgstat.h:352
PgStat_Counter vacuum_count
Definition: pgstat.h:376
PgStat_Counter tuples_fetched
Definition: pgstat.h:360
TimestampTz vacuum_timestamp
Definition: pgstat.h:375
PgStat_Counter blocks_hit
Definition: pgstat.h:373
PgStat_Counter analyze_count
Definition: pgstat.h:380
TimestampTz autovac_analyze_timestamp
Definition: pgstat.h:381
PgStat_Counter tuples_deleted
Definition: pgstat.h:364
PgStat_Counter autovac_analyze_count
Definition: pgstat.h:382
PgStat_Counter tuples_hot_updated
Definition: pgstat.h:365
PgStat_Counter tuples_updated
Definition: pgstat.h:363
PgStat_Counter changes_since_analyze
Definition: pgstat.h:369
PgStat_Counter inserts_since_vacuum
Definition: pgstat.h:370
PgStat_Counter autovac_vacuum_count
Definition: pgstat.h:378
PgStat_Counter numscans
Definition: pgstat.h:357
PgStat_Counter blocks_fetched
Definition: pgstat.h:372
PgStat_Counter tuples_returned
Definition: pgstat.h:359
TimestampTz analyze_timestamp
Definition: pgstat.h:379
PgStat_Counter n_live_tuples
Definition: pgstat.h:367
TimestampTz autovac_vacuum_timestamp
Definition: pgstat.h:377
PgStat_Counter n_dead_tuples
Definition: pgstat.h:368
PgStat_Counter tuples_inserted
Definition: pgstat.h:362
PgStat_Counter t_delta_dead_tuples
Definition: pgstat.h:182
PgStat_Counter t_delta_live_tuples
Definition: pgstat.h:181
PgStat_Counter t_tuples_hot_updated
Definition: pgstat.h:178
PgStat_Counter t_tuples_inserted
Definition: pgstat.h:175
PgStat_Counter t_tuples_updated
Definition: pgstat.h:176
PgStat_Counter t_tuples_fetched
Definition: pgstat.h:173
PgStat_Counter t_tuples_deleted
Definition: pgstat.h:177
PgStat_Counter t_numscans
Definition: pgstat.h:170
PgStat_Counter t_blocks_hit
Definition: pgstat.h:186
bool t_truncdropped
Definition: pgstat.h:179
PgStat_Counter t_changed_tuples
Definition: pgstat.h:183
PgStat_Counter t_blocks_fetched
Definition: pgstat.h:185
PgStat_Counter t_tuples_returned
Definition: pgstat.h:172
PgStat_TableCounts t_counts
Definition: pgstat.h:209
struct PgStat_TableXactStatus * trans
Definition: pgstat.h:208
Relation relation
Definition: pgstat.h:210
struct PgStat_TableXactStatus * next
Definition: pgstat.h:233
PgStat_Counter deleted_pre_truncdrop
Definition: pgstat.h:227
PgStat_TableStatus * parent
Definition: pgstat.h:231
PgStat_Counter tuples_inserted
Definition: pgstat.h:219
PgStat_Counter tuples_updated
Definition: pgstat.h:220
PgStat_Counter inserted_pre_truncdrop
Definition: pgstat.h:225
PgStat_Counter tuples_deleted
Definition: pgstat.h:221
struct PgStat_TableXactStatus * upper
Definition: pgstat.h:230
PgStat_Counter updated_pre_truncdrop
Definition: pgstat.h:226
PgStat_Counter wal_write
Definition: pgstat.h:391
PgStat_Counter wal_buffers_full
Definition: pgstat.h:390
PgStat_Counter wal_write_time
Definition: pgstat.h:393
TimestampTz stat_reset_timestamp
Definition: pgstat.h:395
uint64 wal_bytes
Definition: pgstat.h:389
PgStat_Counter wal_sync_time
Definition: pgstat.h:394
PgStat_Counter wal_fpi
Definition: pgstat.h:388
PgStat_Counter wal_sync
Definition: pgstat.h:392
PgStat_Counter wal_records
Definition: pgstat.h:387
Definition: c.h:676