PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pgstat.h
Go to the documentation of this file.
1 /* ----------
2  * pgstat.h
3  *
4  * Definitions for the PostgreSQL statistics collector daemon.
5  *
6  * Copyright (c) 2001-2017, 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 "fmgr.h"
16 #include "libpq/pqcomm.h"
17 #include "port/atomics.h"
18 #include "portability/instr_time.h"
19 #include "postmaster/pgarch.h"
20 #include "storage/proc.h"
21 #include "utils/hsearch.h"
22 #include "utils/relcache.h"
23 
24 
25 /* ----------
26  * Paths for the statistics files (relative to installation's $PGDATA).
27  * ----------
28  */
29 #define PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat"
30 #define PGSTAT_STAT_PERMANENT_FILENAME "pg_stat/global.stat"
31 #define PGSTAT_STAT_PERMANENT_TMPFILE "pg_stat/global.tmp"
32 
33 /* Default directory to store temporary statistics data in */
34 #define PG_STAT_TMP_DIR "pg_stat_tmp"
35 
36 /* Values for track_functions GUC variable --- order is significant! */
37 typedef enum TrackFunctionsLevel
38 {
43 
44 /* ----------
45  * The types of backend -> collector messages
46  * ----------
47  */
48 typedef enum StatMsgType
49 {
68 } StatMsgType;
69 
70 /* ----------
71  * The data type used for counters.
72  * ----------
73  */
74 typedef int64 PgStat_Counter;
75 
76 /* ----------
77  * PgStat_TableCounts The actual per-table counts kept by a backend
78  *
79  * This struct should contain only actual event counters, because we memcmp
80  * it against zeroes to detect whether there are any counts to transmit.
81  * It is a component of PgStat_TableStatus (within-backend state) and
82  * PgStat_TableEntry (the transmitted message format).
83  *
84  * Note: for a table, tuples_returned is the number of tuples successfully
85  * fetched by heap_getnext, while tuples_fetched is the number of tuples
86  * successfully fetched by heap_fetch under the control of bitmap indexscans.
87  * For an index, tuples_returned is the number of index entries returned by
88  * the index AM, while tuples_fetched is the number of tuples successfully
89  * fetched by heap_fetch under the control of simple indexscans for this index.
90  *
91  * tuples_inserted/updated/deleted/hot_updated count attempted actions,
92  * regardless of whether the transaction committed. delta_live_tuples,
93  * delta_dead_tuples, and changed_tuples are set depending on commit or abort.
94  * Note that delta_live_tuples and delta_dead_tuples can be negative!
95  * ----------
96  */
97 typedef struct PgStat_TableCounts
98 {
100 
103 
109 
113 
117 
118 /* Possible targets for resetting cluster-wide shared values */
120 {
124 
125 /* Possible object types for resetting single counters */
127 {
131 
132 /* ------------------------------------------------------------
133  * Structures kept in backend local memory while accumulating counts
134  * ------------------------------------------------------------
135  */
136 
137 
138 /* ----------
139  * PgStat_TableStatus Per-table status within a backend
140  *
141  * Many of the event counters are nontransactional, ie, we count events
142  * in committed and aborted transactions alike. For these, we just count
143  * directly in the PgStat_TableStatus. However, delta_live_tuples,
144  * delta_dead_tuples, and changed_tuples must be derived from event counts
145  * with awareness of whether the transaction or subtransaction committed or
146  * aborted. Hence, we also keep a stack of per-(sub)transaction status
147  * records for every table modified in the current transaction. At commit
148  * or abort, we propagate tuples_inserted/updated/deleted up to the
149  * parent subtransaction level, or out to the parent PgStat_TableStatus,
150  * as appropriate.
151  * ----------
152  */
153 typedef struct PgStat_TableStatus
154 {
155  Oid t_id; /* table's OID */
156  bool t_shared; /* is it a shared catalog? */
157  struct PgStat_TableXactStatus *trans; /* lowest subxact's counts */
158  PgStat_TableCounts t_counts; /* event counts to be sent */
160 
161 /* ----------
162  * PgStat_TableXactStatus Per-table, per-subtransaction status
163  * ----------
164  */
166 {
167  PgStat_Counter tuples_inserted; /* tuples inserted in (sub)xact */
168  PgStat_Counter tuples_updated; /* tuples updated in (sub)xact */
169  PgStat_Counter tuples_deleted; /* tuples deleted in (sub)xact */
170  bool truncated; /* relation truncated in this (sub)xact */
171  PgStat_Counter inserted_pre_trunc; /* tuples inserted prior to truncate */
172  PgStat_Counter updated_pre_trunc; /* tuples updated prior to truncate */
173  PgStat_Counter deleted_pre_trunc; /* tuples deleted prior to truncate */
174  int nest_level; /* subtransaction nest level */
175  /* links to other structs for same relation: */
176  struct PgStat_TableXactStatus *upper; /* next higher subxact if any */
177  PgStat_TableStatus *parent; /* per-table status */
178  /* structs of same subxact level are linked here: */
179  struct PgStat_TableXactStatus *next; /* next of same subxact */
181 
182 
183 /* ------------------------------------------------------------
184  * Message formats follow
185  * ------------------------------------------------------------
186  */
187 
188 
189 /* ----------
190  * PgStat_MsgHdr The common message header
191  * ----------
192  */
193 typedef struct PgStat_MsgHdr
194 {
196  int m_size;
197 } PgStat_MsgHdr;
198 
199 /* ----------
200  * Space available in a message. This will keep the UDP packets below 1K,
201  * which should fit unfragmented into the MTU of the loopback interface.
202  * (Larger values of PGSTAT_MAX_MSG_SIZE would work for that on most
203  * platforms, but we're being conservative here.)
204  * ----------
205  */
206 #define PGSTAT_MAX_MSG_SIZE 1000
207 #define PGSTAT_MSG_PAYLOAD (PGSTAT_MAX_MSG_SIZE - sizeof(PgStat_MsgHdr))
208 
209 
210 /* ----------
211  * PgStat_MsgDummy A dummy message, ignored by the collector
212  * ----------
213  */
214 typedef struct PgStat_MsgDummy
215 {
218 
219 
220 /* ----------
221  * PgStat_MsgInquiry Sent by a backend to ask the collector
222  * to write the stats file(s).
223  *
224  * Ordinarily, an inquiry message prompts writing of the global stats file,
225  * the stats file for shared catalogs, and the stats file for the specified
226  * database. If databaseid is InvalidOid, only the first two are written.
227  *
228  * New file(s) will be written only if the existing file has a timestamp
229  * older than the specified cutoff_time; this prevents duplicated effort
230  * when multiple requests arrive at nearly the same time, assuming that
231  * backends send requests with cutoff_times a little bit in the past.
232  *
233  * clock_time should be the requestor's current local time; the collector
234  * uses this to check for the system clock going backward, but it has no
235  * effect unless that occurs. We assume clock_time >= cutoff_time, though.
236  * ----------
237  */
238 
239 typedef struct PgStat_MsgInquiry
240 {
242  TimestampTz clock_time; /* observed local clock time */
243  TimestampTz cutoff_time; /* minimum acceptable file timestamp */
244  Oid databaseid; /* requested DB (InvalidOid => shared only) */
246 
247 
248 /* ----------
249  * PgStat_TableEntry Per-table info in a MsgTabstat
250  * ----------
251  */
252 typedef struct PgStat_TableEntry
253 {
257 
258 /* ----------
259  * PgStat_MsgTabstat Sent by the backend to report table
260  * and buffer access statistics.
261  * ----------
262  */
263 #define PGSTAT_NUM_TABENTRIES \
264  ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - 3 * sizeof(int) - 2 * sizeof(PgStat_Counter)) \
265  / sizeof(PgStat_TableEntry))
266 
267 typedef struct PgStat_MsgTabstat
268 {
274  PgStat_Counter m_block_read_time; /* times in microseconds */
278 
279 
280 /* ----------
281  * PgStat_MsgTabpurge Sent by the backend to tell the collector
282  * about dead tables.
283  * ----------
284  */
285 #define PGSTAT_NUM_TABPURGE \
286  ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int)) \
287  / sizeof(Oid))
288 
289 typedef struct PgStat_MsgTabpurge
290 {
296 
297 
298 /* ----------
299  * PgStat_MsgDropdb Sent by the backend to tell the collector
300  * about a dropped database
301  * ----------
302  */
303 typedef struct PgStat_MsgDropdb
304 {
308 
309 
310 /* ----------
311  * PgStat_MsgResetcounter Sent by the backend to tell the collector
312  * to reset counters
313  * ----------
314  */
316 {
320 
321 /* ----------
322  * PgStat_MsgResetsharedcounter Sent by the backend to tell the collector
323  * to reset a shared counter
324  * ----------
325  */
327 {
331 
332 /* ----------
333  * PgStat_MsgResetsinglecounter Sent by the backend to tell the collector
334  * to reset a single counter
335  * ----------
336  */
338 {
344 
345 /* ----------
346  * PgStat_MsgAutovacStart Sent by the autovacuum daemon to signal
347  * that a database is going to be processed
348  * ----------
349  */
351 {
356 
357 
358 /* ----------
359  * PgStat_MsgVacuum Sent by the backend or autovacuum daemon
360  * after VACUUM
361  * ----------
362  */
363 typedef struct PgStat_MsgVacuum
364 {
373 
374 
375 /* ----------
376  * PgStat_MsgAnalyze Sent by the backend or autovacuum daemon
377  * after ANALYZE
378  * ----------
379  */
380 typedef struct PgStat_MsgAnalyze
381 {
391 
392 
393 /* ----------
394  * PgStat_MsgArchiver Sent by the archiver to update statistics.
395  * ----------
396  */
397 typedef struct PgStat_MsgArchiver
398 {
400  bool m_failed; /* Failed attempt */
404 
405 /* ----------
406  * PgStat_MsgBgWriter Sent by the bgwriter to update statistics.
407  * ----------
408  */
409 typedef struct PgStat_MsgBgWriter
410 {
412 
421  PgStat_Counter m_checkpoint_write_time; /* times in milliseconds */
424 
425 /* ----------
426  * PgStat_MsgRecoveryConflict Sent by the backend upon recovery conflict
427  * ----------
428  */
430 {
432 
434  int m_reason;
436 
437 /* ----------
438  * PgStat_MsgTempFile Sent by the backend upon creating a temp file
439  * ----------
440  */
441 typedef struct PgStat_MsgTempFile
442 {
444 
446  size_t m_filesize;
448 
449 /* ----------
450  * PgStat_FunctionCounts The actual per-function counts kept by a backend
451  *
452  * This struct should contain only actual event counters, because we memcmp
453  * it against zeroes to detect whether there are any counts to transmit.
454  *
455  * Note that the time counters are in instr_time format here. We convert to
456  * microseconds in PgStat_Counter format when transmitting to the collector.
457  * ----------
458  */
459 typedef struct PgStat_FunctionCounts
460 {
465 
466 /* ----------
467  * PgStat_BackendFunctionEntry Entry in backend's per-function hash table
468  * ----------
469  */
471 {
475 
476 /* ----------
477  * PgStat_FunctionEntry Per-function info in a MsgFuncstat
478  * ----------
479  */
480 typedef struct PgStat_FunctionEntry
481 {
484  PgStat_Counter f_total_time; /* times in microseconds */
487 
488 /* ----------
489  * PgStat_MsgFuncstat Sent by the backend to report function
490  * usage statistics.
491  * ----------
492  */
493 #define PGSTAT_NUM_FUNCENTRIES \
494  ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int)) \
495  / sizeof(PgStat_FunctionEntry))
496 
497 typedef struct PgStat_MsgFuncstat
498 {
504 
505 /* ----------
506  * PgStat_MsgFuncpurge Sent by the backend to tell the collector
507  * about dead functions.
508  * ----------
509  */
510 #define PGSTAT_NUM_FUNCPURGE \
511  ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int)) \
512  / sizeof(Oid))
513 
514 typedef struct PgStat_MsgFuncpurge
515 {
521 
522 /* ----------
523  * PgStat_MsgDeadlock Sent by the backend to tell the collector
524  * about a deadlock that occurred.
525  * ----------
526  */
527 typedef struct PgStat_MsgDeadlock
528 {
532 
533 
534 /* ----------
535  * PgStat_Msg Union over all possible messages.
536  * ----------
537  */
538 typedef union PgStat_Msg
539 {
558 } PgStat_Msg;
559 
560 
561 /* ------------------------------------------------------------
562  * Statistic collector data structures follow
563  *
564  * PGSTAT_FILE_FORMAT_ID should be changed whenever any of these
565  * data structures change.
566  * ------------------------------------------------------------
567  */
568 
569 #define PGSTAT_FILE_FORMAT_ID 0x01A5BC9D
570 
571 /* ----------
572  * PgStat_StatDBEntry The collector's data per database
573  * ----------
574  */
575 typedef struct PgStat_StatDBEntry
576 {
596  PgStat_Counter n_block_read_time; /* times in microseconds */
598 
600  TimestampTz stats_timestamp; /* time of db stats file update */
601 
602  /*
603  * tables and functions must be last in the struct, because we don't write
604  * the pointers out to the stats file.
605  */
609 
610 
611 /* ----------
612  * PgStat_StatTabEntry The collector's data per table (or index)
613  * ----------
614  */
615 typedef struct PgStat_StatTabEntry
616 {
618 
620 
623 
628 
632 
635 
636  TimestampTz vacuum_timestamp; /* user initiated vacuum */
638  TimestampTz autovac_vacuum_timestamp; /* autovacuum initiated */
640  TimestampTz analyze_timestamp; /* user initiated */
642  TimestampTz autovac_analyze_timestamp; /* autovacuum initiated */
645 
646 
647 /* ----------
648  * PgStat_StatFuncEntry The collector's data per function
649  * ----------
650  */
651 typedef struct PgStat_StatFuncEntry
652 {
654 
656 
657  PgStat_Counter f_total_time; /* times in microseconds */
660 
661 
662 /*
663  * Archiver statistics kept in the stats collector
664  */
665 typedef struct PgStat_ArchiverStats
666 {
667  PgStat_Counter archived_count; /* archival successes */
668  char last_archived_wal[MAX_XFN_CHARS + 1]; /* last WAL file
669  * archived */
670  TimestampTz last_archived_timestamp; /* last archival success time */
671  PgStat_Counter failed_count; /* failed archival attempts */
672  char last_failed_wal[MAX_XFN_CHARS + 1]; /* WAL file involved in
673  * last failure */
674  TimestampTz last_failed_timestamp; /* last archival failure time */
677 
678 /*
679  * Global statistics kept in the stats collector
680  */
681 typedef struct PgStat_GlobalStats
682 {
683  TimestampTz stats_timestamp; /* time of stats file update */
686  PgStat_Counter checkpoint_write_time; /* times in milliseconds */
696 
697 
698 /* ----------
699  * Backend types
700  * ----------
701  */
702 typedef enum BackendType
703 {
714 } BackendType;
715 
716 
717 /* ----------
718  * Backend states
719  * ----------
720  */
721 typedef enum BackendState
722 {
730 } BackendState;
731 
732 
733 /* ----------
734  * Wait Classes
735  * ----------
736  */
737 #define PG_WAIT_LWLOCK 0x01000000U
738 #define PG_WAIT_LOCK 0x03000000U
739 #define PG_WAIT_BUFFER_PIN 0x04000000U
740 #define PG_WAIT_ACTIVITY 0x05000000U
741 #define PG_WAIT_CLIENT 0x06000000U
742 #define PG_WAIT_EXTENSION 0x07000000U
743 #define PG_WAIT_IPC 0x08000000U
744 #define PG_WAIT_TIMEOUT 0x09000000U
745 #define PG_WAIT_IO 0x0A000000U
746 
747 /* ----------
748  * Wait Events - Activity
749  *
750  * Use this category when a process is waiting because it has no work to do,
751  * unless the "Client" or "Timeout" category describes the situation better.
752  * Typically, this should only be used for background processes.
753  * ----------
754  */
755 typedef enum
756 {
772 
773 /* ----------
774  * Wait Events - Client
775  *
776  * Use this category when a process is waiting to send data to or receive data
777  * from the frontend process to which it is connected. This is never used for
778  * a background process, which has no client connection.
779  * ----------
780  */
781 typedef enum
782 {
791 
792 /* ----------
793  * Wait Events - IPC
794  *
795  * Use this category when a process cannot complete the work it is doing because
796  * it is waiting for a notification from another process.
797  * ----------
798  */
799 typedef enum
800 {
816 } WaitEventIPC;
817 
818 /* ----------
819  * Wait Events - Timeout
820  *
821  * Use this category when a process is waiting for a timeout to expire.
822  * ----------
823  */
824 typedef enum
825 {
830 
831 /* ----------
832  * Wait Events - IO
833  *
834  * Use this category when a process is waiting for a IO.
835  * ----------
836  */
837 typedef enum
838 {
906 } WaitEventIO;
907 
908 /* ----------
909  * Command type for progress reporting purposes
910  * ----------
911  */
913 {
917 
918 #define PGSTAT_NUM_PROGRESS_PARAM 10
919 
920 /* ----------
921  * Shared-memory data structures
922  * ----------
923  */
924 
925 
926 /*
927  * PgBackendSSLStatus
928  *
929  * For each backend, we keep the SSL status in a separate struct, that
930  * is only filled in if SSL is enabled.
931  */
932 typedef struct PgBackendSSLStatus
933 {
934  /* Information about SSL connection */
935  int ssl_bits;
937  char ssl_version[NAMEDATALEN]; /* MUST be null-terminated */
938  char ssl_cipher[NAMEDATALEN]; /* MUST be null-terminated */
939  char ssl_clientdn[NAMEDATALEN]; /* MUST be null-terminated */
941 
942 
943 /* ----------
944  * PgBackendStatus
945  *
946  * Each live backend maintains a PgBackendStatus struct in shared memory
947  * showing its current activity. (The structs are allocated according to
948  * BackendId, but that is not critical.) Note that the collector process
949  * has no involvement in, or even access to, these structs.
950  *
951  * Each auxiliary process also maintains a PgBackendStatus struct in shared
952  * memory.
953  * ----------
954  */
955 typedef struct PgBackendStatus
956 {
957  /*
958  * To avoid locking overhead, we use the following protocol: a backend
959  * increments st_changecount before modifying its entry, and again after
960  * finishing a modification. A would-be reader should note the value of
961  * st_changecount, copy the entry into private memory, then check
962  * st_changecount again. If the value hasn't changed, and if it's even,
963  * the copy is valid; otherwise start over. This makes updates cheap
964  * while reads are potentially expensive, but that's the tradeoff we want.
965  *
966  * The above protocol needs the memory barriers to ensure that the
967  * apparent order of execution is as it desires. Otherwise, for example,
968  * the CPU might rearrange the code so that st_changecount is incremented
969  * twice before the modification on a machine with weak memory ordering.
970  * This surprising result can lead to bugs.
971  */
973 
974  /* The entry is valid iff st_procpid > 0, unused if st_procpid == 0 */
976 
977  /* Type of backends */
979 
980  /* Times when current backend, transaction, and activity started */
985 
986  /* Database OID, owning user's OID, connection client address */
990  char *st_clienthostname; /* MUST be null-terminated */
991 
992  /* Information about SSL connection */
993  bool st_ssl;
995 
996  /* current state */
998 
999  /* application name; MUST be null-terminated */
1000  char *st_appname;
1001 
1002  /* current command string; MUST be null-terminated */
1004 
1005  /*
1006  * Command progress reporting. Any command which wishes can advertise
1007  * that it is running by setting st_progress_command,
1008  * st_progress_command_target, and st_progress_param[].
1009  * st_progress_command_target should be the OID of the relation which the
1010  * command targets (we assume there's just one, as this is meant for
1011  * utility commands), but the meaning of each element in the
1012  * st_progress_param array is command-specific.
1013  */
1017 } PgBackendStatus;
1018 
1019 /*
1020  * Macros to load and store st_changecount with the memory barriers.
1021  *
1022  * pgstat_increment_changecount_before() and
1023  * pgstat_increment_changecount_after() need to be called before and after
1024  * PgBackendStatus entries are modified, respectively. This makes sure that
1025  * st_changecount is incremented around the modification.
1026  *
1027  * Also pgstat_save_changecount_before() and pgstat_save_changecount_after()
1028  * need to be called before and after PgBackendStatus entries are copied into
1029  * private memory, respectively.
1030  */
1031 #define pgstat_increment_changecount_before(beentry) \
1032  do { \
1033  beentry->st_changecount++; \
1034  pg_write_barrier(); \
1035  } while (0)
1036 
1037 #define pgstat_increment_changecount_after(beentry) \
1038  do { \
1039  pg_write_barrier(); \
1040  beentry->st_changecount++; \
1041  Assert((beentry->st_changecount & 1) == 0); \
1042  } while (0)
1043 
1044 #define pgstat_save_changecount_before(beentry, save_changecount) \
1045  do { \
1046  save_changecount = beentry->st_changecount; \
1047  pg_read_barrier(); \
1048  } while (0)
1049 
1050 #define pgstat_save_changecount_after(beentry, save_changecount) \
1051  do { \
1052  pg_read_barrier(); \
1053  save_changecount = beentry->st_changecount; \
1054  } while (0)
1055 
1056 /* ----------
1057  * LocalPgBackendStatus
1058  *
1059  * When we build the backend status array, we use LocalPgBackendStatus to be
1060  * able to add new values to the struct when needed without adding new fields
1061  * to the shared memory. It contains the backend status as a first member.
1062  * ----------
1063  */
1064 typedef struct LocalPgBackendStatus
1065 {
1066  /*
1067  * Local version of the backend status entry.
1068  */
1070 
1071  /*
1072  * The xid of the current transaction if available, InvalidTransactionId
1073  * if not.
1074  */
1076 
1077  /*
1078  * The xmin of the current session if available, InvalidTransactionId if
1079  * not.
1080  */
1083 
1084 /*
1085  * Working state needed to accumulate per-function-call timing statistics.
1086  */
1088 {
1089  /* Link to function's hashtable entry (must still be there at exit!) */
1090  /* NULL means we are not tracking the current function call */
1092  /* Total time previously charged to function, as of function start */
1094  /* Backend-wide total time as of function start */
1096  /* system clock as of function start */
1099 
1100 
1101 /* ----------
1102  * GUC parameters
1103  * ----------
1104  */
1105 extern bool pgstat_track_activities;
1106 extern bool pgstat_track_counts;
1107 extern int pgstat_track_functions;
1109 extern char *pgstat_stat_directory;
1110 extern char *pgstat_stat_tmpname;
1111 extern char *pgstat_stat_filename;
1112 
1113 /*
1114  * BgWriter statistics counters are updated directly by bgwriter and bufmgr
1115  */
1117 
1118 /*
1119  * Updated by pgstat_count_buffer_*_time macros
1120  */
1123 
1124 /* ----------
1125  * Functions called from postmaster
1126  * ----------
1127  */
1128 extern Size BackendStatusShmemSize(void);
1129 extern void CreateSharedBackendStatus(void);
1130 
1131 extern void pgstat_init(void);
1132 extern int pgstat_start(void);
1133 extern void pgstat_reset_all(void);
1134 extern void allow_immediate_pgstat_restart(void);
1135 
1136 #ifdef EXEC_BACKEND
1137 extern void PgstatCollectorMain(int argc, char *argv[]) pg_attribute_noreturn();
1138 #endif
1139 
1140 
1141 /* ----------
1142  * Functions called from backends
1143  * ----------
1144  */
1145 extern void pgstat_ping(void);
1146 
1147 extern void pgstat_report_stat(bool force);
1148 extern void pgstat_vacuum_stat(void);
1149 extern void pgstat_drop_database(Oid databaseid);
1150 
1151 extern void pgstat_clear_snapshot(void);
1152 extern void pgstat_reset_counters(void);
1153 extern void pgstat_reset_shared_counters(const char *);
1154 extern void pgstat_reset_single_counter(Oid objectid, PgStat_Single_Reset_Type type);
1155 
1156 extern void pgstat_report_autovac(Oid dboid);
1157 extern void pgstat_report_vacuum(Oid tableoid, bool shared,
1158  PgStat_Counter livetuples, PgStat_Counter deadtuples);
1159 extern void pgstat_report_analyze(Relation rel,
1160  PgStat_Counter livetuples, PgStat_Counter deadtuples,
1161  bool resetcounter);
1162 
1163 extern void pgstat_report_recovery_conflict(int reason);
1164 extern void pgstat_report_deadlock(void);
1165 
1166 extern void pgstat_initialize(void);
1167 extern void pgstat_bestart(void);
1168 
1169 extern void pgstat_report_activity(BackendState state, const char *cmd_str);
1170 extern void pgstat_report_tempfile(size_t filesize);
1171 extern void pgstat_report_appname(const char *appname);
1172 extern void pgstat_report_xact_timestamp(TimestampTz tstamp);
1173 extern const char *pgstat_get_wait_event(uint32 wait_event_info);
1174 extern const char *pgstat_get_wait_event_type(uint32 wait_event_info);
1175 extern const char *pgstat_get_backend_current_activity(int pid, bool checkUser);
1176 extern const char *pgstat_get_crashed_backend_activity(int pid, char *buffer,
1177  int buflen);
1178 extern const char *pgstat_get_backend_desc(BackendType backendType);
1179 
1181  Oid relid);
1182 extern void pgstat_progress_update_param(int index, int64 val);
1183 extern void pgstat_progress_update_multi_param(int nparam, const int *index,
1184  const int64 *val);
1185 extern void pgstat_progress_end_command(void);
1186 
1187 extern PgStat_TableStatus *find_tabstat_entry(Oid rel_id);
1189 
1190 extern void pgstat_initstats(Relation rel);
1191 
1192 /* ----------
1193  * pgstat_report_wait_start() -
1194  *
1195  * Called from places where server process needs to wait. This is called
1196  * to report wait event information. The wait information is stored
1197  * as 4-bytes where first byte represents the wait event class (type of
1198  * wait, for different types of wait, refer WaitClass) and the next
1199  * 3-bytes represent the actual wait event. Currently 2-bytes are used
1200  * for wait event which is sufficient for current usage, 1-byte is
1201  * reserved for future usage.
1202  *
1203  * NB: this *must* be able to survive being called before MyProc has been
1204  * initialized.
1205  * ----------
1206  */
1207 static inline void
1209 {
1210  volatile PGPROC *proc = MyProc;
1211 
1212  if (!pgstat_track_activities || !proc)
1213  return;
1214 
1215  /*
1216  * Since this is a four-byte field which is always read and written as
1217  * four-bytes, updates are atomic.
1218  */
1219  proc->wait_event_info = wait_event_info;
1220 }
1221 
1222 /* ----------
1223  * pgstat_report_wait_end() -
1224  *
1225  * Called to report end of a wait.
1226  *
1227  * NB: this *must* be able to survive being called before MyProc has been
1228  * initialized.
1229  * ----------
1230  */
1231 static inline void
1233 {
1234  volatile PGPROC *proc = MyProc;
1235 
1236  if (!pgstat_track_activities || !proc)
1237  return;
1238 
1239  /*
1240  * Since this is a four-byte field which is always read and written as
1241  * four-bytes, updates are atomic.
1242  */
1243  proc->wait_event_info = 0;
1244 }
1245 
1246 /* nontransactional event counts are simple enough to inline */
1247 
1248 #define pgstat_count_heap_scan(rel) \
1249  do { \
1250  if ((rel)->pgstat_info != NULL) \
1251  (rel)->pgstat_info->t_counts.t_numscans++; \
1252  } while (0)
1253 #define pgstat_count_heap_getnext(rel) \
1254  do { \
1255  if ((rel)->pgstat_info != NULL) \
1256  (rel)->pgstat_info->t_counts.t_tuples_returned++; \
1257  } while (0)
1258 #define pgstat_count_heap_fetch(rel) \
1259  do { \
1260  if ((rel)->pgstat_info != NULL) \
1261  (rel)->pgstat_info->t_counts.t_tuples_fetched++; \
1262  } while (0)
1263 #define pgstat_count_index_scan(rel) \
1264  do { \
1265  if ((rel)->pgstat_info != NULL) \
1266  (rel)->pgstat_info->t_counts.t_numscans++; \
1267  } while (0)
1268 #define pgstat_count_index_tuples(rel, n) \
1269  do { \
1270  if ((rel)->pgstat_info != NULL) \
1271  (rel)->pgstat_info->t_counts.t_tuples_returned += (n); \
1272  } while (0)
1273 #define pgstat_count_buffer_read(rel) \
1274  do { \
1275  if ((rel)->pgstat_info != NULL) \
1276  (rel)->pgstat_info->t_counts.t_blocks_fetched++; \
1277  } while (0)
1278 #define pgstat_count_buffer_hit(rel) \
1279  do { \
1280  if ((rel)->pgstat_info != NULL) \
1281  (rel)->pgstat_info->t_counts.t_blocks_hit++; \
1282  } while (0)
1283 #define pgstat_count_buffer_read_time(n) \
1284  (pgStatBlockReadTime += (n))
1285 #define pgstat_count_buffer_write_time(n) \
1286  (pgStatBlockWriteTime += (n))
1287 
1289 extern void pgstat_count_heap_update(Relation rel, bool hot);
1290 extern void pgstat_count_heap_delete(Relation rel);
1291 extern void pgstat_count_truncate(Relation rel);
1292 extern void pgstat_update_heap_dead_tuples(Relation rel, int delta);
1293 
1297  bool finalize);
1298 
1299 extern void AtEOXact_PgStat(bool isCommit);
1300 extern void AtEOSubXact_PgStat(bool isCommit, int nestDepth);
1301 
1302 extern void AtPrepare_PgStat(void);
1303 extern void PostPrepare_PgStat(void);
1304 
1305 extern void pgstat_twophase_postcommit(TransactionId xid, uint16 info,
1306  void *recdata, uint32 len);
1307 extern void pgstat_twophase_postabort(TransactionId xid, uint16 info,
1308  void *recdata, uint32 len);
1309 
1310 extern void pgstat_send_archiver(const char *xlog, bool failed);
1311 extern void pgstat_send_bgwriter(void);
1312 
1313 /* ----------
1314  * Support functions for the SQL-callable functions to
1315  * generate the pgstat* views.
1316  * ----------
1317  */
1320 extern PgBackendStatus *pgstat_fetch_stat_beentry(int beid);
1323 extern int pgstat_fetch_stat_numbackends(void);
1326 
1327 #endif /* PGSTAT_H */
bool ssl_compression
Definition: pgstat.h:936
BackendType
Definition: pgstat.h:702
void pgstat_count_truncate(Relation rel)
Definition: pgstat.c:2008
PgStat_MsgBgWriter msg_bgwriter
Definition: pgstat.h:553
PgStat_Counter m_buf_fsync_backend
Definition: pgstat.h:419
PgStat_ArchiverStats * pgstat_fetch_stat_archiver(void)
Definition: pgstat.c:2559
void pgstat_initialize(void)
Definition: pgstat.c:2745
PgStat_Counter analyze_count
Definition: pgstat.h:641
char ssl_cipher[NAMEDATALEN]
Definition: pgstat.h:938
char last_failed_wal[MAX_XFN_CHARS+1]
Definition: pgstat.h:672
instr_time f_self_time
Definition: pgstat.h:463
char m_xlog[MAX_XFN_CHARS+1]
Definition: pgstat.h:401
int pgstat_start(void)
Definition: pgstat.c:727
const char * pgstat_get_backend_desc(BackendType backendType)
Definition: pgstat.c:4024
PgStat_Counter buf_alloc
Definition: pgstat.h:693
PgStat_Counter archived_count
Definition: pgstat.h:667
void pgstat_ping(void)
Definition: pgstat.c:1546
PgStat_Counter m_buf_written_checkpoints
Definition: pgstat.h:415
PgStat_Counter m_buf_alloc
Definition: pgstat.h:420
struct PgStat_MsgFuncpurge PgStat_MsgFuncpurge
PgStat_Counter t_delta_live_tuples
Definition: pgstat.h:110
Oid st_progress_command_target
Definition: pgstat.h:1015
PgStat_Counter m_dead_tuples
Definition: pgstat.h:371
void pgstat_clear_snapshot(void)
Definition: pgstat.c:5540
int64 PgStat_Counter
Definition: pgstat.h:74
PgStat_Counter m_checkpoint_write_time
Definition: pgstat.h:421
TimestampTz m_vacuumtime
Definition: pgstat.h:369
PgStat_Counter tuples_updated
Definition: pgstat.h:168
void pgstat_report_xact_timestamp(TimestampTz tstamp)
Definition: pgstat.c:3192
const char * pgstat_get_backend_current_activity(int pid, bool checkUser)
Definition: pgstat.c:3891
NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]) pg_attribute_noreturn()
Definition: pgstat.c:4178
PgStat_Counter tuples_returned
Definition: pgstat.h:621
PgStat_MsgDeadlock msg_deadlock
Definition: pgstat.h:557
uint32 TransactionId
Definition: c.h:397
PgStat_MsgResetsharedcounter msg_resetsharedcounter
Definition: pgstat.h:547
union PgStat_Msg PgStat_Msg
TimestampTz stats_timestamp
Definition: pgstat.h:600
uint32 wait_event_info
Definition: proc.h:172
WaitEventIPC
Definition: pgstat.h:799
void pgstat_progress_update_param(int index, int64 val)
Definition: pgstat.c:3089
TrackFunctionsLevel
Definition: pgstat.h:37
PgStat_Counter t_tuples_fetched
Definition: pgstat.h:102
PgStat_MsgHdr m_hdr
Definition: pgstat.h:443
PgStat_Counter m_live_tuples
Definition: pgstat.h:370
TimestampTz clock_time
Definition: pgstat.h:242
TimestampTz st_activity_start_timestamp
Definition: pgstat.h:983
instr_time save_total
Definition: pgstat.h:1095
PgStat_Counter n_blocks_hit
Definition: pgstat.h:581
PGPROC * MyProc
Definition: proc.c:67
int64 TimestampTz
Definition: timestamp.h:39
#define PGSTAT_NUM_TABPURGE
Definition: pgstat.h:285
struct PgStat_MsgTabpurge PgStat_MsgTabpurge
void pgstat_update_heap_dead_tuples(Relation rel, int delta)
Definition: pgstat.c:2037
PgStat_MsgHdr m_hdr
Definition: pgstat.h:352
struct PgStat_MsgArchiver PgStat_MsgArchiver
PgStat_Counter m_timed_checkpoints
Definition: pgstat.h:413
PgStat_Counter n_conflict_bufferpin
Definition: pgstat.h:591
void pgstat_report_appname(const char *appname)
Definition: pgstat.c:3163
PgStat_Counter m_maxwritten_clean
Definition: pgstat.h:417
PgStat_Counter n_conflict_startup_deadlock
Definition: pgstat.h:592
void CreateSharedBackendStatus(void)
Definition: pgstat.c:2632
PgStat_Counter t_tuples_hot_updated
Definition: pgstat.h:107
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
Definition: pgstat.c:3068
PgStat_MsgHdr m_hdr
Definition: pgstat.h:411
TimestampTz autovac_analyze_timestamp
Definition: pgstat.h:642
bool pgstat_track_activities
Definition: pgstat.c:125
struct PgStat_MsgDeadlock PgStat_MsgDeadlock
struct timeval instr_time
Definition: instr_time.h:147
PgStat_Counter f_self_time
Definition: pgstat.h:485
PgStat_Counter timed_checkpoints
Definition: pgstat.h:684
PgStat_MsgHdr m_hdr
Definition: pgstat.h:516
PgStat_Counter n_temp_files
Definition: pgstat.h:593
Oid m_databaseid
Definition: pgstat.h:366
PgStat_Counter m_buf_written_clean
Definition: pgstat.h:416
PgStat_MsgDummy msg_dummy
Definition: pgstat.h:541
HTAB * functions
Definition: pgstat.h:607
TransactionId backend_xmin
Definition: pgstat.h:1081
PgStat_GlobalStats * pgstat_fetch_global(void)
Definition: pgstat.c:2576
char ssl_version[NAMEDATALEN]
Definition: pgstat.h:937
PgStat_Counter n_tuples_returned
Definition: pgstat.h:582
PgStat_Counter vacuum_count
Definition: pgstat.h:637
SockAddr st_clientaddr
Definition: pgstat.h:989
bool m_autovacuum
Definition: pgstat.h:368
void pgstat_send_archiver(const char *xlog, bool failed)
Definition: pgstat.c:4121
size_t m_filesize
Definition: pgstat.h:446
PgStat_Counter buf_fsync_backend
Definition: pgstat.h:692
struct PgStat_TableCounts PgStat_TableCounts
struct PgStat_MsgDummy PgStat_MsgDummy
TimestampTz stats_timestamp
Definition: pgstat.h:683
TimestampTz stat_reset_timestamp
Definition: pgstat.h:599
bool pgstat_track_counts
Definition: pgstat.c:126
instr_time f_total_time
Definition: pgstat.h:462
#define PG_WAIT_ACTIVITY
Definition: pgstat.h:740
struct PgStat_TableXactStatus * next
Definition: pgstat.h:179
TimestampTz m_analyzetime
Definition: pgstat.h:387
ProgressCommandType st_progress_command
Definition: pgstat.h:1014
void pgstat_twophase_postcommit(TransactionId xid, uint16 info, void *recdata, uint32 len)
Definition: pgstat.c:2317
PgStat_Counter numscans
Definition: pgstat.h:619
PgStat_TableCounts t_counts
Definition: pgstat.h:158
struct PgBackendSSLStatus PgBackendSSLStatus
struct PgStat_MsgRecoveryConflict PgStat_MsgRecoveryConflict
#define PG_WAIT_IO
Definition: pgstat.h:745
unsigned int Oid
Definition: postgres_ext.h:31
struct PgStat_ArchiverStats PgStat_ArchiverStats
PgStat_Counter deleted_pre_trunc
Definition: pgstat.h:173
PgStat_MsgAnalyze msg_analyze
Definition: pgstat.h:551
PgStat_Counter tuples_hot_updated
Definition: pgstat.h:627
PgStat_Counter f_total_time
Definition: pgstat.h:657
BackendState st_state
Definition: pgstat.h:997
PgStat_Counter t_tuples_returned
Definition: pgstat.h:101
PgStat_Shared_Reset_Target
Definition: pgstat.h:119
char * st_clienthostname
Definition: pgstat.h:990
PgStat_Counter tuples_inserted
Definition: pgstat.h:624
PgStat_FunctionCounts * fs
Definition: pgstat.h:1091
PgStat_Counter f_numcalls
Definition: pgstat.h:461
PgStat_MsgHdr msg_hdr
Definition: pgstat.h:540
struct PgStat_StatFuncEntry PgStat_StatFuncEntry
struct PgStat_FunctionCallUsage PgStat_FunctionCallUsage
#define PGDLLIMPORT
Definition: c.h:1063
PgStat_StatTabEntry * pgstat_fetch_stat_tabentry(Oid relid)
Definition: pgstat.c:2414
PgStat_Counter n_xact_commit
Definition: pgstat.h:578
void pgstat_report_deadlock(void)
Definition: pgstat.c:1506
bool m_resetcounter
Definition: pgstat.h:386
Definition: type.h:89
PgStat_MsgBgWriter BgWriterStats
Definition: pgstat.c:143
Oid st_databaseid
Definition: pgstat.h:987
#define NAMEDATALEN
#define PGSTAT_NUM_PROGRESS_PARAM
Definition: pgstat.h:918
PgStat_Counter n_blocks_fetched
Definition: pgstat.h:580
int pgstat_track_functions
Definition: pgstat.c:127
struct PgStat_TableEntry PgStat_TableEntry
PgStat_Counter n_live_tuples
Definition: pgstat.h:629
PgStat_Counter m_requested_checkpoints
Definition: pgstat.h:414
Definition: dynahash.c:193
struct PgStat_MsgAnalyze PgStat_MsgAnalyze
unsigned short uint16
Definition: c.h:267
PgStat_FunctionCounts f_counts
Definition: pgstat.h:473
PgStat_MsgHdr m_hdr
Definition: pgstat.h:529
PgStat_TableStatus * find_tabstat_entry(Oid rel_id)
Definition: pgstat.c:1838
PgStat_MsgFuncpurge msg_funcpurge
Definition: pgstat.h:555
char * pgstat_stat_tmpname
Definition: pgstat.c:136
PgStat_Counter buf_written_backend
Definition: pgstat.h:691
PgStat_Counter n_conflict_tablespace
Definition: pgstat.h:588
TransactionId backend_xid
Definition: pgstat.h:1075
void AtEOSubXact_PgStat(bool isCommit, int nestDepth)
Definition: pgstat.c:2136
TimestampTz vacuum_timestamp
Definition: pgstat.h:636
PgStat_Counter t_tuples_updated
Definition: pgstat.h:105
Oid m_tableid[PGSTAT_NUM_TABPURGE]
Definition: pgstat.h:294
PgStat_MsgHdr m_hdr
Definition: pgstat.h:431
PgStat_Counter pgStatBlockReadTime
Definition: pgstat.c:223
#define PG_WAIT_CLIENT
Definition: pgstat.h:741
void pgstat_reset_single_counter(Oid objectid, PgStat_Single_Reset_Type type)
Definition: pgstat.c:1359
PgStat_Counter checkpoint_write_time
Definition: pgstat.h:686
PgStat_Counter n_dead_tuples
Definition: pgstat.h:630
struct PgStat_MsgTempFile PgStat_MsgTempFile
LocalPgBackendStatus * pgstat_fetch_stat_local_beentry(int beid)
Definition: pgstat.c:2524
void allow_immediate_pgstat_restart(void)
Definition: pgstat.c:790
PgStat_Counter f_numcalls
Definition: pgstat.h:655
TimestampTz last_autovac_time
Definition: pgstat.h:587
WaitEventClient
Definition: pgstat.h:781
struct PgStat_GlobalStats PgStat_GlobalStats
PgStat_Counter n_tuples_inserted
Definition: pgstat.h:584
Oid m_databaseid
Definition: pgstat.h:306
PgStat_Counter buf_written_checkpoints
Definition: pgstat.h:688
PgStat_Counter tuples_inserted
Definition: pgstat.h:167
void AtEOXact_PgStat(bool isCommit)
Definition: pgstat.c:2053
struct PgStat_MsgDropdb PgStat_MsgDropdb
PgStat_Counter pgStatBlockWriteTime
Definition: pgstat.c:224
struct PgStat_MsgInquiry PgStat_MsgInquiry
void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
Definition: pgstat.c:1653
char * pgstat_stat_directory
Definition: pgstat.c:134
void pgstat_report_stat(bool force)
Definition: pgstat.c:812
void pgstat_vacuum_stat(void)
Definition: pgstat.c:1022
PgStat_Counter t_delta_dead_tuples
Definition: pgstat.h:111
PgStat_Counter tuples_fetched
Definition: pgstat.h:622
void pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
Definition: pgstat.c:1907
unsigned int uint32
Definition: c.h:268
PgStat_Counter n_conflict_snapshot
Definition: pgstat.h:590
PgStat_MsgHdr m_hdr
Definition: pgstat.h:305
PgStat_Counter m_block_write_time
Definition: pgstat.h:275
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1232
TimestampTz st_state_start_timestamp
Definition: pgstat.h:984
PgStat_Counter n_tuples_deleted
Definition: pgstat.h:586
void pgstat_twophase_postabort(TransactionId xid, uint16 info, void *recdata, uint32 len)
Definition: pgstat.c:2353
PgStat_Counter n_conflict_lock
Definition: pgstat.h:589
WaitEventTimeout
Definition: pgstat.h:824
char * st_appname
Definition: pgstat.h:1000
PgStat_Counter t_blocks_hit
Definition: pgstat.h:115
void pgstat_init(void)
Definition: pgstat.c:355
struct PgStat_TableXactStatus * upper
Definition: pgstat.h:176
PgStat_Counter n_xact_rollback
Definition: pgstat.h:579
int m_xact_rollback
Definition: pgstat.h:273
PgStat_MsgHdr m_hdr
Definition: pgstat.h:317
void pgstat_progress_end_command(void)
Definition: pgstat.c:3140
PgStat_Counter t_tuples_deleted
Definition: pgstat.h:106
PgStat_Counter buf_written_clean
Definition: pgstat.h:689
int pgstat_fetch_stat_numbackends(void)
Definition: pgstat.c:2543
void pgstat_report_recovery_conflict(int reason)
Definition: pgstat.c:1486
PgStat_MsgRecoveryConflict msg_recoveryconflict
Definition: pgstat.h:556
struct PgStat_MsgTabstat PgStat_MsgTabstat
PgBackendStatus * pgstat_fetch_stat_beentry(int beid)
Definition: pgstat.c:2502
PgStat_MsgHdr m_hdr
Definition: pgstat.h:291
PgStat_Counter m_live_tuples
Definition: pgstat.h:388
void pgstat_drop_database(Oid databaseid)
Definition: pgstat.c:1250
const char * pgstat_get_wait_event_type(uint32 wait_event_info)
Definition: pgstat.c:3331
struct PgStat_MsgResetsharedcounter PgStat_MsgResetsharedcounter
struct PgStat_FunctionCounts PgStat_FunctionCounts
const char * pgstat_get_wait_event(uint32 wait_event_info)
Definition: pgstat.c:3386
PgBackendStatus backendStatus
Definition: pgstat.h:1069
bool m_autovacuum
Definition: pgstat.h:385
#define PGSTAT_NUM_FUNCENTRIES
Definition: pgstat.h:493
PgStat_Counter tuples_deleted
Definition: pgstat.h:169
struct PgStat_MsgBgWriter PgStat_MsgBgWriter
TimestampTz m_timestamp
Definition: pgstat.h:402
#define PGSTAT_NUM_TABENTRIES
Definition: pgstat.h:263
struct PgStat_MsgResetsinglecounter PgStat_MsgResetsinglecounter
void pgstat_reset_counters(void)
Definition: pgstat.c:1306
#define MAX_XFN_CHARS
Definition: pgarch.h:26
BackendType st_backendType
Definition: pgstat.h:978
PgStat_Counter f_total_time
Definition: pgstat.h:484
PgStat_MsgAutovacStart msg_autovacuum
Definition: pgstat.h:549
PgStat_Counter blocks_hit
Definition: pgstat.h:634
TimestampTz analyze_timestamp
Definition: pgstat.h:640
TimestampTz last_failed_timestamp
Definition: pgstat.h:674
PgStat_Counter changes_since_analyze
Definition: pgstat.h:631
StatMsgType
Definition: pgstat.h:48
PgStat_Shared_Reset_Target m_resettarget
Definition: pgstat.h:329
void pgstat_report_vacuum(Oid tableoid, bool shared, PgStat_Counter livetuples, PgStat_Counter deadtuples)
Definition: pgstat.c:1405
PgStat_Counter t_numscans
Definition: pgstat.h:99
struct PgStat_MsgVacuum PgStat_MsgVacuum
PgStat_Single_Reset_Type
Definition: pgstat.h:126
Size BackendStatusShmemSize(void)
Definition: pgstat.c:2604
struct PgStat_TableXactStatus PgStat_TableXactStatus
PgStat_Counter n_tuples_updated
Definition: pgstat.h:585
char * pgstat_stat_filename
Definition: pgstat.c:135
PgStat_MsgHdr m_hdr
Definition: pgstat.h:216
PgStat_Counter t_changed_tuples
Definition: pgstat.h:112
PgStat_MsgTabstat msg_tabstat
Definition: pgstat.h:543
PgStat_MsgHdr m_hdr
Definition: pgstat.h:269
void pgstat_send_bgwriter(void)
Definition: pgstat.c:4142
ProgressCommandType
Definition: pgstat.h:912
PgStat_Counter m_checkpoint_sync_time
Definition: pgstat.h:422
PgStat_MsgVacuum msg_vacuum
Definition: pgstat.h:550
char * st_activity
Definition: pgstat.h:1003
Definition: regguts.h:298
PgStat_MsgHdr m_hdr
Definition: pgstat.h:499
PgStat_Counter failed_count
Definition: pgstat.h:671
PgStat_StatDBEntry * pgstat_fetch_stat_dbentry(Oid dbid)
Definition: pgstat.c:2387
PgStat_Counter n_block_write_time
Definition: pgstat.h:597
PgStat_Counter m_buf_written_backend
Definition: pgstat.h:418
int64 st_progress_param[PGSTAT_NUM_PROGRESS_PARAM]
Definition: pgstat.h:1016
PgStat_MsgHdr m_hdr
Definition: pgstat.h:365
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
void pgstat_count_heap_delete(Relation rel)
Definition: pgstat.c:1953
PgStat_Counter tuples_deleted
Definition: pgstat.h:626
struct PgStat_StatTabEntry PgStat_StatTabEntry
PgStat_TableCounts t_counts
Definition: pgstat.h:255
PgStat_Counter inserted_pre_trunc
Definition: pgstat.h:171
PgStat_Counter tuples_updated
Definition: pgstat.h:625
size_t Size
Definition: c.h:356
PgStat_Counter checkpoint_sync_time
Definition: pgstat.h:687
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: pgstat.h:1208
void pgstat_report_tempfile(size_t filesize)
Definition: pgstat.c:1525
PgStat_FunctionEntry m_entry[PGSTAT_NUM_FUNCENTRIES]
Definition: pgstat.h:502
void pgstat_init_function_usage(FunctionCallInfoData *fcinfo, PgStat_FunctionCallUsage *fcu)
Definition: pgstat.c:1581
struct PgStat_FunctionEntry PgStat_FunctionEntry
TimestampTz autovac_vacuum_timestamp
Definition: pgstat.h:638
PgStat_Counter maxwritten_clean
Definition: pgstat.h:690
PgStat_Counter n_block_read_time
Definition: pgstat.h:596
PgStat_Counter m_block_read_time
Definition: pgstat.h:274
struct PgStat_MsgFuncstat PgStat_MsgFuncstat
TimestampTz stat_reset_timestamp
Definition: pgstat.h:694
void pgstat_bestart(void)
Definition: pgstat.c:2785
struct PgStat_TableXactStatus * trans
Definition: pgstat.h:157
struct PgStat_TableStatus PgStat_TableStatus
struct PgBackendStatus PgBackendStatus
int st_procpid
Definition: pgstat.h:975
#define pg_attribute_noreturn()
Definition: c.h:653
struct PgStat_StatDBEntry PgStat_StatDBEntry
PgStat_Counter autovac_analyze_count
Definition: pgstat.h:643
void pgstat_report_autovac(Oid dboid)
Definition: pgstat.c:1383
PgStat_Counter updated_pre_trunc
Definition: pgstat.h:172
PgStat_MsgHdr m_hdr
Definition: pgstat.h:382
void pgstat_report_activity(BackendState state, const char *cmd_str)
Definition: pgstat.c:2994
void pgstat_count_heap_update(Relation rel, bool hot)
Definition: pgstat.c:1928
PgStat_BackendFunctionEntry * find_funcstat_entry(Oid func_id)
Definition: pgstat.c:1633
TimestampTz cutoff_time
Definition: pgstat.h:243
WaitEventIO
Definition: pgstat.h:837
TimestampTz stat_reset_timestamp
Definition: pgstat.h:675
TimestampTz last_archived_timestamp
Definition: pgstat.h:670
PgStat_TableEntry m_entry[PGSTAT_NUM_TABENTRIES]
Definition: pgstat.h:276
TimestampTz m_start_time
Definition: pgstat.h:354
PgStat_Counter n_deadlocks
Definition: pgstat.h:595
#define PG_WAIT_TIMEOUT
Definition: pgstat.h:744
#define PG_WAIT_IPC
Definition: pgstat.h:743
struct PgStat_MsgAutovacStart PgStat_MsgAutovacStart
TimestampTz st_xact_start_timestamp
Definition: pgstat.h:982
PgStat_MsgArchiver msg_archiver
Definition: pgstat.h:552
int st_changecount
Definition: pgstat.h:972
const char * pgstat_get_crashed_backend_activity(int pid, char *buffer, int buflen)
Definition: pgstat.c:3966
void pgstat_report_analyze(Relation rel, PgStat_Counter livetuples, PgStat_Counter deadtuples, bool resetcounter)
Definition: pgstat.c:1433
PgStat_MsgResetsinglecounter msg_resetsinglecounter
Definition: pgstat.h:548
PgStat_Counter requested_checkpoints
Definition: pgstat.h:685
StatMsgType m_type
Definition: pgstat.h:195
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
Definition: pgstat.c:3111
PgStat_StatFuncEntry * pgstat_fetch_stat_funcentry(Oid funcid)
Definition: pgstat.c:2470
instr_time save_f_total_time
Definition: pgstat.h:1093
PgStat_MsgResetcounter msg_resetcounter
Definition: pgstat.h:546
BackendState
Definition: pgstat.h:721
void pgstat_reset_all(void)
Definition: pgstat.c:685
PgStat_Counter f_numcalls
Definition: pgstat.h:483
struct PgStat_MsgResetcounter PgStat_MsgResetcounter
PgStat_Counter f_self_time
Definition: pgstat.h:658
PgStat_Counter m_dead_tuples
Definition: pgstat.h:389
Definition: proc.h:94
PgStat_Counter blocks_fetched
Definition: pgstat.h:633
void AtPrepare_PgStat(void)
Definition: pgstat.c:2235
struct PgStat_BackendFunctionEntry PgStat_BackendFunctionEntry
struct PgStat_MsgHdr PgStat_MsgHdr
TimestampTz st_proc_start_timestamp
Definition: pgstat.h:981
PgStat_MsgInquiry msg_inquiry
Definition: pgstat.h:542
PgStat_MsgDropdb msg_dropdb
Definition: pgstat.h:545
int m_size
Definition: pgstat.h:196
PgBackendSSLStatus * st_sslstatus
Definition: pgstat.h:994
PgStat_Single_Reset_Type m_resettype
Definition: pgstat.h:341
void pgstat_initstats(Relation rel)
Definition: pgstat.c:1710
PgStat_Counter t_tuples_inserted
Definition: pgstat.h:104
long val
Definition: informix.c:689
void pgstat_reset_shared_counters(const char *)
Definition: pgstat.c:1328
PgStat_MsgTabpurge msg_tabpurge
Definition: pgstat.h:544
#define PGSTAT_NUM_FUNCPURGE
Definition: pgstat.h:510
PGDLLIMPORT int pgstat_track_activity_query_size
Definition: pgstat.c:128
PgStat_TableStatus * parent
Definition: pgstat.h:177
PgStat_Counter t_blocks_fetched
Definition: pgstat.h:114
PgStat_MsgHdr m_hdr
Definition: pgstat.h:399
void PostPrepare_PgStat(void)
Definition: pgstat.c:2284
PgStat_MsgFuncstat msg_funcstat
Definition: pgstat.h:554
struct LocalPgBackendStatus LocalPgBackendStatus
WaitEventActivity
Definition: pgstat.h:755
PgStat_Counter n_tuples_fetched
Definition: pgstat.h:583
char last_archived_wal[MAX_XFN_CHARS+1]
Definition: pgstat.h:668
PgStat_Counter autovac_vacuum_count
Definition: pgstat.h:639
Oid m_functionid[PGSTAT_NUM_FUNCPURGE]
Definition: pgstat.h:519
char ssl_clientdn[NAMEDATALEN]
Definition: pgstat.h:939
PgStat_MsgHdr m_hdr
Definition: pgstat.h:241
PgStat_Counter n_temp_bytes
Definition: pgstat.h:594