doc: Add more details about pg_stat_get_xact_blocks_{fetched,hit}
[pgsql.git] / doc / src / sgml / monitoring.sgml
blobfd0ffbb1e08e79aba870d09baaf6fc2c88c1ef5d
1 <!-- doc/src/sgml/monitoring.sgml -->
3 <chapter id="monitoring">
4 <title>Monitoring Database Activity</title>
6 <indexterm zone="monitoring">
7 <primary>monitoring</primary>
8 <secondary>database activity</secondary>
9 </indexterm>
11 <indexterm zone="monitoring">
12 <primary>database activity</primary>
13 <secondary>monitoring</secondary>
14 </indexterm>
16 <para>
17 A database administrator frequently wonders, <quote>What is the system
18 doing right now?</quote>
19 This chapter discusses how to find that out.
20 </para>
22 <para>
23 Several tools are available for monitoring database activity and
24 analyzing performance. Most of this chapter is devoted to describing
25 <productname>PostgreSQL</productname>'s cumulative statistics system,
26 but one should not neglect regular Unix monitoring programs such as
27 <command>ps</command>, <command>top</command>, <command>iostat</command>, and <command>vmstat</command>.
28 Also, once one has identified a
29 poorly-performing query, further investigation might be needed using
30 <productname>PostgreSQL</productname>'s <link linkend="sql-explain"><command>EXPLAIN</command></link> command.
31 <xref linkend="using-explain"/> discusses <command>EXPLAIN</command>
32 and other methods for understanding the behavior of an individual
33 query.
34 </para>
36 <sect1 id="monitoring-ps">
37 <title>Standard Unix Tools</title>
39 <indexterm zone="monitoring-ps">
40 <primary>ps</primary>
41 <secondary>to monitor activity</secondary>
42 </indexterm>
44 <para>
45 On most Unix platforms, <productname>PostgreSQL</productname> modifies its
46 command title as reported by <command>ps</command>, so that individual server
47 processes can readily be identified. A sample display is
49 <screen>
50 $ ps auxww | grep ^postgres
51 postgres 15551 0.0 0.1 57536 7132 pts/0 S 18:02 0:00 postgres -i
52 postgres 15554 0.0 0.0 57536 1184 ? Ss 18:02 0:00 postgres: background writer
53 postgres 15555 0.0 0.0 57536 916 ? Ss 18:02 0:00 postgres: checkpointer
54 postgres 15556 0.0 0.0 57536 916 ? Ss 18:02 0:00 postgres: walwriter
55 postgres 15557 0.0 0.0 58504 2244 ? Ss 18:02 0:00 postgres: autovacuum launcher
56 postgres 15582 0.0 0.0 58772 3080 ? Ss 18:04 0:00 postgres: joe runbug 127.0.0.1 idle
57 postgres 15606 0.0 0.0 58772 3052 ? Ss 18:07 0:00 postgres: tgl regression [local] SELECT waiting
58 postgres 15610 0.0 0.0 58772 3056 ? Ss 18:07 0:00 postgres: tgl regression [local] idle in transaction
59 </screen>
61 (The appropriate invocation of <command>ps</command> varies across different
62 platforms, as do the details of what is shown. This example is from a
63 recent Linux system.) The first process listed here is the
64 primary server process. The command arguments
65 shown for it are the same ones used when it was launched. The next four
66 processes are background worker processes automatically launched by the
67 primary process. (The <quote>autovacuum launcher</quote> process will not
68 be present if you have set the system not to run autovacuum.)
69 Each of the remaining
70 processes is a server process handling one client connection. Each such
71 process sets its command line display in the form
73 <screen>
74 postgres: <replaceable>user</replaceable> <replaceable>database</replaceable> <replaceable>host</replaceable> <replaceable>activity</replaceable>
75 </screen>
77 The user, database, and (client) host items remain the same for
78 the life of the client connection, but the activity indicator changes.
79 The activity can be <literal>idle</literal> (i.e., waiting for a client command),
80 <literal>idle in transaction</literal> (waiting for client inside a <command>BEGIN</command> block),
81 or a command type name such as <literal>SELECT</literal>. Also,
82 <literal>waiting</literal> is appended if the server process is presently waiting
83 on a lock held by another session. In the above example we can infer
84 that process 15606 is waiting for process 15610 to complete its transaction
85 and thereby release some lock. (Process 15610 must be the blocker, because
86 there is no other active session. In more complicated cases it would be
87 necessary to look into the
88 <link linkend="view-pg-locks"><structname>pg_locks</structname></link>
89 system view to determine who is blocking whom.)
90 </para>
92 <para>
93 If <xref linkend="guc-cluster-name"/> has been configured the
94 cluster name will also be shown in <command>ps</command> output:
95 <screen>
96 $ psql -c 'SHOW cluster_name'
97 cluster_name
98 --------------
99 server1
100 (1 row)
102 $ ps aux|grep server1
103 postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: server1: background writer
105 </screen>
106 </para>
108 <para>
109 If you have turned off <xref linkend="guc-update-process-title"/> then the
110 activity indicator is not updated; the process title is set only once
111 when a new process is launched. On some platforms this saves a measurable
112 amount of per-command overhead; on others it's insignificant.
113 </para>
115 <tip>
116 <para>
117 <productname>Solaris</productname> requires special handling. You must
118 use <command>/usr/ucb/ps</command>, rather than
119 <command>/bin/ps</command>. You also must use two <option>w</option>
120 flags, not just one. In addition, your original invocation of the
121 <command>postgres</command> command must have a shorter
122 <command>ps</command> status display than that provided by each
123 server process. If you fail to do all three things, the <command>ps</command>
124 output for each server process will be the original <command>postgres</command>
125 command line.
126 </para>
127 </tip>
128 </sect1>
130 <sect1 id="monitoring-stats">
131 <title>The Cumulative Statistics System</title>
133 <indexterm zone="monitoring-stats">
134 <primary>statistics</primary>
135 </indexterm>
137 <para>
138 <productname>PostgreSQL</productname>'s <firstterm>cumulative statistics
139 system</firstterm> supports collection and reporting of information about
140 server activity. Presently, accesses to tables and indexes in both
141 disk-block and individual-row terms are counted. The total number of rows
142 in each table, and information about vacuum and analyze actions for each
143 table are also counted. If enabled, calls to user-defined functions and
144 the total time spent in each one are counted as well.
145 </para>
147 <para>
148 <productname>PostgreSQL</productname> also supports reporting dynamic
149 information about exactly what is going on in the system right now, such as
150 the exact command currently being executed by other server processes, and
151 which other connections exist in the system. This facility is independent
152 of the cumulative statistics system.
153 </para>
155 <sect2 id="monitoring-stats-setup">
156 <title>Statistics Collection Configuration</title>
158 <para>
159 Since collection of statistics adds some overhead to query execution,
160 the system can be configured to collect or not collect information.
161 This is controlled by configuration parameters that are normally set in
162 <filename>postgresql.conf</filename>. (See <xref linkend="runtime-config"/> for
163 details about setting configuration parameters.)
164 </para>
166 <para>
167 The parameter <xref linkend="guc-track-activities"/> enables monitoring
168 of the current command being executed by any server process.
169 </para>
171 <para>
172 The parameter <xref linkend="guc-track-counts"/> controls whether
173 cumulative statistics are collected about table and index accesses.
174 </para>
176 <para>
177 The parameter <xref linkend="guc-track-functions"/> enables tracking of
178 usage of user-defined functions.
179 </para>
181 <para>
182 The parameter <xref linkend="guc-track-io-timing"/> enables monitoring
183 of block read and write times.
184 </para>
186 <para>
187 The parameter <xref linkend="guc-track-wal-io-timing"/> enables monitoring
188 of WAL write times.
189 </para>
191 <para>
192 Normally these parameters are set in <filename>postgresql.conf</filename> so
193 that they apply to all server processes, but it is possible to turn
194 them on or off in individual sessions using the <xref
195 linkend="sql-set"/> command. (To prevent
196 ordinary users from hiding their activity from the administrator,
197 only superusers are allowed to change these parameters with
198 <command>SET</command>.)
199 </para>
201 <para>
202 Cumulative statistics are collected in shared memory. Every
203 <productname>PostgreSQL</productname> process collects statistics locally,
204 then updates the shared data at appropriate intervals. When a server,
205 including a physical replica, shuts down cleanly, a permanent copy of the
206 statistics data is stored in the <filename>pg_stat</filename> subdirectory,
207 so that statistics can be retained across server restarts. In contrast,
208 when starting from an unclean shutdown (e.g., after an immediate shutdown,
209 a server crash, starting from a base backup, and point-in-time recovery),
210 all statistics counters are reset.
211 </para>
213 </sect2>
215 <sect2 id="monitoring-stats-views">
216 <title>Viewing Statistics</title>
218 <para>
219 Several predefined views, listed in <xref
220 linkend="monitoring-stats-dynamic-views-table"/>, are available to show
221 the current state of the system. There are also several other
222 views, listed in <xref
223 linkend="monitoring-stats-views-table"/>, available to show the accumulated
224 statistics. Alternatively, one can
225 build custom views using the underlying cumulative statistics functions, as
226 discussed in <xref linkend="monitoring-stats-functions"/>.
227 </para>
229 <para>
230 When using the cumulative statistics views and functions to monitor
231 collected data, it is important to realize that the information does not
232 update instantaneously. Each individual server process flushes out
233 accumulated statistics to shared memory just before going idle, but not
234 more frequently than once per <varname>PGSTAT_MIN_INTERVAL</varname>
235 milliseconds (1 second unless altered while building the server); so a
236 query or transaction still in progress does not affect the displayed totals
237 and the displayed information lags behind actual activity. However,
238 current-query information collected by <varname>track_activities</varname>
239 is always up-to-date.
240 </para>
242 <para>
243 Another important point is that when a server process is asked to display
244 any of the accumulated statistics, accessed values are cached until the end
245 of its current transaction in the default configuration. So the statistics
246 will show static information as long as you continue the current
247 transaction. Similarly, information about the current queries of all
248 sessions is collected when any such information is first requested within a
249 transaction, and the same information will be displayed throughout the
250 transaction. This is a feature, not a bug, because it allows you to perform
251 several queries on the statistics and correlate the results without
252 worrying that the numbers are changing underneath you.
254 When analyzing statistics interactively, or with expensive queries, the
255 time delta between accesses to individual statistics can lead to
256 significant skew in the cached statistics. To minimize skew,
257 <varname>stats_fetch_consistency</varname> can be set to
258 <literal>snapshot</literal>, at the price of increased memory usage for
259 caching not-needed statistics data. Conversely, if it's known that
260 statistics are only accessed once, caching accessed statistics is
261 unnecessary and can be avoided by setting
262 <varname>stats_fetch_consistency</varname> to <literal>none</literal>.
264 You can invoke <function>pg_stat_clear_snapshot</function>() to discard the
265 current transaction's statistics snapshot or cached values (if any). The
266 next use of statistical information will (when in snapshot mode) cause a
267 new snapshot to be built or (when in cache mode) accessed statistics to be
268 cached.
269 </para>
271 <para>
272 A transaction can also see its own statistics (not yet flushed out to the
273 shared memory statistics) in the views
274 <structname>pg_stat_xact_all_tables</structname>,
275 <structname>pg_stat_xact_sys_tables</structname>,
276 <structname>pg_stat_xact_user_tables</structname>, and
277 <structname>pg_stat_xact_user_functions</structname>. These numbers do not act as
278 stated above; instead they update continuously throughout the transaction.
279 </para>
281 <para>
282 Some of the information in the dynamic statistics views shown in <xref
283 linkend="monitoring-stats-dynamic-views-table"/> is security restricted.
284 Ordinary users can only see all the information about their own sessions
285 (sessions belonging to a role that they are a member of). In rows about
286 other sessions, many columns will be null. Note, however, that the
287 existence of a session and its general properties such as its sessions user
288 and database are visible to all users. Superusers and roles with privileges of
289 built-in role <literal>pg_read_all_stats</literal> (see also <xref
290 linkend="predefined-roles"/>) can see all the information about all sessions.
291 </para>
293 <table id="monitoring-stats-dynamic-views-table">
294 <title>Dynamic Statistics Views</title>
296 <tgroup cols="2">
297 <thead>
298 <row>
299 <entry>View Name</entry>
300 <entry>Description</entry>
301 </row>
302 </thead>
304 <tbody>
305 <row>
306 <entry>
307 <structname>pg_stat_activity</structname>
308 <indexterm><primary>pg_stat_activity</primary></indexterm>
309 </entry>
310 <entry>
311 One row per server process, showing information related to
312 the current activity of that process, such as state and current query.
313 See <link linkend="monitoring-pg-stat-activity-view">
314 <structname>pg_stat_activity</structname></link> for details.
315 </entry>
316 </row>
318 <row>
319 <entry><structname>pg_stat_replication</structname><indexterm><primary>pg_stat_replication</primary></indexterm></entry>
320 <entry>One row per WAL sender process, showing statistics about
321 replication to that sender's connected standby server.
322 See <link linkend="monitoring-pg-stat-replication-view">
323 <structname>pg_stat_replication</structname></link> for details.
324 </entry>
325 </row>
327 <row>
328 <entry><structname>pg_stat_wal_receiver</structname><indexterm><primary>pg_stat_wal_receiver</primary></indexterm></entry>
329 <entry>Only one row, showing statistics about the WAL receiver from
330 that receiver's connected server.
331 See <link linkend="monitoring-pg-stat-wal-receiver-view">
332 <structname>pg_stat_wal_receiver</structname></link> for details.
333 </entry>
334 </row>
336 <row>
337 <entry><structname>pg_stat_recovery_prefetch</structname><indexterm><primary>pg_stat_recovery_prefetch</primary></indexterm></entry>
338 <entry>Only one row, showing statistics about blocks prefetched during recovery.
339 See <link linkend="monitoring-pg-stat-recovery-prefetch">
340 <structname>pg_stat_recovery_prefetch</structname></link> for details.
341 </entry>
342 </row>
344 <row>
345 <entry><structname>pg_stat_subscription</structname><indexterm><primary>pg_stat_subscription</primary></indexterm></entry>
346 <entry>At least one row per subscription, showing information about
347 the subscription workers.
348 See <link linkend="monitoring-pg-stat-subscription">
349 <structname>pg_stat_subscription</structname></link> for details.
350 </entry>
351 </row>
353 <row>
354 <entry><structname>pg_stat_ssl</structname><indexterm><primary>pg_stat_ssl</primary></indexterm></entry>
355 <entry>One row per connection (regular and replication), showing information about
356 SSL used on this connection.
357 See <link linkend="monitoring-pg-stat-ssl-view">
358 <structname>pg_stat_ssl</structname></link> for details.
359 </entry>
360 </row>
362 <row>
363 <entry><structname>pg_stat_gssapi</structname><indexterm><primary>pg_stat_gssapi</primary></indexterm></entry>
364 <entry>One row per connection (regular and replication), showing information about
365 GSSAPI authentication and encryption used on this connection.
366 See <link linkend="monitoring-pg-stat-gssapi-view">
367 <structname>pg_stat_gssapi</structname></link> for details.
368 </entry>
369 </row>
371 <row>
372 <entry><structname>pg_stat_progress_analyze</structname><indexterm><primary>pg_stat_progress_analyze</primary></indexterm></entry>
373 <entry>One row for each backend (including autovacuum worker processes) running
374 <command>ANALYZE</command>, showing current progress.
375 See <xref linkend="analyze-progress-reporting"/>.
376 </entry>
377 </row>
379 <row>
380 <entry><structname>pg_stat_progress_create_index</structname><indexterm><primary>pg_stat_progress_create_index</primary></indexterm></entry>
381 <entry>One row for each backend running <command>CREATE INDEX</command> or <command>REINDEX</command>, showing
382 current progress.
383 See <xref linkend="create-index-progress-reporting"/>.
384 </entry>
385 </row>
387 <row>
388 <entry><structname>pg_stat_progress_vacuum</structname><indexterm><primary>pg_stat_progress_vacuum</primary></indexterm></entry>
389 <entry>One row for each backend (including autovacuum worker processes) running
390 <command>VACUUM</command>, showing current progress.
391 See <xref linkend="vacuum-progress-reporting"/>.
392 </entry>
393 </row>
395 <row>
396 <entry><structname>pg_stat_progress_cluster</structname><indexterm><primary>pg_stat_progress_cluster</primary></indexterm></entry>
397 <entry>One row for each backend running
398 <command>CLUSTER</command> or <command>VACUUM FULL</command>, showing current progress.
399 See <xref linkend="cluster-progress-reporting"/>.
400 </entry>
401 </row>
403 <row>
404 <entry><structname>pg_stat_progress_basebackup</structname><indexterm><primary>pg_stat_progress_basebackup</primary></indexterm></entry>
405 <entry>One row for each WAL sender process streaming a base backup,
406 showing current progress.
407 See <xref linkend="basebackup-progress-reporting"/>.
408 </entry>
409 </row>
411 <row>
412 <entry><structname>pg_stat_progress_copy</structname><indexterm><primary>pg_stat_progress_copy</primary></indexterm></entry>
413 <entry>One row for each backend running <command>COPY</command>, showing current progress.
414 See <xref linkend="copy-progress-reporting"/>.
415 </entry>
416 </row>
417 </tbody>
418 </tgroup>
419 </table>
421 <table id="monitoring-stats-views-table">
422 <title>Collected Statistics Views</title>
424 <tgroup cols="2">
425 <thead>
426 <row>
427 <entry>View Name</entry>
428 <entry>Description</entry>
429 </row>
430 </thead>
432 <tbody>
434 <!-- everything related to global objects, alphabetically -->
436 <row>
437 <entry><structname>pg_stat_archiver</structname><indexterm><primary>pg_stat_archiver</primary></indexterm></entry>
438 <entry>One row only, showing statistics about the
439 WAL archiver process's activity. See
440 <link linkend="monitoring-pg-stat-archiver-view">
441 <structname>pg_stat_archiver</structname></link> for details.
442 </entry>
443 </row>
445 <row>
446 <entry><structname>pg_stat_bgwriter</structname><indexterm><primary>pg_stat_bgwriter</primary></indexterm></entry>
447 <entry>One row only, showing statistics about the
448 background writer process's activity. See
449 <link linkend="monitoring-pg-stat-bgwriter-view">
450 <structname>pg_stat_bgwriter</structname></link> for details.
451 </entry>
452 </row>
454 <row>
455 <entry><structname>pg_stat_database</structname><indexterm><primary>pg_stat_database</primary></indexterm></entry>
456 <entry>One row per database, showing database-wide statistics. See
457 <link linkend="monitoring-pg-stat-database-view">
458 <structname>pg_stat_database</structname></link> for details.
459 </entry>
460 </row>
462 <row>
463 <entry><structname>pg_stat_database_conflicts</structname><indexterm><primary>pg_stat_database_conflicts</primary></indexterm></entry>
464 <entry>
465 One row per database, showing database-wide statistics about
466 query cancels due to conflict with recovery on standby servers.
467 See <link linkend="monitoring-pg-stat-database-conflicts-view">
468 <structname>pg_stat_database_conflicts</structname></link> for details.
469 </entry>
470 </row>
472 <row>
473 <entry><structname>pg_stat_io</structname><indexterm><primary>pg_stat_io</primary></indexterm></entry>
474 <entry>
475 One row for each combination of backend type, context, and target object
476 containing cluster-wide I/O statistics.
477 See <link linkend="monitoring-pg-stat-io-view">
478 <structname>pg_stat_io</structname></link> for details.
479 </entry>
480 </row>
482 <row>
483 <entry><structname>pg_stat_replication_slots</structname><indexterm><primary>pg_stat_replication_slots</primary></indexterm></entry>
484 <entry>One row per replication slot, showing statistics about the
485 replication slot's usage. See
486 <link linkend="monitoring-pg-stat-replication-slots-view">
487 <structname>pg_stat_replication_slots</structname></link> for details.
488 </entry>
489 </row>
491 <row>
492 <entry><structname>pg_stat_slru</structname><indexterm><primary>pg_stat_slru</primary></indexterm></entry>
493 <entry>One row per SLRU, showing statistics of operations. See
494 <link linkend="monitoring-pg-stat-slru-view">
495 <structname>pg_stat_slru</structname></link> for details.
496 </entry>
497 </row>
499 <row>
500 <entry><structname>pg_stat_subscription_stats</structname><indexterm><primary>pg_stat_subscription_stats</primary></indexterm></entry>
501 <entry>One row per subscription, showing statistics about errors.
502 See <link linkend="monitoring-pg-stat-subscription-stats">
503 <structname>pg_stat_subscription_stats</structname></link> for details.
504 </entry>
505 </row>
507 <row>
508 <entry><structname>pg_stat_wal</structname><indexterm><primary>pg_stat_wal</primary></indexterm></entry>
509 <entry>One row only, showing statistics about WAL activity. See
510 <link linkend="monitoring-pg-stat-wal-view">
511 <structname>pg_stat_wal</structname></link> for details.
512 </entry>
513 </row>
515 <!-- all "stat" for schema objects, by "importance" -->
517 <row>
518 <entry><structname>pg_stat_all_tables</structname><indexterm><primary>pg_stat_all_tables</primary></indexterm></entry>
519 <entry>
520 One row for each table in the current database, showing statistics
521 about accesses to that specific table.
522 See <link linkend="monitoring-pg-stat-all-tables-view">
523 <structname>pg_stat_all_tables</structname></link> for details.
524 </entry>
525 </row>
527 <row>
528 <entry><structname>pg_stat_sys_tables</structname><indexterm><primary>pg_stat_sys_tables</primary></indexterm></entry>
529 <entry>Same as <structname>pg_stat_all_tables</structname>, except that only
530 system tables are shown.</entry>
531 </row>
533 <row>
534 <entry><structname>pg_stat_user_tables</structname><indexterm><primary>pg_stat_user_tables</primary></indexterm></entry>
535 <entry>Same as <structname>pg_stat_all_tables</structname>, except that only user
536 tables are shown.</entry>
537 </row>
539 <row>
540 <entry><structname>pg_stat_xact_all_tables</structname><indexterm><primary>pg_stat_xact_all_tables</primary></indexterm></entry>
541 <entry>Similar to <structname>pg_stat_all_tables</structname>, but counts actions
542 taken so far within the current transaction (which are <emphasis>not</emphasis>
543 yet included in <structname>pg_stat_all_tables</structname> and related views).
544 The columns for numbers of live and dead rows and vacuum and
545 analyze actions are not present in this view.</entry>
546 </row>
548 <row>
549 <entry><structname>pg_stat_xact_sys_tables</structname><indexterm><primary>pg_stat_xact_sys_tables</primary></indexterm></entry>
550 <entry>Same as <structname>pg_stat_xact_all_tables</structname>, except that only
551 system tables are shown.</entry>
552 </row>
554 <row>
555 <entry><structname>pg_stat_xact_user_tables</structname><indexterm><primary>pg_stat_xact_user_tables</primary></indexterm></entry>
556 <entry>Same as <structname>pg_stat_xact_all_tables</structname>, except that only
557 user tables are shown.</entry>
558 </row>
560 <row>
561 <entry><structname>pg_stat_all_indexes</structname><indexterm><primary>pg_stat_all_indexes</primary></indexterm></entry>
562 <entry>
563 One row for each index in the current database, showing statistics
564 about accesses to that specific index.
565 See <link linkend="monitoring-pg-stat-all-indexes-view">
566 <structname>pg_stat_all_indexes</structname></link> for details.
567 </entry>
568 </row>
570 <row>
571 <entry><structname>pg_stat_sys_indexes</structname><indexterm><primary>pg_stat_sys_indexes</primary></indexterm></entry>
572 <entry>Same as <structname>pg_stat_all_indexes</structname>, except that only
573 indexes on system tables are shown.</entry>
574 </row>
576 <row>
577 <entry><structname>pg_stat_user_indexes</structname><indexterm><primary>pg_stat_user_indexes</primary></indexterm></entry>
578 <entry>Same as <structname>pg_stat_all_indexes</structname>, except that only
579 indexes on user tables are shown.</entry>
580 </row>
582 <row>
583 <entry><structname>pg_stat_user_functions</structname><indexterm><primary>pg_stat_user_functions</primary></indexterm></entry>
584 <entry>
585 One row for each tracked function, showing statistics
586 about executions of that function. See
587 <link linkend="monitoring-pg-stat-user-functions-view">
588 <structname>pg_stat_user_functions</structname></link> for details.
589 </entry>
590 </row>
592 <row>
593 <entry><structname>pg_stat_xact_user_functions</structname><indexterm><primary>pg_stat_xact_user_functions</primary></indexterm></entry>
594 <entry>Similar to <structname>pg_stat_user_functions</structname>, but counts only
595 calls during the current transaction (which are <emphasis>not</emphasis>
596 yet included in <structname>pg_stat_user_functions</structname>).</entry>
597 </row>
599 <!-- all "statio" for schema objects, by "importance" -->
601 <row>
602 <entry><structname>pg_statio_all_tables</structname><indexterm><primary>pg_statio_all_tables</primary></indexterm></entry>
603 <entry>
604 One row for each table in the current database, showing statistics
605 about I/O on that specific table.
606 See <link linkend="monitoring-pg-statio-all-tables-view">
607 <structname>pg_statio_all_tables</structname></link> for details.
608 </entry>
609 </row>
611 <row>
612 <entry><structname>pg_statio_sys_tables</structname><indexterm><primary>pg_statio_sys_tables</primary></indexterm></entry>
613 <entry>Same as <structname>pg_statio_all_tables</structname>, except that only
614 system tables are shown.</entry>
615 </row>
617 <row>
618 <entry><structname>pg_statio_user_tables</structname><indexterm><primary>pg_statio_user_tables</primary></indexterm></entry>
619 <entry>Same as <structname>pg_statio_all_tables</structname>, except that only
620 user tables are shown.</entry>
621 </row>
623 <row>
624 <entry><structname>pg_statio_all_indexes</structname><indexterm><primary>pg_statio_all_indexes</primary></indexterm></entry>
625 <entry>
626 One row for each index in the current database,
627 showing statistics about I/O on that specific index.
628 See <link linkend="monitoring-pg-statio-all-indexes-view">
629 <structname>pg_statio_all_indexes</structname></link> for details.
630 </entry>
631 </row>
633 <row>
634 <entry><structname>pg_statio_sys_indexes</structname><indexterm><primary>pg_statio_sys_indexes</primary></indexterm></entry>
635 <entry>Same as <structname>pg_statio_all_indexes</structname>, except that only
636 indexes on system tables are shown.</entry>
637 </row>
639 <row>
640 <entry><structname>pg_statio_user_indexes</structname><indexterm><primary>pg_statio_user_indexes</primary></indexterm></entry>
641 <entry>Same as <structname>pg_statio_all_indexes</structname>, except that only
642 indexes on user tables are shown.</entry>
643 </row>
645 <row>
646 <entry><structname>pg_statio_all_sequences</structname><indexterm><primary>pg_statio_all_sequences</primary></indexterm></entry>
647 <entry>
648 One row for each sequence in the current database,
649 showing statistics about I/O on that specific sequence.
650 See <link linkend="monitoring-pg-statio-all-sequences-view">
651 <structname>pg_statio_all_sequences</structname></link> for details.
652 </entry>
653 </row>
655 <row>
656 <entry><structname>pg_statio_sys_sequences</structname><indexterm><primary>pg_statio_sys_sequences</primary></indexterm></entry>
657 <entry>Same as <structname>pg_statio_all_sequences</structname>, except that only
658 system sequences are shown. (Presently, no system sequences are defined,
659 so this view is always empty.)</entry>
660 </row>
662 <row>
663 <entry><structname>pg_statio_user_sequences</structname><indexterm><primary>pg_statio_user_sequences</primary></indexterm></entry>
664 <entry>Same as <structname>pg_statio_all_sequences</structname>, except that only
665 user sequences are shown.</entry>
666 </row>
668 </tbody>
669 </tgroup>
670 </table>
672 <para>
673 The per-index statistics are particularly useful to determine which
674 indexes are being used and how effective they are.
675 </para>
677 <para>
678 The <structname>pg_stat_io</structname> and
679 <structname>pg_statio_</structname> set of views are useful for determining
680 the effectiveness of the buffer cache. They can be used to calculate a cache
681 hit ratio. Note that while <productname>PostgreSQL</productname>'s I/O
682 statistics capture most instances in which the kernel was invoked in order
683 to perform I/O, they do not differentiate between data which had to be
684 fetched from disk and that which already resided in the kernel page cache.
685 Users are advised to use the <productname>PostgreSQL</productname>
686 statistics views in combination with operating system utilities for a more
687 complete picture of their database's I/O performance.
688 </para>
690 </sect2>
692 <sect2 id="monitoring-pg-stat-activity-view">
693 <title><structname>pg_stat_activity</structname></title>
695 <indexterm>
696 <primary>pg_stat_activity</primary>
697 </indexterm>
699 <para>
700 The <structname>pg_stat_activity</structname> view will have one row
701 per server process, showing information related to
702 the current activity of that process.
703 </para>
705 <table id="pg-stat-activity-view" xreflabel="pg_stat_activity">
706 <title><structname>pg_stat_activity</structname> View</title>
707 <tgroup cols="1">
708 <thead>
709 <row>
710 <entry role="catalog_table_entry"><para role="column_definition">
711 Column Type
712 </para>
713 <para>
714 Description
715 </para></entry>
716 </row>
717 </thead>
719 <tbody>
720 <row>
721 <entry role="catalog_table_entry"><para role="column_definition">
722 <structfield>datid</structfield> <type>oid</type>
723 </para>
724 <para>
725 OID of the database this backend is connected to
726 </para></entry>
727 </row>
729 <row>
730 <entry role="catalog_table_entry"><para role="column_definition">
731 <structfield>datname</structfield> <type>name</type>
732 </para>
733 <para>
734 Name of the database this backend is connected to
735 </para></entry>
736 </row>
738 <row>
739 <entry role="catalog_table_entry"><para role="column_definition">
740 <structfield>pid</structfield> <type>integer</type>
741 </para>
742 <para>
743 Process ID of this backend
744 </para></entry>
745 </row>
747 <row>
748 <entry role="catalog_table_entry"><para role="column_definition">
749 <structfield>leader_pid</structfield> <type>integer</type>
750 </para>
751 <para>
752 Process ID of the parallel group leader if this process is a parallel
753 query worker, or process ID of the leader apply worker if this process
754 is a parallel apply worker. <literal>NULL</literal> indicates that this
755 process is a parallel group leader or leader apply worker, or does not
756 participate in any parallel operation.
757 </para></entry>
758 </row>
760 <row>
761 <entry role="catalog_table_entry"><para role="column_definition">
762 <structfield>usesysid</structfield> <type>oid</type>
763 </para>
764 <para>
765 OID of the user logged into this backend
766 </para></entry>
767 </row>
769 <row>
770 <entry role="catalog_table_entry"><para role="column_definition">
771 <structfield>usename</structfield> <type>name</type>
772 </para>
773 <para>
774 Name of the user logged into this backend
775 </para></entry>
776 </row>
778 <row>
779 <entry role="catalog_table_entry"><para role="column_definition">
780 <structfield>application_name</structfield> <type>text</type>
781 </para>
782 <para>
783 Name of the application that is connected
784 to this backend
785 </para></entry>
786 </row>
788 <row>
789 <entry role="catalog_table_entry"><para role="column_definition">
790 <structfield>client_addr</structfield> <type>inet</type>
791 </para>
792 <para>
793 IP address of the client connected to this backend.
794 If this field is null, it indicates either that the client is
795 connected via a Unix socket on the server machine or that this is an
796 internal process such as autovacuum.
797 </para></entry>
798 </row>
800 <row>
801 <entry role="catalog_table_entry"><para role="column_definition">
802 <structfield>client_hostname</structfield> <type>text</type>
803 </para>
804 <para>
805 Host name of the connected client, as reported by a
806 reverse DNS lookup of <structfield>client_addr</structfield>. This field will
807 only be non-null for IP connections, and only when <xref linkend="guc-log-hostname"/> is enabled.
808 </para></entry>
809 </row>
811 <row>
812 <entry role="catalog_table_entry"><para role="column_definition">
813 <structfield>client_port</structfield> <type>integer</type>
814 </para>
815 <para>
816 TCP port number that the client is using for communication
817 with this backend, or <literal>-1</literal> if a Unix socket is used.
818 If this field is null, it indicates that this is an internal server process.
819 </para></entry>
820 </row>
822 <row>
823 <entry role="catalog_table_entry"><para role="column_definition">
824 <structfield>backend_start</structfield> <type>timestamp with time zone</type>
825 </para>
826 <para>
827 Time when this process was started. For client backends,
828 this is the time the client connected to the server.
829 </para></entry>
830 </row>
832 <row>
833 <entry role="catalog_table_entry"><para role="column_definition">
834 <structfield>xact_start</structfield> <type>timestamp with time zone</type>
835 </para>
836 <para>
837 Time when this process' current transaction was started, or null
838 if no transaction is active. If the current
839 query is the first of its transaction, this column is equal to the
840 <structfield>query_start</structfield> column.
841 </para></entry>
842 </row>
844 <row>
845 <entry role="catalog_table_entry"><para role="column_definition">
846 <structfield>query_start</structfield> <type>timestamp with time zone</type>
847 </para>
848 <para>
849 Time when the currently active query was started, or if
850 <structfield>state</structfield> is not <literal>active</literal>, when the last query
851 was started
852 </para></entry>
853 </row>
855 <row>
856 <entry role="catalog_table_entry"><para role="column_definition">
857 <structfield>state_change</structfield> <type>timestamp with time zone</type>
858 </para>
859 <para>
860 Time when the <structfield>state</structfield> was last changed
861 </para></entry>
862 </row>
864 <row>
865 <entry role="catalog_table_entry"><para role="column_definition">
866 <structfield>wait_event_type</structfield> <type>text</type>
867 </para>
868 <para>
869 The type of event for which the backend is waiting, if any;
870 otherwise NULL. See <xref linkend="wait-event-table"/>.
871 </para></entry>
872 </row>
874 <row>
875 <entry role="catalog_table_entry"><para role="column_definition">
876 <structfield>wait_event</structfield> <type>text</type>
877 </para>
878 <para>
879 Wait event name if backend is currently waiting, otherwise NULL.
880 See <xref linkend="wait-event-activity-table"/> through
881 <xref linkend="wait-event-timeout-table"/>.
882 </para></entry>
883 </row>
885 <row>
886 <entry role="catalog_table_entry"><para role="column_definition">
887 <structfield>state</structfield> <type>text</type>
888 </para>
889 <para>
890 Current overall state of this backend.
891 Possible values are:
892 <itemizedlist>
893 <listitem>
894 <para>
895 <literal>active</literal>: The backend is executing a query.
896 </para>
897 </listitem>
898 <listitem>
899 <para>
900 <literal>idle</literal>: The backend is waiting for a new client command.
901 </para>
902 </listitem>
903 <listitem>
904 <para>
905 <literal>idle in transaction</literal>: The backend is in a transaction,
906 but is not currently executing a query.
907 </para>
908 </listitem>
909 <listitem>
910 <para>
911 <literal>idle in transaction (aborted)</literal>: This state is similar to
912 <literal>idle in transaction</literal>, except one of the statements in
913 the transaction caused an error.
914 </para>
915 </listitem>
916 <listitem>
917 <para>
918 <literal>fastpath function call</literal>: The backend is executing a
919 fast-path function.
920 </para>
921 </listitem>
922 <listitem>
923 <para>
924 <literal>disabled</literal>: This state is reported if <xref linkend="guc-track-activities"/> is disabled in this backend.
925 </para>
926 </listitem>
927 </itemizedlist>
928 </para></entry>
929 </row>
931 <row>
932 <entry role="catalog_table_entry"><para role="column_definition">
933 <structfield>backend_xid</structfield> <type>xid</type>
934 </para>
935 <para>
936 Top-level transaction identifier of this backend, if any; see
937 <xref linkend="transaction-id"/>.
938 </para></entry>
939 </row>
941 <row>
942 <entry role="catalog_table_entry"><para role="column_definition">
943 <structfield>backend_xmin</structfield> <type>xid</type>
944 </para>
945 <para>
946 The current backend's <literal>xmin</literal> horizon.
947 </para></entry>
948 </row>
950 <row>
951 <entry role="catalog_table_entry"><para role="column_definition">
952 <structfield>query_id</structfield> <type>bigint</type>
953 </para>
954 <para>
955 Identifier of this backend's most recent query. If
956 <structfield>state</structfield> is <literal>active</literal> this
957 field shows the identifier of the currently executing query. In
958 all other states, it shows the identifier of last query that was
959 executed. Query identifiers are not computed by default so this
960 field will be null unless <xref linkend="guc-compute-query-id"/>
961 parameter is enabled or a third-party module that computes query
962 identifiers is configured.
963 </para></entry>
964 </row>
966 <row>
967 <entry role="catalog_table_entry"><para role="column_definition">
968 <structfield>query</structfield> <type>text</type>
969 </para>
970 <para>
971 Text of this backend's most recent query. If
972 <structfield>state</structfield> is <literal>active</literal> this field shows the
973 currently executing query. In all other states, it shows the last query
974 that was executed. By default the query text is truncated at 1024
975 bytes; this value can be changed via the parameter
976 <xref linkend="guc-track-activity-query-size"/>.
977 </para></entry>
978 </row>
980 <row>
981 <entry role="catalog_table_entry"><para role="column_definition">
982 <structfield>backend_type</structfield> <type>text</type>
983 </para>
984 <para>
985 Type of current backend. Possible types are
986 <literal>autovacuum launcher</literal>, <literal>autovacuum worker</literal>,
987 <literal>logical replication launcher</literal>,
988 <literal>logical replication worker</literal>,
989 <literal>parallel worker</literal>, <literal>background writer</literal>,
990 <literal>client backend</literal>, <literal>checkpointer</literal>,
991 <literal>archiver</literal>,
992 <literal>startup</literal>, <literal>walreceiver</literal>,
993 <literal>walsender</literal> and <literal>walwriter</literal>.
994 In addition, background workers registered by extensions may have
995 additional types.
996 </para></entry>
997 </row>
998 </tbody>
999 </tgroup>
1000 </table>
1002 <note>
1003 <para>
1004 The <structfield>wait_event</structfield> and <structfield>state</structfield> columns are
1005 independent. If a backend is in the <literal>active</literal> state,
1006 it may or may not be <literal>waiting</literal> on some event. If the state
1007 is <literal>active</literal> and <structfield>wait_event</structfield> is non-null, it
1008 means that a query is being executed, but is being blocked somewhere
1009 in the system.
1010 </para>
1011 </note>
1013 <table id="wait-event-table">
1014 <title>Wait Event Types</title>
1015 <tgroup cols="2">
1016 <thead>
1017 <row>
1018 <entry>Wait Event Type</entry>
1019 <entry>Description</entry>
1020 </row>
1021 </thead>
1023 <tbody>
1024 <row>
1025 <entry><literal>Activity</literal></entry>
1026 <entry>The server process is idle. This event type indicates a process
1027 waiting for activity in its main processing loop.
1028 <literal>wait_event</literal> will identify the specific wait point;
1029 see <xref linkend="wait-event-activity-table"/>.
1030 </entry>
1031 </row>
1032 <row>
1033 <entry><literal>BufferPin</literal></entry>
1034 <entry>The server process is waiting for exclusive access to
1035 a data buffer. Buffer pin waits can be protracted if
1036 another process holds an open cursor that last read data from the
1037 buffer in question. See <xref linkend="wait-event-bufferpin-table"/>.
1038 </entry>
1039 </row>
1040 <row>
1041 <entry><literal>Client</literal></entry>
1042 <entry>The server process is waiting for activity on a socket
1043 connected to a user application. Thus, the server expects something
1044 to happen that is independent of its internal processes.
1045 <literal>wait_event</literal> will identify the specific wait point;
1046 see <xref linkend="wait-event-client-table"/>.
1047 </entry>
1048 </row>
1049 <row>
1050 <entry><literal>Extension</literal></entry>
1051 <entry>The server process is waiting for some condition defined by an
1052 extension module.
1053 See <xref linkend="wait-event-extension-table"/>.
1054 </entry>
1055 </row>
1056 <row>
1057 <entry><literal>IO</literal></entry>
1058 <entry>The server process is waiting for an I/O operation to complete.
1059 <literal>wait_event</literal> will identify the specific wait point;
1060 see <xref linkend="wait-event-io-table"/>.
1061 </entry>
1062 </row>
1063 <row>
1064 <entry><literal>IPC</literal></entry>
1065 <entry>The server process is waiting for some interaction with
1066 another server process. <literal>wait_event</literal> will
1067 identify the specific wait point;
1068 see <xref linkend="wait-event-ipc-table"/>.
1069 </entry>
1070 </row>
1071 <row>
1072 <entry><literal>Lock</literal></entry>
1073 <entry>The server process is waiting for a heavyweight lock.
1074 Heavyweight locks, also known as lock manager locks or simply locks,
1075 primarily protect SQL-visible objects such as tables. However,
1076 they are also used to ensure mutual exclusion for certain internal
1077 operations such as relation extension. <literal>wait_event</literal>
1078 will identify the type of lock awaited;
1079 see <xref linkend="wait-event-lock-table"/>.
1080 </entry>
1081 </row>
1082 <row>
1083 <entry><literal>LWLock</literal></entry>
1084 <entry> The server process is waiting for a lightweight lock.
1085 Most such locks protect a particular data structure in shared memory.
1086 <literal>wait_event</literal> will contain a name identifying the purpose
1087 of the lightweight lock. (Some locks have specific names; others
1088 are part of a group of locks each with a similar purpose.)
1089 See <xref linkend="wait-event-lwlock-table"/>.
1090 </entry>
1091 </row>
1092 <row>
1093 <entry><literal>Timeout</literal></entry>
1094 <entry>The server process is waiting for a timeout
1095 to expire. <literal>wait_event</literal> will identify the specific wait
1096 point; see <xref linkend="wait-event-timeout-table"/>.
1097 </entry>
1098 </row>
1099 </tbody>
1100 </tgroup>
1101 </table>
1103 <table id="wait-event-activity-table">
1104 <title>Wait Events of Type <literal>Activity</literal></title>
1105 <tgroup cols="2">
1106 <thead>
1107 <row>
1108 <entry><literal>Activity</literal> Wait Event</entry>
1109 <entry>Description</entry>
1110 </row>
1111 </thead>
1113 <tbody>
1114 <row>
1115 <entry><literal>ArchiverMain</literal></entry>
1116 <entry>Waiting in main loop of archiver process.</entry>
1117 </row>
1118 <row>
1119 <entry><literal>AutoVacuumMain</literal></entry>
1120 <entry>Waiting in main loop of autovacuum launcher process.</entry>
1121 </row>
1122 <row>
1123 <entry><literal>BgWriterHibernate</literal></entry>
1124 <entry>Waiting in background writer process, hibernating.</entry>
1125 </row>
1126 <row>
1127 <entry><literal>BgWriterMain</literal></entry>
1128 <entry>Waiting in main loop of background writer process.</entry>
1129 </row>
1130 <row>
1131 <entry><literal>CheckpointerMain</literal></entry>
1132 <entry>Waiting in main loop of checkpointer process.</entry>
1133 </row>
1134 <row>
1135 <entry><literal>LogicalApplyMain</literal></entry>
1136 <entry>Waiting in main loop of logical replication apply process.</entry>
1137 </row>
1138 <row>
1139 <entry><literal>LogicalLauncherMain</literal></entry>
1140 <entry>Waiting in main loop of logical replication launcher process.</entry>
1141 </row>
1142 <row>
1143 <entry><literal>LogicalParallelApplyMain</literal></entry>
1144 <entry>Waiting in main loop of logical replication parallel apply
1145 process.</entry>
1146 </row>
1147 <row>
1148 <entry><literal>RecoveryWalStream</literal></entry>
1149 <entry>Waiting in main loop of startup process for WAL to arrive, during
1150 streaming recovery.</entry>
1151 </row>
1152 <row>
1153 <entry><literal>SysLoggerMain</literal></entry>
1154 <entry>Waiting in main loop of syslogger process.</entry>
1155 </row>
1156 <row>
1157 <entry><literal>WalReceiverMain</literal></entry>
1158 <entry>Waiting in main loop of WAL receiver process.</entry>
1159 </row>
1160 <row>
1161 <entry><literal>WalSenderMain</literal></entry>
1162 <entry>Waiting in main loop of WAL sender process.</entry>
1163 </row>
1164 <row>
1165 <entry><literal>WalWriterMain</literal></entry>
1166 <entry>Waiting in main loop of WAL writer process.</entry>
1167 </row>
1168 </tbody>
1169 </tgroup>
1170 </table>
1172 <table id="wait-event-bufferpin-table">
1173 <title>Wait Events of Type <literal>BufferPin</literal></title>
1174 <tgroup cols="2">
1175 <thead>
1176 <row>
1177 <entry><literal>BufferPin</literal> Wait Event</entry>
1178 <entry>Description</entry>
1179 </row>
1180 </thead>
1182 <tbody>
1183 <row>
1184 <entry><literal>BufferPin</literal></entry>
1185 <entry>Waiting to acquire an exclusive pin on a buffer.</entry>
1186 </row>
1187 </tbody>
1188 </tgroup>
1189 </table>
1191 <table id="wait-event-client-table">
1192 <title>Wait Events of Type <literal>Client</literal></title>
1193 <tgroup cols="2">
1194 <thead>
1195 <row>
1196 <entry><literal>Client</literal> Wait Event</entry>
1197 <entry>Description</entry>
1198 </row>
1199 </thead>
1201 <tbody>
1202 <row>
1203 <entry><literal>ClientRead</literal></entry>
1204 <entry>Waiting to read data from the client.</entry>
1205 </row>
1206 <row>
1207 <entry><literal>ClientWrite</literal></entry>
1208 <entry>Waiting to write data to the client.</entry>
1209 </row>
1210 <row>
1211 <entry><literal>GSSOpenServer</literal></entry>
1212 <entry>Waiting to read data from the client while establishing a GSSAPI
1213 session.</entry>
1214 </row>
1215 <row>
1216 <entry><literal>LibPQWalReceiverConnect</literal></entry>
1217 <entry>Waiting in WAL receiver to establish connection to remote
1218 server.</entry>
1219 </row>
1220 <row>
1221 <entry><literal>LibPQWalReceiverReceive</literal></entry>
1222 <entry>Waiting in WAL receiver to receive data from remote server.</entry>
1223 </row>
1224 <row>
1225 <entry><literal>SSLOpenServer</literal></entry>
1226 <entry>Waiting for SSL while attempting connection.</entry>
1227 </row>
1228 <row>
1229 <entry><literal>WalSenderWaitForWAL</literal></entry>
1230 <entry>Waiting for WAL to be flushed in WAL sender process.</entry>
1231 </row>
1232 <row>
1233 <entry><literal>WalSenderWriteData</literal></entry>
1234 <entry>Waiting for any activity when processing replies from WAL
1235 receiver in WAL sender process.</entry>
1236 </row>
1237 </tbody>
1238 </tgroup>
1239 </table>
1241 <table id="wait-event-extension-table">
1242 <title>Wait Events of Type <literal>Extension</literal></title>
1243 <tgroup cols="2">
1244 <thead>
1245 <row>
1246 <entry><literal>Extension</literal> Wait Event</entry>
1247 <entry>Description</entry>
1248 </row>
1249 </thead>
1251 <tbody>
1252 <row>
1253 <entry><literal>Extension</literal></entry>
1254 <entry>Waiting in an extension.</entry>
1255 </row>
1256 </tbody>
1257 </tgroup>
1258 </table>
1260 <table id="wait-event-io-table">
1261 <title>Wait Events of Type <literal>IO</literal></title>
1262 <tgroup cols="2">
1263 <thead>
1264 <row>
1265 <entry><literal>IO</literal> Wait Event</entry>
1266 <entry>Description</entry>
1267 </row>
1268 </thead>
1270 <tbody>
1271 <row>
1272 <entry><literal>BaseBackupRead</literal></entry>
1273 <entry>Waiting for base backup to read from a file.</entry>
1274 </row>
1275 <row>
1276 <entry><literal>BufFileRead</literal></entry>
1277 <entry>Waiting for a read from a buffered file.</entry>
1278 </row>
1279 <row>
1280 <entry><literal>BufFileWrite</literal></entry>
1281 <entry>Waiting for a write to a buffered file.</entry>
1282 </row>
1283 <row>
1284 <entry><literal>BufFileTruncate</literal></entry>
1285 <entry>Waiting for a buffered file to be truncated.</entry>
1286 </row>
1287 <row>
1288 <entry><literal>ControlFileRead</literal></entry>
1289 <entry>Waiting for a read from the <filename>pg_control</filename>
1290 file.</entry>
1291 </row>
1292 <row>
1293 <entry><literal>ControlFileSync</literal></entry>
1294 <entry>Waiting for the <filename>pg_control</filename> file to reach
1295 durable storage.</entry>
1296 </row>
1297 <row>
1298 <entry><literal>ControlFileSyncUpdate</literal></entry>
1299 <entry>Waiting for an update to the <filename>pg_control</filename> file
1300 to reach durable storage.</entry>
1301 </row>
1302 <row>
1303 <entry><literal>ControlFileWrite</literal></entry>
1304 <entry>Waiting for a write to the <filename>pg_control</filename>
1305 file.</entry>
1306 </row>
1307 <row>
1308 <entry><literal>ControlFileWriteUpdate</literal></entry>
1309 <entry>Waiting for a write to update the <filename>pg_control</filename>
1310 file.</entry>
1311 </row>
1312 <row>
1313 <entry><literal>CopyFileRead</literal></entry>
1314 <entry>Waiting for a read during a file copy operation.</entry>
1315 </row>
1316 <row>
1317 <entry><literal>CopyFileWrite</literal></entry>
1318 <entry>Waiting for a write during a file copy operation.</entry>
1319 </row>
1320 <row>
1321 <entry><literal>DSMAllocate</literal></entry>
1322 <entry>Waiting for a dynamic shared memory segment to be
1323 allocated.</entry>
1324 </row>
1325 <row>
1326 <entry><literal>DSMFillZeroWrite</literal></entry>
1327 <entry>Waiting to fill a dynamic shared memory backing file with
1328 zeroes.</entry>
1329 </row>
1330 <row>
1331 <entry><literal>DataFileExtend</literal></entry>
1332 <entry>Waiting for a relation data file to be extended.</entry>
1333 </row>
1334 <row>
1335 <entry><literal>DataFileFlush</literal></entry>
1336 <entry>Waiting for a relation data file to reach durable storage.</entry>
1337 </row>
1338 <row>
1339 <entry><literal>DataFileImmediateSync</literal></entry>
1340 <entry>Waiting for an immediate synchronization of a relation data file to
1341 durable storage.</entry>
1342 </row>
1343 <row>
1344 <entry><literal>DataFilePrefetch</literal></entry>
1345 <entry>Waiting for an asynchronous prefetch from a relation data
1346 file.</entry>
1347 </row>
1348 <row>
1349 <entry><literal>DataFileRead</literal></entry>
1350 <entry>Waiting for a read from a relation data file.</entry>
1351 </row>
1352 <row>
1353 <entry><literal>DataFileSync</literal></entry>
1354 <entry>Waiting for changes to a relation data file to reach durable storage.</entry>
1355 </row>
1356 <row>
1357 <entry><literal>DataFileTruncate</literal></entry>
1358 <entry>Waiting for a relation data file to be truncated.</entry>
1359 </row>
1360 <row>
1361 <entry><literal>DataFileWrite</literal></entry>
1362 <entry>Waiting for a write to a relation data file.</entry>
1363 </row>
1364 <row>
1365 <entry><literal>LockFileAddToDataDirRead</literal></entry>
1366 <entry>Waiting for a read while adding a line to the data directory lock
1367 file.</entry>
1368 </row>
1369 <row>
1370 <entry><literal>LockFileAddToDataDirSync</literal></entry>
1371 <entry>Waiting for data to reach durable storage while adding a line to the
1372 data directory lock file.</entry>
1373 </row>
1374 <row>
1375 <entry><literal>LockFileAddToDataDirWrite</literal></entry>
1376 <entry>Waiting for a write while adding a line to the data directory
1377 lock file.</entry>
1378 </row>
1379 <row>
1380 <entry><literal>LockFileCreateRead</literal></entry>
1381 <entry>Waiting to read while creating the data directory lock
1382 file.</entry>
1383 </row>
1384 <row>
1385 <entry><literal>LockFileCreateSync</literal></entry>
1386 <entry>Waiting for data to reach durable storage while creating the data
1387 directory lock file.</entry>
1388 </row>
1389 <row>
1390 <entry><literal>LockFileCreateWrite</literal></entry>
1391 <entry>Waiting for a write while creating the data directory lock
1392 file.</entry>
1393 </row>
1394 <row>
1395 <entry><literal>LockFileReCheckDataDirRead</literal></entry>
1396 <entry>Waiting for a read during recheck of the data directory lock
1397 file.</entry>
1398 </row>
1399 <row>
1400 <entry><literal>LogicalRewriteCheckpointSync</literal></entry>
1401 <entry>Waiting for logical rewrite mappings to reach durable storage
1402 during a checkpoint.</entry>
1403 </row>
1404 <row>
1405 <entry><literal>LogicalRewriteMappingSync</literal></entry>
1406 <entry>Waiting for mapping data to reach durable storage during a logical
1407 rewrite.</entry>
1408 </row>
1409 <row>
1410 <entry><literal>LogicalRewriteMappingWrite</literal></entry>
1411 <entry>Waiting for a write of mapping data during a logical
1412 rewrite.</entry>
1413 </row>
1414 <row>
1415 <entry><literal>LogicalRewriteSync</literal></entry>
1416 <entry>Waiting for logical rewrite mappings to reach durable
1417 storage.</entry>
1418 </row>
1419 <row>
1420 <entry><literal>LogicalRewriteTruncate</literal></entry>
1421 <entry>Waiting for truncate of mapping data during a logical
1422 rewrite.</entry>
1423 </row>
1424 <row>
1425 <entry><literal>LogicalRewriteWrite</literal></entry>
1426 <entry>Waiting for a write of logical rewrite mappings.</entry>
1427 </row>
1428 <row>
1429 <entry><literal>RelationMapRead</literal></entry>
1430 <entry>Waiting for a read of the relation map file.</entry>
1431 </row>
1432 <row>
1433 <entry><literal>RelationMapReplace</literal></entry>
1434 <entry>Waiting for durable replacement of a relation map file.</entry>
1435 </row>
1436 <row>
1437 <entry><literal>RelationMapWrite</literal></entry>
1438 <entry>Waiting for a write to the relation map file.</entry>
1439 </row>
1440 <row>
1441 <entry><literal>ReorderBufferRead</literal></entry>
1442 <entry>Waiting for a read during reorder buffer management.</entry>
1443 </row>
1444 <row>
1445 <entry><literal>ReorderBufferWrite</literal></entry>
1446 <entry>Waiting for a write during reorder buffer management.</entry>
1447 </row>
1448 <row>
1449 <entry><literal>ReorderLogicalMappingRead</literal></entry>
1450 <entry>Waiting for a read of a logical mapping during reorder buffer
1451 management.</entry>
1452 </row>
1453 <row>
1454 <entry><literal>ReplicationSlotRead</literal></entry>
1455 <entry>Waiting for a read from a replication slot control file.</entry>
1456 </row>
1457 <row>
1458 <entry><literal>ReplicationSlotRestoreSync</literal></entry>
1459 <entry>Waiting for a replication slot control file to reach durable storage
1460 while restoring it to memory.</entry>
1461 </row>
1462 <row>
1463 <entry><literal>ReplicationSlotSync</literal></entry>
1464 <entry>Waiting for a replication slot control file to reach durable
1465 storage.</entry>
1466 </row>
1467 <row>
1468 <entry><literal>ReplicationSlotWrite</literal></entry>
1469 <entry>Waiting for a write to a replication slot control file.</entry>
1470 </row>
1471 <row>
1472 <entry><literal>SLRUFlushSync</literal></entry>
1473 <entry>Waiting for SLRU data to reach durable storage during a checkpoint
1474 or database shutdown.</entry>
1475 </row>
1476 <row>
1477 <entry><literal>SLRURead</literal></entry>
1478 <entry>Waiting for a read of an SLRU page.</entry>
1479 </row>
1480 <row>
1481 <entry><literal>SLRUSync</literal></entry>
1482 <entry>Waiting for SLRU data to reach durable storage following a page
1483 write.</entry>
1484 </row>
1485 <row>
1486 <entry><literal>SLRUWrite</literal></entry>
1487 <entry>Waiting for a write of an SLRU page.</entry>
1488 </row>
1489 <row>
1490 <entry><literal>SnapbuildRead</literal></entry>
1491 <entry>Waiting for a read of a serialized historical catalog
1492 snapshot.</entry>
1493 </row>
1494 <row>
1495 <entry><literal>SnapbuildSync</literal></entry>
1496 <entry>Waiting for a serialized historical catalog snapshot to reach
1497 durable storage.</entry>
1498 </row>
1499 <row>
1500 <entry><literal>SnapbuildWrite</literal></entry>
1501 <entry>Waiting for a write of a serialized historical catalog
1502 snapshot.</entry>
1503 </row>
1504 <row>
1505 <entry><literal>TimelineHistoryFileSync</literal></entry>
1506 <entry>Waiting for a timeline history file received via streaming
1507 replication to reach durable storage.</entry>
1508 </row>
1509 <row>
1510 <entry><literal>TimelineHistoryFileWrite</literal></entry>
1511 <entry>Waiting for a write of a timeline history file received via
1512 streaming replication.</entry>
1513 </row>
1514 <row>
1515 <entry><literal>TimelineHistoryRead</literal></entry>
1516 <entry>Waiting for a read of a timeline history file.</entry>
1517 </row>
1518 <row>
1519 <entry><literal>TimelineHistorySync</literal></entry>
1520 <entry>Waiting for a newly created timeline history file to reach durable
1521 storage.</entry>
1522 </row>
1523 <row>
1524 <entry><literal>TimelineHistoryWrite</literal></entry>
1525 <entry>Waiting for a write of a newly created timeline history
1526 file.</entry>
1527 </row>
1528 <row>
1529 <entry><literal>TwophaseFileRead</literal></entry>
1530 <entry>Waiting for a read of a two phase state file.</entry>
1531 </row>
1532 <row>
1533 <entry><literal>TwophaseFileSync</literal></entry>
1534 <entry>Waiting for a two phase state file to reach durable storage.</entry>
1535 </row>
1536 <row>
1537 <entry><literal>TwophaseFileWrite</literal></entry>
1538 <entry>Waiting for a write of a two phase state file.</entry>
1539 </row>
1540 <row>
1541 <entry><literal>VersionFileWrite</literal></entry>
1542 <entry>Waiting for the version file to be written while creating a database.</entry>
1543 </row>
1544 <row>
1545 <entry><literal>WALBootstrapSync</literal></entry>
1546 <entry>Waiting for WAL to reach durable storage during
1547 bootstrapping.</entry>
1548 </row>
1549 <row>
1550 <entry><literal>WALBootstrapWrite</literal></entry>
1551 <entry>Waiting for a write of a WAL page during bootstrapping.</entry>
1552 </row>
1553 <row>
1554 <entry><literal>WALCopyRead</literal></entry>
1555 <entry>Waiting for a read when creating a new WAL segment by copying an
1556 existing one.</entry>
1557 </row>
1558 <row>
1559 <entry><literal>WALCopySync</literal></entry>
1560 <entry>Waiting for a new WAL segment created by copying an existing one to
1561 reach durable storage.</entry>
1562 </row>
1563 <row>
1564 <entry><literal>WALCopyWrite</literal></entry>
1565 <entry>Waiting for a write when creating a new WAL segment by copying an
1566 existing one.</entry>
1567 </row>
1568 <row>
1569 <entry><literal>WALInitSync</literal></entry>
1570 <entry>Waiting for a newly initialized WAL file to reach durable
1571 storage.</entry>
1572 </row>
1573 <row>
1574 <entry><literal>WALInitWrite</literal></entry>
1575 <entry>Waiting for a write while initializing a new WAL file.</entry>
1576 </row>
1577 <row>
1578 <entry><literal>WALRead</literal></entry>
1579 <entry>Waiting for a read from a WAL file.</entry>
1580 </row>
1581 <row>
1582 <entry><literal>WALSenderTimelineHistoryRead</literal></entry>
1583 <entry>Waiting for a read from a timeline history file during a walsender
1584 timeline command.</entry>
1585 </row>
1586 <row>
1587 <entry><literal>WALSync</literal></entry>
1588 <entry>Waiting for a WAL file to reach durable storage.</entry>
1589 </row>
1590 <row>
1591 <entry><literal>WALSyncMethodAssign</literal></entry>
1592 <entry>Waiting for data to reach durable storage while assigning a new
1593 WAL sync method.</entry>
1594 </row>
1595 <row>
1596 <entry><literal>WALWrite</literal></entry>
1597 <entry>Waiting for a write to a WAL file.</entry>
1598 </row>
1599 </tbody>
1600 </tgroup>
1601 </table>
1603 <table id="wait-event-ipc-table">
1604 <title>Wait Events of Type <literal>IPC</literal></title>
1605 <tgroup cols="2">
1606 <thead>
1607 <row>
1608 <entry><literal>IPC</literal> Wait Event</entry>
1609 <entry>Description</entry>
1610 </row>
1611 </thead>
1613 <tbody>
1614 <row>
1615 <entry><literal>AppendReady</literal></entry>
1616 <entry>Waiting for subplan nodes of an <literal>Append</literal> plan
1617 node to be ready.</entry>
1618 </row>
1619 <row>
1620 <entry><literal>ArchiveCleanupCommand</literal></entry>
1621 <entry>Waiting for <xref linkend="guc-archive-cleanup-command"/> to
1622 complete.</entry>
1623 </row>
1624 <row>
1625 <entry><literal>ArchiveCommand</literal></entry>
1626 <entry>Waiting for <xref linkend="guc-archive-command"/> to
1627 complete.</entry>
1628 </row>
1629 <row>
1630 <entry><literal>BackendTermination</literal></entry>
1631 <entry>Waiting for the termination of another backend.</entry>
1632 </row>
1633 <row>
1634 <entry><literal>BackupWaitWalArchive</literal></entry>
1635 <entry>Waiting for WAL files required for a backup to be successfully
1636 archived.</entry>
1637 </row>
1638 <row>
1639 <entry><literal>BgWorkerShutdown</literal></entry>
1640 <entry>Waiting for background worker to shut down.</entry>
1641 </row>
1642 <row>
1643 <entry><literal>BgWorkerStartup</literal></entry>
1644 <entry>Waiting for background worker to start up.</entry>
1645 </row>
1646 <row>
1647 <entry><literal>BtreePage</literal></entry>
1648 <entry>Waiting for the page number needed to continue a parallel B-tree
1649 scan to become available.</entry>
1650 </row>
1651 <row>
1652 <entry><literal>BufferIO</literal></entry>
1653 <entry>Waiting for buffer I/O to complete.</entry>
1654 </row>
1655 <row>
1656 <entry><literal>CheckpointDone</literal></entry>
1657 <entry>Waiting for a checkpoint to complete.</entry>
1658 </row>
1659 <row>
1660 <entry><literal>CheckpointStart</literal></entry>
1661 <entry>Waiting for a checkpoint to start.</entry>
1662 </row>
1663 <row>
1664 <entry><literal>ExecuteGather</literal></entry>
1665 <entry>Waiting for activity from a child process while
1666 executing a <literal>Gather</literal> plan node.</entry>
1667 </row>
1668 <row>
1669 <entry><literal>HashBatchAllocate</literal></entry>
1670 <entry>Waiting for an elected Parallel Hash participant to allocate a hash
1671 table.</entry>
1672 </row>
1673 <row>
1674 <entry><literal>HashBatchElect</literal></entry>
1675 <entry>Waiting to elect a Parallel Hash participant to allocate a hash
1676 table.</entry>
1677 </row>
1678 <row>
1679 <entry><literal>HashBatchLoad</literal></entry>
1680 <entry>Waiting for other Parallel Hash participants to finish loading a
1681 hash table.</entry>
1682 </row>
1683 <row>
1684 <entry><literal>HashBuildAllocate</literal></entry>
1685 <entry>Waiting for an elected Parallel Hash participant to allocate the
1686 initial hash table.</entry>
1687 </row>
1688 <row>
1689 <entry><literal>HashBuildElect</literal></entry>
1690 <entry>Waiting to elect a Parallel Hash participant to allocate the
1691 initial hash table.</entry>
1692 </row>
1693 <row>
1694 <entry><literal>HashBuildHashInner</literal></entry>
1695 <entry>Waiting for other Parallel Hash participants to finish hashing the
1696 inner relation.</entry>
1697 </row>
1698 <row>
1699 <entry><literal>HashBuildHashOuter</literal></entry>
1700 <entry>Waiting for other Parallel Hash participants to finish partitioning
1701 the outer relation.</entry>
1702 </row>
1703 <row>
1704 <entry><literal>HashGrowBatchesDecide</literal></entry>
1705 <entry>Waiting to elect a Parallel Hash participant to decide on future
1706 batch growth.</entry>
1707 </row>
1708 <row>
1709 <entry><literal>HashGrowBatchesElect</literal></entry>
1710 <entry>Waiting to elect a Parallel Hash participant to allocate more
1711 batches.</entry>
1712 </row>
1713 <row>
1714 <entry><literal>HashGrowBatchesFinish</literal></entry>
1715 <entry>Waiting for an elected Parallel Hash participant to decide on
1716 future batch growth.</entry>
1717 </row>
1718 <row>
1719 <entry><literal>HashGrowBatchesReallocate</literal></entry>
1720 <entry>Waiting for an elected Parallel Hash participant to allocate more
1721 batches.</entry>
1722 </row>
1723 <row>
1724 <entry><literal>HashGrowBatchesRepartition</literal></entry>
1725 <entry>Waiting for other Parallel Hash participants to finish
1726 repartitioning.</entry>
1727 </row>
1728 <row>
1729 <entry><literal>HashGrowBucketsElect</literal></entry>
1730 <entry>Waiting to elect a Parallel Hash participant to allocate more
1731 buckets.</entry>
1732 </row>
1733 <row>
1734 <entry><literal>HashGrowBucketsReallocate</literal></entry>
1735 <entry>Waiting for an elected Parallel Hash participant to finish
1736 allocating more buckets.</entry>
1737 </row>
1738 <row>
1739 <entry><literal>HashGrowBucketsReinsert</literal></entry>
1740 <entry>Waiting for other Parallel Hash participants to finish inserting
1741 tuples into new buckets.</entry>
1742 </row>
1743 <row>
1744 <entry><literal>LogicalApplySendData</literal></entry>
1745 <entry>Waiting for a logical replication leader apply process to send
1746 data to a parallel apply process.</entry>
1747 </row>
1748 <row>
1749 <entry><literal>LogicalParallelApplyStateChange</literal></entry>
1750 <entry>Waiting for a logical replication parallel apply process to change
1751 state.</entry>
1752 </row>
1753 <row>
1754 <entry><literal>LogicalSyncData</literal></entry>
1755 <entry>Waiting for a logical replication remote server to send data for
1756 initial table synchronization.</entry>
1757 </row>
1758 <row>
1759 <entry><literal>LogicalSyncStateChange</literal></entry>
1760 <entry>Waiting for a logical replication remote server to change
1761 state.</entry>
1762 </row>
1763 <row>
1764 <entry><literal>MessageQueueInternal</literal></entry>
1765 <entry>Waiting for another process to be attached to a shared message
1766 queue.</entry>
1767 </row>
1768 <row>
1769 <entry><literal>MessageQueuePutMessage</literal></entry>
1770 <entry>Waiting to write a protocol message to a shared message queue.</entry>
1771 </row>
1772 <row>
1773 <entry><literal>MessageQueueReceive</literal></entry>
1774 <entry>Waiting to receive bytes from a shared message queue.</entry>
1775 </row>
1776 <row>
1777 <entry><literal>MessageQueueSend</literal></entry>
1778 <entry>Waiting to send bytes to a shared message queue.</entry>
1779 </row>
1780 <row>
1781 <entry><literal>ParallelBitmapScan</literal></entry>
1782 <entry>Waiting for parallel bitmap scan to become initialized.</entry>
1783 </row>
1784 <row>
1785 <entry><literal>ParallelCreateIndexScan</literal></entry>
1786 <entry>Waiting for parallel <command>CREATE INDEX</command> workers to
1787 finish heap scan.</entry>
1788 </row>
1789 <row>
1790 <entry><literal>ParallelFinish</literal></entry>
1791 <entry>Waiting for parallel workers to finish computing.</entry>
1792 </row>
1793 <row>
1794 <entry><literal>ProcArrayGroupUpdate</literal></entry>
1795 <entry>Waiting for the group leader to clear the transaction ID at
1796 end of a parallel operation.</entry>
1797 </row>
1798 <row>
1799 <entry><literal>ProcSignalBarrier</literal></entry>
1800 <entry>Waiting for a barrier event to be processed by all
1801 backends.</entry>
1802 </row>
1803 <row>
1804 <entry><literal>Promote</literal></entry>
1805 <entry>Waiting for standby promotion.</entry>
1806 </row>
1807 <row>
1808 <entry><literal>RecoveryConflictSnapshot</literal></entry>
1809 <entry>Waiting for recovery conflict resolution for a vacuum
1810 cleanup.</entry>
1811 </row>
1812 <row>
1813 <entry><literal>RecoveryConflictTablespace</literal></entry>
1814 <entry>Waiting for recovery conflict resolution for dropping a
1815 tablespace.</entry>
1816 </row>
1817 <row>
1818 <entry><literal>RecoveryEndCommand</literal></entry>
1819 <entry>Waiting for <xref linkend="guc-recovery-end-command"/> to
1820 complete.</entry>
1821 </row>
1822 <row>
1823 <entry><literal>RecoveryPause</literal></entry>
1824 <entry>Waiting for recovery to be resumed.</entry>
1825 </row>
1826 <row>
1827 <entry><literal>ReplicationOriginDrop</literal></entry>
1828 <entry>Waiting for a replication origin to become inactive so it can be
1829 dropped.</entry>
1830 </row>
1831 <row>
1832 <entry><literal>ReplicationSlotDrop</literal></entry>
1833 <entry>Waiting for a replication slot to become inactive so it can be
1834 dropped.</entry>
1835 </row>
1836 <row>
1837 <entry><literal>RestoreCommand</literal></entry>
1838 <entry>Waiting for <xref linkend="guc-restore-command"/> to
1839 complete.</entry>
1840 </row>
1841 <row>
1842 <entry><literal>SafeSnapshot</literal></entry>
1843 <entry>Waiting to obtain a valid snapshot for a <literal>READ ONLY
1844 DEFERRABLE</literal> transaction.</entry>
1845 </row>
1846 <row>
1847 <entry><literal>SyncRep</literal></entry>
1848 <entry>Waiting for confirmation from a remote server during synchronous
1849 replication.</entry>
1850 </row>
1851 <row>
1852 <entry><literal>WalReceiverExit</literal></entry>
1853 <entry>Waiting for the WAL receiver to exit.</entry>
1854 </row>
1855 <row>
1856 <entry><literal>WalReceiverWaitStart</literal></entry>
1857 <entry>Waiting for startup process to send initial data for streaming
1858 replication.</entry>
1859 </row>
1860 <row>
1861 <entry><literal>XactGroupUpdate</literal></entry>
1862 <entry>Waiting for the group leader to update transaction status at
1863 end of a parallel operation.</entry>
1864 </row>
1865 </tbody>
1866 </tgroup>
1867 </table>
1869 <table id="wait-event-lock-table">
1870 <title>Wait Events of Type <literal>Lock</literal></title>
1871 <tgroup cols="2">
1872 <thead>
1873 <row>
1874 <entry><literal>Lock</literal> Wait Event</entry>
1875 <entry>Description</entry>
1876 </row>
1877 </thead>
1879 <tbody>
1880 <row>
1881 <entry><literal>advisory</literal></entry>
1882 <entry>Waiting to acquire an advisory user lock.</entry>
1883 </row>
1884 <row>
1885 <entry><literal>applytransaction</literal></entry>
1886 <entry>Waiting to acquire a lock on a remote transaction being applied
1887 by a logical replication subscriber.</entry>
1888 </row>
1889 <row>
1890 <entry><literal>extend</literal></entry>
1891 <entry>Waiting to extend a relation.</entry>
1892 </row>
1893 <row>
1894 <entry><literal>frozenid</literal></entry>
1895 <entry>Waiting to
1896 update <structname>pg_database</structname>.<structfield>datfrozenxid</structfield>
1897 and <structname>pg_database</structname>.<structfield>datminmxid</structfield>.</entry>
1898 </row>
1899 <row>
1900 <entry><literal>object</literal></entry>
1901 <entry>Waiting to acquire a lock on a non-relation database object.</entry>
1902 </row>
1903 <row>
1904 <entry><literal>page</literal></entry>
1905 <entry>Waiting to acquire a lock on a page of a relation.</entry>
1906 </row>
1907 <row>
1908 <entry><literal>relation</literal></entry>
1909 <entry>Waiting to acquire a lock on a relation.</entry>
1910 </row>
1911 <row>
1912 <entry><literal>spectoken</literal></entry>
1913 <entry>Waiting to acquire a speculative insertion lock.</entry>
1914 </row>
1915 <row>
1916 <entry><literal>transactionid</literal></entry>
1917 <entry>Waiting for a transaction to finish.</entry>
1918 </row>
1919 <row>
1920 <entry><literal>tuple</literal></entry>
1921 <entry>Waiting to acquire a lock on a tuple.</entry>
1922 </row>
1923 <row>
1924 <entry><literal>userlock</literal></entry>
1925 <entry>Waiting to acquire a user lock.</entry>
1926 </row>
1927 <row>
1928 <entry><literal>virtualxid</literal></entry>
1929 <entry>Waiting to acquire a virtual transaction ID lock; see
1930 <xref linkend="transaction-id"/>.</entry>
1931 </row>
1932 </tbody>
1933 </tgroup>
1934 </table>
1936 <table id="wait-event-lwlock-table">
1937 <title>Wait Events of Type <literal>LWLock</literal></title>
1938 <tgroup cols="2">
1939 <thead>
1940 <row>
1941 <entry><literal>LWLock</literal> Wait Event</entry>
1942 <entry>Description</entry>
1943 </row>
1944 </thead>
1946 <tbody>
1947 <row>
1948 <entry><literal>AddinShmemInit</literal></entry>
1949 <entry>Waiting to manage an extension's space allocation in shared
1950 memory.</entry>
1951 </row>
1952 <row>
1953 <entry><literal>AutoFile</literal></entry>
1954 <entry>Waiting to update the <filename>postgresql.auto.conf</filename>
1955 file.</entry>
1956 </row>
1957 <row>
1958 <entry><literal>Autovacuum</literal></entry>
1959 <entry>Waiting to read or update the current state of autovacuum
1960 workers.</entry>
1961 </row>
1962 <row>
1963 <entry><literal>AutovacuumSchedule</literal></entry>
1964 <entry>Waiting to ensure that a table selected for autovacuum
1965 still needs vacuuming.</entry>
1966 </row>
1967 <row>
1968 <entry><literal>BackgroundWorker</literal></entry>
1969 <entry>Waiting to read or update background worker state.</entry>
1970 </row>
1971 <row>
1972 <entry><literal>BtreeVacuum</literal></entry>
1973 <entry>Waiting to read or update vacuum-related information for a
1974 B-tree index.</entry>
1975 </row>
1976 <row>
1977 <entry><literal>BufferContent</literal></entry>
1978 <entry>Waiting to access a data page in memory.</entry>
1979 </row>
1980 <row>
1981 <entry><literal>BufferMapping</literal></entry>
1982 <entry>Waiting to associate a data block with a buffer in the buffer
1983 pool.</entry>
1984 </row>
1985 <row>
1986 <entry><literal>CheckpointerComm</literal></entry>
1987 <entry>Waiting to manage fsync requests.</entry>
1988 </row>
1989 <row>
1990 <entry><literal>CommitTs</literal></entry>
1991 <entry>Waiting to read or update the last value set for a
1992 transaction commit timestamp.</entry>
1993 </row>
1994 <row>
1995 <entry><literal>CommitTsBuffer</literal></entry>
1996 <entry>Waiting for I/O on a commit timestamp SLRU buffer.</entry>
1997 </row>
1998 <row>
1999 <entry><literal>CommitTsSLRU</literal></entry>
2000 <entry>Waiting to access the commit timestamp SLRU cache.</entry>
2001 </row>
2002 <row>
2003 <entry><literal>ControlFile</literal></entry>
2004 <entry>Waiting to read or update the <filename>pg_control</filename>
2005 file or create a new WAL file.</entry>
2006 </row>
2007 <row>
2008 <entry><literal>DynamicSharedMemoryControl</literal></entry>
2009 <entry>Waiting to read or update dynamic shared memory allocation
2010 information.</entry>
2011 </row>
2012 <row>
2013 <entry><literal>LockFastPath</literal></entry>
2014 <entry>Waiting to read or update a process' fast-path lock
2015 information.</entry>
2016 </row>
2017 <row>
2018 <entry><literal>LockManager</literal></entry>
2019 <entry>Waiting to read or update information
2020 about <quote>heavyweight</quote> locks.</entry>
2021 </row>
2022 <row>
2023 <entry><literal>LogicalRepLauncherDSA</literal></entry>
2024 <entry>Waiting to access logical replication launcher's dynamic shared
2025 memory allocator.</entry>
2026 </row>
2027 <row>
2028 <entry><literal>LogicalRepLauncherHash</literal></entry>
2029 <entry>Waiting to access logical replication launcher's shared
2030 hash table.</entry>
2031 </row>
2032 <row>
2033 <entry><literal>LogicalRepWorker</literal></entry>
2034 <entry>Waiting to read or update the state of logical replication
2035 workers.</entry>
2036 </row>
2037 <row>
2038 <entry><literal>MultiXactGen</literal></entry>
2039 <entry>Waiting to read or update shared multixact state.</entry>
2040 </row>
2041 <row>
2042 <entry><literal>MultiXactMemberBuffer</literal></entry>
2043 <entry>Waiting for I/O on a multixact member SLRU buffer.</entry>
2044 </row>
2045 <row>
2046 <entry><literal>MultiXactMemberSLRU</literal></entry>
2047 <entry>Waiting to access the multixact member SLRU cache.</entry>
2048 </row>
2049 <row>
2050 <entry><literal>MultiXactOffsetBuffer</literal></entry>
2051 <entry>Waiting for I/O on a multixact offset SLRU buffer.</entry>
2052 </row>
2053 <row>
2054 <entry><literal>MultiXactOffsetSLRU</literal></entry>
2055 <entry>Waiting to access the multixact offset SLRU cache.</entry>
2056 </row>
2057 <row>
2058 <entry><literal>MultiXactTruncation</literal></entry>
2059 <entry>Waiting to read or truncate multixact information.</entry>
2060 </row>
2061 <row>
2062 <entry><literal>NotifyBuffer</literal></entry>
2063 <entry>Waiting for I/O on a <command>NOTIFY</command> message SLRU
2064 buffer.</entry>
2065 </row>
2066 <row>
2067 <entry><literal>NotifyQueue</literal></entry>
2068 <entry>Waiting to read or update <command>NOTIFY</command> messages.</entry>
2069 </row>
2070 <row>
2071 <entry><literal>NotifyQueueTail</literal></entry>
2072 <entry>Waiting to update limit on <command>NOTIFY</command> message
2073 storage.</entry>
2074 </row>
2075 <row>
2076 <entry><literal>NotifySLRU</literal></entry>
2077 <entry>Waiting to access the <command>NOTIFY</command> message SLRU
2078 cache.</entry>
2079 </row>
2080 <row>
2081 <entry><literal>OidGen</literal></entry>
2082 <entry>Waiting to allocate a new OID.</entry>
2083 </row>
2084 <row>
2085 <entry><literal>OldSnapshotTimeMap</literal></entry>
2086 <entry>Waiting to read or update old snapshot control information.</entry>
2087 </row>
2088 <row>
2089 <entry><literal>ParallelAppend</literal></entry>
2090 <entry>Waiting to choose the next subplan during Parallel Append plan
2091 execution.</entry>
2092 </row>
2093 <row>
2094 <entry><literal>ParallelHashJoin</literal></entry>
2095 <entry>Waiting to synchronize workers during Parallel Hash Join plan
2096 execution.</entry>
2097 </row>
2098 <row>
2099 <entry><literal>ParallelQueryDSA</literal></entry>
2100 <entry>Waiting for parallel query dynamic shared memory allocation.</entry>
2101 </row>
2102 <row>
2103 <entry><literal>PerSessionDSA</literal></entry>
2104 <entry>Waiting for parallel query dynamic shared memory allocation.</entry>
2105 </row>
2106 <row>
2107 <entry><literal>PerSessionRecordType</literal></entry>
2108 <entry>Waiting to access a parallel query's information about composite
2109 types.</entry>
2110 </row>
2111 <row>
2112 <entry><literal>PerSessionRecordTypmod</literal></entry>
2113 <entry>Waiting to access a parallel query's information about type
2114 modifiers that identify anonymous record types.</entry>
2115 </row>
2116 <row>
2117 <entry><literal>PerXactPredicateList</literal></entry>
2118 <entry>Waiting to access the list of predicate locks held by the current
2119 serializable transaction during a parallel query.</entry>
2120 </row>
2121 <row>
2122 <entry><literal>PgStatsData</literal></entry>
2123 <entry>Waiting for shared memory stats data access</entry>
2124 </row>
2125 <row>
2126 <entry><literal>PgStatsDSA</literal></entry>
2127 <entry>Waiting for stats dynamic shared memory allocator access</entry>
2128 </row>
2129 <row>
2130 <entry><literal>PgStatsHash</literal></entry>
2131 <entry>Waiting for stats shared memory hash table access</entry>
2132 </row>
2133 <row>
2134 <entry><literal>PredicateLockManager</literal></entry>
2135 <entry>Waiting to access predicate lock information used by
2136 serializable transactions.</entry>
2137 </row>
2138 <row>
2139 <entry><literal>ProcArray</literal></entry>
2140 <entry>Waiting to access the shared per-process data structures
2141 (typically, to get a snapshot or report a session's transaction
2142 ID).</entry>
2143 </row>
2144 <row>
2145 <entry><literal>RelationMapping</literal></entry>
2146 <entry>Waiting to read or update
2147 a <filename>pg_filenode.map</filename> file (used to track the
2148 filenode assignments of certain system catalogs).</entry>
2149 </row>
2150 <row>
2151 <entry><literal>RelCacheInit</literal></entry>
2152 <entry>Waiting to read or update a <filename>pg_internal.init</filename>
2153 relation cache initialization file.</entry>
2154 </row>
2155 <row>
2156 <entry><literal>ReplicationOrigin</literal></entry>
2157 <entry>Waiting to create, drop or use a replication origin.</entry>
2158 </row>
2159 <row>
2160 <entry><literal>ReplicationOriginState</literal></entry>
2161 <entry>Waiting to read or update the progress of one replication
2162 origin.</entry>
2163 </row>
2164 <row>
2165 <entry><literal>ReplicationSlotAllocation</literal></entry>
2166 <entry>Waiting to allocate or free a replication slot.</entry>
2167 </row>
2168 <row>
2169 <entry><literal>ReplicationSlotControl</literal></entry>
2170 <entry>Waiting to read or update replication slot state.</entry>
2171 </row>
2172 <row>
2173 <entry><literal>ReplicationSlotIO</literal></entry>
2174 <entry>Waiting for I/O on a replication slot.</entry>
2175 </row>
2176 <row>
2177 <entry><literal>SerialBuffer</literal></entry>
2178 <entry>Waiting for I/O on a serializable transaction conflict SLRU
2179 buffer.</entry>
2180 </row>
2181 <row>
2182 <entry><literal>SerializableFinishedList</literal></entry>
2183 <entry>Waiting to access the list of finished serializable
2184 transactions.</entry>
2185 </row>
2186 <row>
2187 <entry><literal>SerializablePredicateList</literal></entry>
2188 <entry>Waiting to access the list of predicate locks held by
2189 serializable transactions.</entry>
2190 </row>
2191 <row>
2192 <entry><literal>SerializableXactHash</literal></entry>
2193 <entry>Waiting to read or update information about serializable
2194 transactions.</entry>
2195 </row>
2196 <row>
2197 <entry><literal>SerialSLRU</literal></entry>
2198 <entry>Waiting to access the serializable transaction conflict SLRU
2199 cache.</entry>
2200 </row>
2201 <row>
2202 <entry><literal>SharedTidBitmap</literal></entry>
2203 <entry>Waiting to access a shared TID bitmap during a parallel bitmap
2204 index scan.</entry>
2205 </row>
2206 <row>
2207 <entry><literal>SharedTupleStore</literal></entry>
2208 <entry>Waiting to access a shared tuple store during parallel
2209 query.</entry>
2210 </row>
2211 <row>
2212 <entry><literal>ShmemIndex</literal></entry>
2213 <entry>Waiting to find or allocate space in shared memory.</entry>
2214 </row>
2215 <row>
2216 <entry><literal>SInvalRead</literal></entry>
2217 <entry>Waiting to retrieve messages from the shared catalog invalidation
2218 queue.</entry>
2219 </row>
2220 <row>
2221 <entry><literal>SInvalWrite</literal></entry>
2222 <entry>Waiting to add a message to the shared catalog invalidation
2223 queue.</entry>
2224 </row>
2225 <row>
2226 <entry><literal>SubtransBuffer</literal></entry>
2227 <entry>Waiting for I/O on a sub-transaction SLRU buffer.</entry>
2228 </row>
2229 <row>
2230 <entry><literal>SubtransSLRU</literal></entry>
2231 <entry>Waiting to access the sub-transaction SLRU cache.</entry>
2232 </row>
2233 <row>
2234 <entry><literal>SyncRep</literal></entry>
2235 <entry>Waiting to read or update information about the state of
2236 synchronous replication.</entry>
2237 </row>
2238 <row>
2239 <entry><literal>SyncScan</literal></entry>
2240 <entry>Waiting to select the starting location of a synchronized table
2241 scan.</entry>
2242 </row>
2243 <row>
2244 <entry><literal>TablespaceCreate</literal></entry>
2245 <entry>Waiting to create or drop a tablespace.</entry>
2246 </row>
2247 <row>
2248 <entry><literal>TwoPhaseState</literal></entry>
2249 <entry>Waiting to read or update the state of prepared transactions.</entry>
2250 </row>
2251 <row>
2252 <entry><literal>WALBufMapping</literal></entry>
2253 <entry>Waiting to replace a page in WAL buffers.</entry>
2254 </row>
2255 <row>
2256 <entry><literal>WALInsert</literal></entry>
2257 <entry>Waiting to insert WAL data into a memory buffer.</entry>
2258 </row>
2259 <row>
2260 <entry><literal>WALWrite</literal></entry>
2261 <entry>Waiting for WAL buffers to be written to disk.</entry>
2262 </row>
2263 <row>
2264 <entry><literal>WrapLimitsVacuum</literal></entry>
2265 <entry>Waiting to update limits on transaction id and multixact
2266 consumption.</entry>
2267 </row>
2268 <row>
2269 <entry><literal>XactBuffer</literal></entry>
2270 <entry>Waiting for I/O on a transaction status SLRU buffer.</entry>
2271 </row>
2272 <row>
2273 <entry><literal>XactSLRU</literal></entry>
2274 <entry>Waiting to access the transaction status SLRU cache.</entry>
2275 </row>
2276 <row>
2277 <entry><literal>XactTruncation</literal></entry>
2278 <entry>Waiting to execute <function>pg_xact_status</function> or update
2279 the oldest transaction ID available to it.</entry>
2280 </row>
2281 <row>
2282 <entry><literal>XidGen</literal></entry>
2283 <entry>Waiting to allocate a new transaction ID.</entry>
2284 </row>
2285 </tbody>
2286 </tgroup>
2287 </table>
2289 <note>
2290 <para>
2291 Extensions can add <literal>LWLock</literal> types to the list shown in
2292 <xref linkend="wait-event-lwlock-table"/>. In some cases, the name
2293 assigned by an extension will not be available in all server processes;
2294 so an <literal>LWLock</literal> wait event might be reported as
2295 just <quote><literal>extension</literal></quote> rather than the
2296 extension-assigned name.
2297 </para>
2298 </note>
2300 <table id="wait-event-timeout-table">
2301 <title>Wait Events of Type <literal>Timeout</literal></title>
2302 <tgroup cols="2">
2303 <thead>
2304 <row>
2305 <entry><literal>Timeout</literal> Wait Event</entry>
2306 <entry>Description</entry>
2307 </row>
2308 </thead>
2310 <tbody>
2311 <row>
2312 <entry><literal>BaseBackupThrottle</literal></entry>
2313 <entry>Waiting during base backup when throttling activity.</entry>
2314 </row>
2315 <row>
2316 <entry><literal>CheckpointWriteDelay</literal></entry>
2317 <entry>Waiting between writes while performing a checkpoint.</entry>
2318 </row>
2319 <row>
2320 <entry><literal>PgSleep</literal></entry>
2321 <entry>Waiting due to a call to <function>pg_sleep</function> or
2322 a sibling function.</entry>
2323 </row>
2324 <row>
2325 <entry><literal>RecoveryApplyDelay</literal></entry>
2326 <entry>Waiting to apply WAL during recovery because of a delay
2327 setting.</entry>
2328 </row>
2329 <row>
2330 <entry><literal>RecoveryRetrieveRetryInterval</literal></entry>
2331 <entry>Waiting during recovery when WAL data is not available from any
2332 source (<filename>pg_wal</filename>, archive or stream).</entry>
2333 </row>
2334 <row>
2335 <entry><literal>RegisterSyncRequest</literal></entry>
2336 <entry>Waiting while sending synchronization requests to the
2337 checkpointer, because the request queue is full.</entry>
2338 </row>
2339 <row>
2340 <entry><literal>SpinDelay</literal></entry>
2341 <entry>Waiting while acquiring a contended spinlock.</entry>
2342 </row>
2343 <row>
2344 <entry><literal>VacuumDelay</literal></entry>
2345 <entry>Waiting in a cost-based vacuum delay point.</entry>
2346 </row>
2347 <row>
2348 <entry><literal>VacuumTruncate</literal></entry>
2349 <entry>Waiting to acquire an exclusive lock to truncate off any
2350 empty pages at the end of a table vacuumed.</entry>
2351 </row>
2352 </tbody>
2353 </tgroup>
2354 </table>
2356 <para>
2357 Here is an example of how wait events can be viewed:
2359 <programlisting>
2360 SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event is NOT NULL;
2361 pid | wait_event_type | wait_event
2362 ------+-----------------+------------
2363 2540 | Lock | relation
2364 6644 | LWLock | ProcArray
2365 (2 rows)
2366 </programlisting>
2367 </para>
2369 </sect2>
2371 <sect2 id="monitoring-pg-stat-replication-view">
2372 <title><structname>pg_stat_replication</structname></title>
2374 <indexterm>
2375 <primary>pg_stat_replication</primary>
2376 </indexterm>
2378 <para>
2379 The <structname>pg_stat_replication</structname> view will contain one row
2380 per WAL sender process, showing statistics about replication to that
2381 sender's connected standby server. Only directly connected standbys are
2382 listed; no information is available about downstream standby servers.
2383 </para>
2385 <table id="pg-stat-replication-view" xreflabel="pg_stat_replication">
2386 <title><structname>pg_stat_replication</structname> View</title>
2387 <tgroup cols="1">
2388 <thead>
2389 <row>
2390 <entry role="catalog_table_entry"><para role="column_definition">
2391 Column Type
2392 </para>
2393 <para>
2394 Description
2395 </para></entry>
2396 </row>
2397 </thead>
2399 <tbody>
2400 <row>
2401 <entry role="catalog_table_entry"><para role="column_definition">
2402 <structfield>pid</structfield> <type>integer</type>
2403 </para>
2404 <para>
2405 Process ID of a WAL sender process
2406 </para></entry>
2407 </row>
2409 <row>
2410 <entry role="catalog_table_entry"><para role="column_definition">
2411 <structfield>usesysid</structfield> <type>oid</type>
2412 </para>
2413 <para>
2414 OID of the user logged into this WAL sender process
2415 </para></entry>
2416 </row>
2418 <row>
2419 <entry role="catalog_table_entry"><para role="column_definition">
2420 <structfield>usename</structfield> <type>name</type>
2421 </para>
2422 <para>
2423 Name of the user logged into this WAL sender process
2424 </para></entry>
2425 </row>
2427 <row>
2428 <entry role="catalog_table_entry"><para role="column_definition">
2429 <structfield>application_name</structfield> <type>text</type>
2430 </para>
2431 <para>
2432 Name of the application that is connected
2433 to this WAL sender
2434 </para></entry>
2435 </row>
2437 <row>
2438 <entry role="catalog_table_entry"><para role="column_definition">
2439 <structfield>client_addr</structfield> <type>inet</type>
2440 </para>
2441 <para>
2442 IP address of the client connected to this WAL sender.
2443 If this field is null, it indicates that the client is
2444 connected via a Unix socket on the server machine.
2445 </para></entry>
2446 </row>
2448 <row>
2449 <entry role="catalog_table_entry"><para role="column_definition">
2450 <structfield>client_hostname</structfield> <type>text</type>
2451 </para>
2452 <para>
2453 Host name of the connected client, as reported by a
2454 reverse DNS lookup of <structfield>client_addr</structfield>. This field will
2455 only be non-null for IP connections, and only when <xref linkend="guc-log-hostname"/> is enabled.
2456 </para></entry>
2457 </row>
2459 <row>
2460 <entry role="catalog_table_entry"><para role="column_definition">
2461 <structfield>client_port</structfield> <type>integer</type>
2462 </para>
2463 <para>
2464 TCP port number that the client is using for communication
2465 with this WAL sender, or <literal>-1</literal> if a Unix socket is used
2466 </para></entry>
2467 </row>
2469 <row>
2470 <entry role="catalog_table_entry"><para role="column_definition">
2471 <structfield>backend_start</structfield> <type>timestamp with time zone</type>
2472 </para>
2473 <para>
2474 Time when this process was started, i.e., when the
2475 client connected to this WAL sender
2476 </para></entry>
2477 </row>
2479 <row>
2480 <entry role="catalog_table_entry"><para role="column_definition">
2481 <structfield>backend_xmin</structfield> <type>xid</type>
2482 </para>
2483 <para>
2484 This standby's <literal>xmin</literal> horizon reported
2485 by <xref linkend="guc-hot-standby-feedback"/>.
2486 </para></entry>
2487 </row>
2489 <row>
2490 <entry role="catalog_table_entry"><para role="column_definition">
2491 <structfield>state</structfield> <type>text</type>
2492 </para>
2493 <para>
2494 Current WAL sender state.
2495 Possible values are:
2496 <itemizedlist>
2497 <listitem>
2498 <para>
2499 <literal>startup</literal>: This WAL sender is starting up.
2500 </para>
2501 </listitem>
2502 <listitem>
2503 <para>
2504 <literal>catchup</literal>: This WAL sender's connected standby is
2505 catching up with the primary.
2506 </para>
2507 </listitem>
2508 <listitem>
2509 <para>
2510 <literal>streaming</literal>: This WAL sender is streaming changes
2511 after its connected standby server has caught up with the primary.
2512 </para>
2513 </listitem>
2514 <listitem>
2515 <para>
2516 <literal>backup</literal>: This WAL sender is sending a backup.
2517 </para>
2518 </listitem>
2519 <listitem>
2520 <para>
2521 <literal>stopping</literal>: This WAL sender is stopping.
2522 </para>
2523 </listitem>
2524 </itemizedlist>
2525 </para></entry>
2526 </row>
2528 <row>
2529 <entry role="catalog_table_entry"><para role="column_definition">
2530 <structfield>sent_lsn</structfield> <type>pg_lsn</type>
2531 </para>
2532 <para>
2533 Last write-ahead log location sent on this connection
2534 </para></entry>
2535 </row>
2537 <row>
2538 <entry role="catalog_table_entry"><para role="column_definition">
2539 <structfield>write_lsn</structfield> <type>pg_lsn</type>
2540 </para>
2541 <para>
2542 Last write-ahead log location written to disk by this standby
2543 server
2544 </para></entry>
2545 </row>
2547 <row>
2548 <entry role="catalog_table_entry"><para role="column_definition">
2549 <structfield>flush_lsn</structfield> <type>pg_lsn</type>
2550 </para>
2551 <para>
2552 Last write-ahead log location flushed to disk by this standby
2553 server
2554 </para></entry>
2555 </row>
2557 <row>
2558 <entry role="catalog_table_entry"><para role="column_definition">
2559 <structfield>replay_lsn</structfield> <type>pg_lsn</type>
2560 </para>
2561 <para>
2562 Last write-ahead log location replayed into the database on this
2563 standby server
2564 </para></entry>
2565 </row>
2567 <row>
2568 <entry role="catalog_table_entry"><para role="column_definition">
2569 <structfield>write_lag</structfield> <type>interval</type>
2570 </para>
2571 <para>
2572 Time elapsed between flushing recent WAL locally and receiving
2573 notification that this standby server has written it (but not yet
2574 flushed it or applied it). This can be used to gauge the delay that
2575 <literal>synchronous_commit</literal> level
2576 <literal>remote_write</literal> incurred while committing if this
2577 server was configured as a synchronous standby.
2578 </para></entry>
2579 </row>
2581 <row>
2582 <entry role="catalog_table_entry"><para role="column_definition">
2583 <structfield>flush_lag</structfield> <type>interval</type>
2584 </para>
2585 <para>
2586 Time elapsed between flushing recent WAL locally and receiving
2587 notification that this standby server has written and flushed it
2588 (but not yet applied it). This can be used to gauge the delay that
2589 <literal>synchronous_commit</literal> level
2590 <literal>on</literal> incurred while committing if this
2591 server was configured as a synchronous standby.
2592 </para></entry>
2593 </row>
2595 <row>
2596 <entry role="catalog_table_entry"><para role="column_definition">
2597 <structfield>replay_lag</structfield> <type>interval</type>
2598 </para>
2599 <para>
2600 Time elapsed between flushing recent WAL locally and receiving
2601 notification that this standby server has written, flushed and
2602 applied it. This can be used to gauge the delay that
2603 <literal>synchronous_commit</literal> level
2604 <literal>remote_apply</literal> incurred while committing if this
2605 server was configured as a synchronous standby.
2606 </para></entry>
2607 </row>
2609 <row>
2610 <entry role="catalog_table_entry"><para role="column_definition">
2611 <structfield>sync_priority</structfield> <type>integer</type>
2612 </para>
2613 <para>
2614 Priority of this standby server for being chosen as the
2615 synchronous standby in a priority-based synchronous replication.
2616 This has no effect in a quorum-based synchronous replication.
2617 </para></entry>
2618 </row>
2620 <row>
2621 <entry role="catalog_table_entry"><para role="column_definition">
2622 <structfield>sync_state</structfield> <type>text</type>
2623 </para>
2624 <para>
2625 Synchronous state of this standby server.
2626 Possible values are:
2627 <itemizedlist>
2628 <listitem>
2629 <para>
2630 <literal>async</literal>: This standby server is asynchronous.
2631 </para>
2632 </listitem>
2633 <listitem>
2634 <para>
2635 <literal>potential</literal>: This standby server is now asynchronous,
2636 but can potentially become synchronous if one of current
2637 synchronous ones fails.
2638 </para>
2639 </listitem>
2640 <listitem>
2641 <para>
2642 <literal>sync</literal>: This standby server is synchronous.
2643 </para>
2644 </listitem>
2645 <listitem>
2646 <para>
2647 <literal>quorum</literal>: This standby server is considered as a candidate
2648 for quorum standbys.
2649 </para>
2650 </listitem>
2651 </itemizedlist>
2652 </para></entry>
2653 </row>
2655 <row>
2656 <entry role="catalog_table_entry"><para role="column_definition">
2657 <structfield>reply_time</structfield> <type>timestamp with time zone</type>
2658 </para>
2659 <para>
2660 Send time of last reply message received from standby server
2661 </para></entry>
2662 </row>
2663 </tbody>
2664 </tgroup>
2665 </table>
2667 <para>
2668 The lag times reported in the <structname>pg_stat_replication</structname>
2669 view are measurements of the time taken for recent WAL to be written,
2670 flushed and replayed and for the sender to know about it. These times
2671 represent the commit delay that was (or would have been) introduced by each
2672 synchronous commit level, if the remote server was configured as a
2673 synchronous standby. For an asynchronous standby, the
2674 <structfield>replay_lag</structfield> column approximates the delay
2675 before recent transactions became visible to queries. If the standby
2676 server has entirely caught up with the sending server and there is no more
2677 WAL activity, the most recently measured lag times will continue to be
2678 displayed for a short time and then show NULL.
2679 </para>
2681 <para>
2682 Lag times work automatically for physical replication. Logical decoding
2683 plugins may optionally emit tracking messages; if they do not, the tracking
2684 mechanism will simply display NULL lag.
2685 </para>
2687 <note>
2688 <para>
2689 The reported lag times are not predictions of how long it will take for
2690 the standby to catch up with the sending server assuming the current
2691 rate of replay. Such a system would show similar times while new WAL is
2692 being generated, but would differ when the sender becomes idle. In
2693 particular, when the standby has caught up completely,
2694 <structname>pg_stat_replication</structname> shows the time taken to
2695 write, flush and replay the most recent reported WAL location rather than
2696 zero as some users might expect. This is consistent with the goal of
2697 measuring synchronous commit and transaction visibility delays for
2698 recent write transactions.
2699 To reduce confusion for users expecting a different model of lag, the
2700 lag columns revert to NULL after a short time on a fully replayed idle
2701 system. Monitoring systems should choose whether to represent this
2702 as missing data, zero or continue to display the last known value.
2703 </para>
2704 </note>
2706 </sect2>
2708 <sect2 id="monitoring-pg-stat-replication-slots-view">
2709 <title><structname>pg_stat_replication_slots</structname></title>
2711 <indexterm>
2712 <primary>pg_stat_replication_slots</primary>
2713 </indexterm>
2715 <para>
2716 The <structname>pg_stat_replication_slots</structname> view will contain
2717 one row per logical replication slot, showing statistics about its usage.
2718 </para>
2720 <table id="pg-stat-replication-slots-view" xreflabel="pg_stat_replication_slots">
2721 <title><structname>pg_stat_replication_slots</structname> View</title>
2722 <tgroup cols="1">
2723 <thead>
2724 <row>
2725 <entry role="catalog_table_entry"><para role="column_definition">
2726 Column Type
2727 </para>
2728 <para>
2729 Description
2730 </para></entry>
2731 </row>
2732 </thead>
2734 <tbody>
2735 <row>
2736 <entry role="catalog_table_entry"><para role="column_definition">
2737 <structfield>slot_name</structfield> <type>text</type>
2738 </para>
2739 <para>
2740 A unique, cluster-wide identifier for the replication slot
2741 </para></entry>
2742 </row>
2744 <row>
2745 <entry role="catalog_table_entry"><para role="column_definition">
2746 <structfield>spill_txns</structfield> <type>bigint</type>
2747 </para>
2748 <para>
2749 Number of transactions spilled to disk once the memory used by
2750 logical decoding to decode changes from WAL has exceeded
2751 <literal>logical_decoding_work_mem</literal>. The counter gets
2752 incremented for both top-level transactions and subtransactions.
2753 </para></entry>
2754 </row>
2756 <row>
2757 <entry role="catalog_table_entry"><para role="column_definition">
2758 <structfield>spill_count</structfield> <type>bigint</type>
2759 </para>
2760 <para>
2761 Number of times transactions were spilled to disk while decoding
2762 changes from WAL for this slot. This counter is incremented each time
2763 a transaction is spilled, and the same transaction may be spilled
2764 multiple times.
2765 </para></entry>
2766 </row>
2768 <row>
2769 <entry role="catalog_table_entry"><para role="column_definition">
2770 <structfield>spill_bytes</structfield> <type>bigint</type>
2771 </para>
2772 <para>
2773 Amount of decoded transaction data spilled to disk while performing
2774 decoding of changes from WAL for this slot. This and other spill
2775 counters can be used to gauge the I/O which occurred during logical
2776 decoding and allow tuning <literal>logical_decoding_work_mem</literal>.
2777 </para></entry>
2778 </row>
2780 <row>
2781 <entry role="catalog_table_entry"><para role="column_definition">
2782 <structfield>stream_txns</structfield> <type>bigint</type>
2783 </para>
2784 <para>
2785 Number of in-progress transactions streamed to the decoding output
2786 plugin after the memory used by logical decoding to decode changes
2787 from WAL for this slot has exceeded
2788 <literal>logical_decoding_work_mem</literal>. Streaming only
2789 works with top-level transactions (subtransactions can't be streamed
2790 independently), so the counter is not incremented for subtransactions.
2791 </para></entry>
2792 </row>
2794 <row>
2795 <entry role="catalog_table_entry"><para role="column_definition">
2796 <structfield>stream_count</structfield><type>bigint</type>
2797 </para>
2798 <para>
2799 Number of times in-progress transactions were streamed to the decoding
2800 output plugin while decoding changes from WAL for this slot. This
2801 counter is incremented each time a transaction is streamed, and the
2802 same transaction may be streamed multiple times.
2803 </para></entry>
2804 </row>
2806 <row>
2807 <entry role="catalog_table_entry"><para role="column_definition">
2808 <structfield>stream_bytes</structfield><type>bigint</type>
2809 </para>
2810 <para>
2811 Amount of transaction data decoded for streaming in-progress
2812 transactions to the decoding output plugin while decoding changes from
2813 WAL for this slot. This and other streaming counters for this slot can
2814 be used to tune <literal>logical_decoding_work_mem</literal>.
2815 </para>
2816 </entry>
2817 </row>
2819 <row>
2820 <entry role="catalog_table_entry"><para role="column_definition">
2821 <structfield>total_txns</structfield> <type>bigint</type>
2822 </para>
2823 <para>
2824 Number of decoded transactions sent to the decoding output plugin for
2825 this slot. This counts top-level transactions only, and is not incremented
2826 for subtransactions. Note that this includes the transactions that are
2827 streamed and/or spilled.
2828 </para></entry>
2829 </row>
2831 <row>
2832 <entry role="catalog_table_entry"><para role="column_definition">
2833 <structfield>total_bytes</structfield><type>bigint</type>
2834 </para>
2835 <para>
2836 Amount of transaction data decoded for sending transactions to the
2837 decoding output plugin while decoding changes from WAL for this slot.
2838 Note that this includes data that is streamed and/or spilled.
2839 </para>
2840 </entry>
2841 </row>
2843 <row>
2844 <entry role="catalog_table_entry"><para role="column_definition">
2845 <structfield>stats_reset</structfield> <type>timestamp with time zone</type>
2846 </para>
2847 <para>
2848 Time at which these statistics were last reset
2849 </para></entry>
2850 </row>
2851 </tbody>
2852 </tgroup>
2853 </table>
2855 </sect2>
2857 <sect2 id="monitoring-pg-stat-wal-receiver-view">
2858 <title><structname>pg_stat_wal_receiver</structname></title>
2860 <indexterm>
2861 <primary>pg_stat_wal_receiver</primary>
2862 </indexterm>
2864 <para>
2865 The <structname>pg_stat_wal_receiver</structname> view will contain only
2866 one row, showing statistics about the WAL receiver from that receiver's
2867 connected server.
2868 </para>
2870 <table id="pg-stat-wal-receiver-view" xreflabel="pg_stat_wal_receiver">
2871 <title><structname>pg_stat_wal_receiver</structname> View</title>
2872 <tgroup cols="1">
2873 <thead>
2874 <row>
2875 <entry role="catalog_table_entry"><para role="column_definition">
2876 Column Type
2877 </para>
2878 <para>
2879 Description
2880 </para></entry>
2881 </row>
2882 </thead>
2884 <tbody>
2885 <row>
2886 <entry role="catalog_table_entry"><para role="column_definition">
2887 <structfield>pid</structfield> <type>integer</type>
2888 </para>
2889 <para>
2890 Process ID of the WAL receiver process
2891 </para></entry>
2892 </row>
2894 <row>
2895 <entry role="catalog_table_entry"><para role="column_definition">
2896 <structfield>status</structfield> <type>text</type>
2897 </para>
2898 <para>
2899 Activity status of the WAL receiver process
2900 </para></entry>
2901 </row>
2903 <row>
2904 <entry role="catalog_table_entry"><para role="column_definition">
2905 <structfield>receive_start_lsn</structfield> <type>pg_lsn</type>
2906 </para>
2907 <para>
2908 First write-ahead log location used when WAL receiver is
2909 started
2910 </para></entry>
2911 </row>
2913 <row>
2914 <entry role="catalog_table_entry"><para role="column_definition">
2915 <structfield>receive_start_tli</structfield> <type>integer</type>
2916 </para>
2917 <para>
2918 First timeline number used when WAL receiver is started
2919 </para></entry>
2920 </row>
2922 <row>
2923 <entry role="catalog_table_entry"><para role="column_definition">
2924 <structfield>written_lsn</structfield> <type>pg_lsn</type>
2925 </para>
2926 <para>
2927 Last write-ahead log location already received and written to disk,
2928 but not flushed. This should not be used for data integrity checks.
2929 </para></entry>
2930 </row>
2932 <row>
2933 <entry role="catalog_table_entry"><para role="column_definition">
2934 <structfield>flushed_lsn</structfield> <type>pg_lsn</type>
2935 </para>
2936 <para>
2937 Last write-ahead log location already received and flushed to
2938 disk, the initial value of this field being the first log location used
2939 when WAL receiver is started
2940 </para></entry>
2941 </row>
2943 <row>
2944 <entry role="catalog_table_entry"><para role="column_definition">
2945 <structfield>received_tli</structfield> <type>integer</type>
2946 </para>
2947 <para>
2948 Timeline number of last write-ahead log location received and
2949 flushed to disk, the initial value of this field being the timeline
2950 number of the first log location used when WAL receiver is started
2951 </para></entry>
2952 </row>
2954 <row>
2955 <entry role="catalog_table_entry"><para role="column_definition">
2956 <structfield>last_msg_send_time</structfield> <type>timestamp with time zone</type>
2957 </para>
2958 <para>
2959 Send time of last message received from origin WAL sender
2960 </para></entry>
2961 </row>
2963 <row>
2964 <entry role="catalog_table_entry"><para role="column_definition">
2965 <structfield>last_msg_receipt_time</structfield> <type>timestamp with time zone</type>
2966 </para>
2967 <para>
2968 Receipt time of last message received from origin WAL sender
2969 </para></entry>
2970 </row>
2972 <row>
2973 <entry role="catalog_table_entry"><para role="column_definition">
2974 <structfield>latest_end_lsn</structfield> <type>pg_lsn</type>
2975 </para>
2976 <para>
2977 Last write-ahead log location reported to origin WAL sender
2978 </para></entry>
2979 </row>
2981 <row>
2982 <entry role="catalog_table_entry"><para role="column_definition">
2983 <structfield>latest_end_time</structfield> <type>timestamp with time zone</type>
2984 </para>
2985 <para>
2986 Time of last write-ahead log location reported to origin WAL sender
2987 </para></entry>
2988 </row>
2990 <row>
2991 <entry role="catalog_table_entry"><para role="column_definition">
2992 <structfield>slot_name</structfield> <type>text</type>
2993 </para>
2994 <para>
2995 Replication slot name used by this WAL receiver
2996 </para></entry>
2997 </row>
2999 <row>
3000 <entry role="catalog_table_entry"><para role="column_definition">
3001 <structfield>sender_host</structfield> <type>text</type>
3002 </para>
3003 <para>
3004 Host of the <productname>PostgreSQL</productname> instance
3005 this WAL receiver is connected to. This can be a host name,
3006 an IP address, or a directory path if the connection is via
3007 Unix socket. (The path case can be distinguished because it
3008 will always be an absolute path, beginning with <literal>/</literal>.)
3009 </para></entry>
3010 </row>
3012 <row>
3013 <entry role="catalog_table_entry"><para role="column_definition">
3014 <structfield>sender_port</structfield> <type>integer</type>
3015 </para>
3016 <para>
3017 Port number of the <productname>PostgreSQL</productname> instance
3018 this WAL receiver is connected to.
3019 </para></entry>
3020 </row>
3022 <row>
3023 <entry role="catalog_table_entry"><para role="column_definition">
3024 <structfield>conninfo</structfield> <type>text</type>
3025 </para>
3026 <para>
3027 Connection string used by this WAL receiver,
3028 with security-sensitive fields obfuscated.
3029 </para></entry>
3030 </row>
3031 </tbody>
3032 </tgroup>
3033 </table>
3035 </sect2>
3037 <sect2 id="monitoring-pg-stat-recovery-prefetch">
3038 <title><structname>pg_stat_recovery_prefetch</structname></title>
3040 <indexterm>
3041 <primary>pg_stat_recovery_prefetch</primary>
3042 </indexterm>
3044 <para>
3045 The <structname>pg_stat_recovery_prefetch</structname> view will contain
3046 only one row. The columns <structfield>wal_distance</structfield>,
3047 <structfield>block_distance</structfield> and
3048 <structfield>io_depth</structfield> show current values, and the
3049 other columns show cumulative counters that can be reset
3050 with the <function>pg_stat_reset_shared</function> function.
3051 </para>
3053 <table id="pg-stat-recovery-prefetch-view" xreflabel="pg_stat_recovery_prefetch">
3054 <title><structname>pg_stat_recovery_prefetch</structname> View</title>
3055 <tgroup cols="1">
3056 <thead>
3057 <row>
3058 <entry role="catalog_table_entry"><para role="column_definition">
3059 Column Type
3060 </para>
3061 <para>
3062 Description
3063 </para></entry>
3064 </row>
3065 </thead>
3067 <tbody>
3068 <row>
3069 <entry role="catalog_table_entry">
3070 <para role="column_definition">
3071 <structfield>stats_reset</structfield> <type>timestamp with time zone</type>
3072 </para>
3073 <para>
3074 Time at which these statistics were last reset
3075 </para>
3076 </entry>
3077 </row>
3079 <row>
3080 <entry role="catalog_table_entry">
3081 <para role="column_definition">
3082 <structfield>prefetch</structfield> <type>bigint</type>
3083 </para>
3084 <para>
3085 Number of blocks prefetched because they were not in the buffer pool
3086 </para>
3087 </entry>
3088 </row>
3090 <row>
3091 <entry role="catalog_table_entry">
3092 <para role="column_definition">
3093 <structfield>hit</structfield> <type>bigint</type>
3094 </para>
3095 <para>
3096 Number of blocks not prefetched because they were already in the buffer pool
3097 </para>
3098 </entry>
3099 </row>
3101 <row>
3102 <entry role="catalog_table_entry">
3103 <para role="column_definition">
3104 <structfield>skip_init</structfield> <type>bigint</type>
3105 </para>
3106 <para>
3107 Number of blocks not prefetched because they would be zero-initialized
3108 </para>
3109 </entry>
3110 </row>
3112 <row>
3113 <entry role="catalog_table_entry">
3114 <para role="column_definition">
3115 <structfield>skip_new</structfield> <type>bigint</type>
3116 </para>
3117 <para>
3118 Number of blocks not prefetched because they didn't exist yet
3119 </para>
3120 </entry>
3121 </row>
3123 <row>
3124 <entry role="catalog_table_entry">
3125 <para role="column_definition">
3126 <structfield>skip_fpw</structfield> <type>bigint</type>
3127 </para>
3128 <para>
3129 Number of blocks not prefetched because a full page image was included in the WAL
3130 </para>
3131 </entry>
3132 </row>
3134 <row>
3135 <entry role="catalog_table_entry">
3136 <para role="column_definition">
3137 <structfield>skip_rep</structfield> <type>bigint</type>
3138 </para>
3139 <para>
3140 Number of blocks not prefetched because they were already recently prefetched
3141 </para>
3142 </entry>
3143 </row>
3145 <row>
3146 <entry role="catalog_table_entry">
3147 <para role="column_definition">
3148 <structfield>wal_distance</structfield> <type>int</type>
3149 </para>
3150 <para>
3151 How many bytes ahead the prefetcher is looking
3152 </para>
3153 </entry>
3154 </row>
3156 <row>
3157 <entry role="catalog_table_entry">
3158 <para role="column_definition">
3159 <structfield>block_distance</structfield> <type>int</type>
3160 </para>
3161 <para>
3162 How many blocks ahead the prefetcher is looking
3163 </para>
3164 </entry>
3165 </row>
3167 <row>
3168 <entry role="catalog_table_entry">
3169 <para role="column_definition">
3170 <structfield>io_depth</structfield> <type>int</type>
3171 </para>
3172 <para>
3173 How many prefetches have been initiated but are not yet known to have completed
3174 </para>
3175 </entry>
3176 </row>
3177 </tbody>
3178 </tgroup>
3179 </table>
3181 </sect2>
3183 <sect2 id="monitoring-pg-stat-subscription">
3184 <title><structname>pg_stat_subscription</structname></title>
3186 <indexterm>
3187 <primary>pg_stat_subscription</primary>
3188 </indexterm>
3190 <table id="pg-stat-subscription" xreflabel="pg_stat_subscription">
3191 <title><structname>pg_stat_subscription</structname> View</title>
3192 <tgroup cols="1">
3193 <thead>
3194 <row>
3195 <entry role="catalog_table_entry"><para role="column_definition">
3196 Column Type
3197 </para>
3198 <para>
3199 Description
3200 </para></entry>
3201 </row>
3202 </thead>
3204 <tbody>
3205 <row>
3206 <entry role="catalog_table_entry"><para role="column_definition">
3207 <structfield>subid</structfield> <type>oid</type>
3208 </para>
3209 <para>
3210 OID of the subscription
3211 </para></entry>
3212 </row>
3214 <row>
3215 <entry role="catalog_table_entry"><para role="column_definition">
3216 <structfield>subname</structfield> <type>name</type>
3217 </para>
3218 <para>
3219 Name of the subscription
3220 </para></entry>
3221 </row>
3223 <row>
3224 <entry role="catalog_table_entry"><para role="column_definition">
3225 <structfield>pid</structfield> <type>integer</type>
3226 </para>
3227 <para>
3228 Process ID of the subscription worker process
3229 </para></entry>
3230 </row>
3232 <row>
3233 <entry role="catalog_table_entry"><para role="column_definition">
3234 <structfield>leader_pid</structfield> <type>integer</type>
3235 </para>
3236 <para>
3237 Process ID of the leader apply worker if this process is a parallel
3238 apply worker; NULL if this process is a leader apply worker or a
3239 synchronization worker
3240 </para></entry>
3241 </row>
3243 <row>
3244 <entry role="catalog_table_entry"><para role="column_definition">
3245 <structfield>relid</structfield> <type>oid</type>
3246 </para>
3247 <para>
3248 OID of the relation that the worker is synchronizing; NULL for the
3249 leader apply worker and parallel apply workers
3250 </para></entry>
3251 </row>
3253 <row>
3254 <entry role="catalog_table_entry"><para role="column_definition">
3255 <structfield>received_lsn</structfield> <type>pg_lsn</type>
3256 </para>
3257 <para>
3258 Last write-ahead log location received, the initial value of
3259 this field being 0; NULL for parallel apply workers
3260 </para></entry>
3261 </row>
3263 <row>
3264 <entry role="catalog_table_entry"><para role="column_definition">
3265 <structfield>last_msg_send_time</structfield> <type>timestamp with time zone</type>
3266 </para>
3267 <para>
3268 Send time of last message received from origin WAL sender; NULL for
3269 parallel apply workers
3270 </para></entry>
3271 </row>
3273 <row>
3274 <entry role="catalog_table_entry"><para role="column_definition">
3275 <structfield>last_msg_receipt_time</structfield> <type>timestamp with time zone</type>
3276 </para>
3277 <para>
3278 Receipt time of last message received from origin WAL sender; NULL for
3279 parallel apply workers
3280 </para></entry>
3281 </row>
3283 <row>
3284 <entry role="catalog_table_entry"><para role="column_definition">
3285 <structfield>latest_end_lsn</structfield> <type>pg_lsn</type>
3286 </para>
3287 <para>
3288 Last write-ahead log location reported to origin WAL sender; NULL for
3289 parallel apply workers
3290 </para></entry>
3291 </row>
3293 <row>
3294 <entry role="catalog_table_entry"><para role="column_definition">
3295 <structfield>latest_end_time</structfield> <type>timestamp with time zone</type>
3296 </para>
3297 <para>
3298 Time of last write-ahead log location reported to origin WAL
3299 sender; NULL for parallel apply workers
3300 </para></entry>
3301 </row>
3302 </tbody>
3303 </tgroup>
3304 </table>
3306 </sect2>
3308 <sect2 id="monitoring-pg-stat-subscription-stats">
3309 <title><structname>pg_stat_subscription_stats</structname></title>
3311 <indexterm>
3312 <primary>pg_stat_subscription_stats</primary>
3313 </indexterm>
3315 <para>
3316 The <structname>pg_stat_subscription_stats</structname> view will contain
3317 one row per subscription.
3318 </para>
3320 <table id="pg-stat-subscription-stats" xreflabel="pg_stat_subscription_stats">
3321 <title><structname>pg_stat_subscription_stats</structname> View</title>
3322 <tgroup cols="1">
3323 <thead>
3324 <row>
3325 <entry role="catalog_table_entry"><para role="column_definition">
3326 Column Type
3327 </para>
3328 <para>
3329 Description
3330 </para></entry>
3331 </row>
3332 </thead>
3334 <tbody>
3335 <row>
3336 <entry role="catalog_table_entry"><para role="column_definition">
3337 <structfield>subid</structfield> <type>oid</type>
3338 </para>
3339 <para>
3340 OID of the subscription
3341 </para></entry>
3342 </row>
3344 <row>
3345 <entry role="catalog_table_entry"><para role="column_definition">
3346 <structfield>subname</structfield> <type>name</type>
3347 </para>
3348 <para>
3349 Name of the subscription
3350 </para></entry>
3351 </row>
3353 <row>
3354 <entry role="catalog_table_entry"><para role="column_definition">
3355 <structfield>apply_error_count</structfield> <type>bigint</type>
3356 </para>
3357 <para>
3358 Number of times an error occurred while applying changes
3359 </para></entry>
3360 </row>
3362 <row>
3363 <entry role="catalog_table_entry"><para role="column_definition">
3364 <structfield>sync_error_count</structfield> <type>bigint</type>
3365 </para>
3366 <para>
3367 Number of times an error occurred during the initial table
3368 synchronization
3369 </para></entry>
3370 </row>
3372 <row>
3373 <entry role="catalog_table_entry"><para role="column_definition">
3374 <structfield>stats_reset</structfield> <type>timestamp with time zone</type>
3375 </para>
3376 <para>
3377 Time at which these statistics were last reset
3378 </para></entry>
3379 </row>
3380 </tbody>
3381 </tgroup>
3382 </table>
3384 </sect2>
3386 <sect2 id="monitoring-pg-stat-ssl-view">
3387 <title><structname>pg_stat_ssl</structname></title>
3389 <indexterm>
3390 <primary>pg_stat_ssl</primary>
3391 </indexterm>
3393 <para>
3394 The <structname>pg_stat_ssl</structname> view will contain one row per
3395 backend or WAL sender process, showing statistics about SSL usage on
3396 this connection. It can be joined to <structname>pg_stat_activity</structname>
3397 or <structname>pg_stat_replication</structname> on the
3398 <structfield>pid</structfield> column to get more details about the
3399 connection.
3400 </para>
3402 <table id="pg-stat-ssl-view" xreflabel="pg_stat_ssl">
3403 <title><structname>pg_stat_ssl</structname> View</title>
3404 <tgroup cols="1">
3405 <thead>
3406 <row>
3407 <entry role="catalog_table_entry"><para role="column_definition">
3408 Column Type
3409 </para>
3410 <para>
3411 Description
3412 </para></entry>
3413 </row>
3414 </thead>
3416 <tbody>
3417 <row>
3418 <entry role="catalog_table_entry"><para role="column_definition">
3419 <structfield>pid</structfield> <type>integer</type>
3420 </para>
3421 <para>
3422 Process ID of a backend or WAL sender process
3423 </para></entry>
3424 </row>
3426 <row>
3427 <entry role="catalog_table_entry"><para role="column_definition">
3428 <structfield>ssl</structfield> <type>boolean</type>
3429 </para>
3430 <para>
3431 True if SSL is used on this connection
3432 </para></entry>
3433 </row>
3435 <row>
3436 <entry role="catalog_table_entry"><para role="column_definition">
3437 <structfield>version</structfield> <type>text</type>
3438 </para>
3439 <para>
3440 Version of SSL in use, or NULL if SSL is not in use
3441 on this connection
3442 </para></entry>
3443 </row>
3445 <row>
3446 <entry role="catalog_table_entry"><para role="column_definition">
3447 <structfield>cipher</structfield> <type>text</type>
3448 </para>
3449 <para>
3450 Name of SSL cipher in use, or NULL if SSL is not in use
3451 on this connection
3452 </para></entry>
3453 </row>
3455 <row>
3456 <entry role="catalog_table_entry"><para role="column_definition">
3457 <structfield>bits</structfield> <type>integer</type>
3458 </para>
3459 <para>
3460 Number of bits in the encryption algorithm used, or NULL
3461 if SSL is not used on this connection
3462 </para></entry>
3463 </row>
3465 <row>
3466 <entry role="catalog_table_entry"><para role="column_definition">
3467 <structfield>client_dn</structfield> <type>text</type>
3468 </para>
3469 <para>
3470 Distinguished Name (DN) field from the client certificate
3471 used, or NULL if no client certificate was supplied or if SSL
3472 is not in use on this connection. This field is truncated if the
3473 DN field is longer than <symbol>NAMEDATALEN</symbol> (64 characters
3474 in a standard build).
3475 </para></entry>
3476 </row>
3478 <row>
3479 <entry role="catalog_table_entry"><para role="column_definition">
3480 <structfield>client_serial</structfield> <type>numeric</type>
3481 </para>
3482 <para>
3483 Serial number of the client certificate, or NULL if no client
3484 certificate was supplied or if SSL is not in use on this connection. The
3485 combination of certificate serial number and certificate issuer uniquely
3486 identifies a certificate (unless the issuer erroneously reuses serial
3487 numbers).
3488 </para></entry>
3489 </row>
3491 <row>
3492 <entry role="catalog_table_entry"><para role="column_definition">
3493 <structfield>issuer_dn</structfield> <type>text</type>
3494 </para>
3495 <para>
3496 DN of the issuer of the client certificate, or NULL if no client
3497 certificate was supplied or if SSL is not in use on this connection.
3498 This field is truncated like <structfield>client_dn</structfield>.
3499 </para></entry>
3500 </row>
3501 </tbody>
3502 </tgroup>
3503 </table>
3505 </sect2>
3507 <sect2 id="monitoring-pg-stat-gssapi-view">
3508 <title><structname>pg_stat_gssapi</structname></title>
3510 <indexterm>
3511 <primary>pg_stat_gssapi</primary>
3512 </indexterm>
3514 <para>
3515 The <structname>pg_stat_gssapi</structname> view will contain one row per
3516 backend, showing information about GSSAPI usage on this connection. It can
3517 be joined to <structname>pg_stat_activity</structname> or
3518 <structname>pg_stat_replication</structname> on the
3519 <structfield>pid</structfield> column to get more details about the
3520 connection.
3521 </para>
3523 <table id="pg-stat-gssapi-view" xreflabel="pg_stat_gssapi">
3524 <title><structname>pg_stat_gssapi</structname> View</title>
3525 <tgroup cols="1">
3526 <thead>
3527 <row>
3528 <entry role="catalog_table_entry"><para role="column_definition">
3529 Column Type
3530 </para>
3531 <para>
3532 Description
3533 </para></entry>
3534 </row>
3535 </thead>
3537 <tbody>
3538 <row>
3539 <entry role="catalog_table_entry"><para role="column_definition">
3540 <structfield>pid</structfield> <type>integer</type>
3541 </para>
3542 <para>
3543 Process ID of a backend
3544 </para></entry>
3545 </row>
3547 <row>
3548 <entry role="catalog_table_entry"><para role="column_definition">
3549 <structfield>gss_authenticated</structfield> <type>boolean</type>
3550 </para>
3551 <para>
3552 True if GSSAPI authentication was used for this connection
3553 </para></entry>
3554 </row>
3556 <row>
3557 <entry role="catalog_table_entry"><para role="column_definition">
3558 <structfield>principal</structfield> <type>text</type>
3559 </para>
3560 <para>
3561 Principal used to authenticate this connection, or NULL
3562 if GSSAPI was not used to authenticate this connection. This
3563 field is truncated if the principal is longer than
3564 <symbol>NAMEDATALEN</symbol> (64 characters in a standard build).
3565 </para></entry>
3566 </row>
3568 <row>
3569 <entry role="catalog_table_entry"><para role="column_definition">
3570 <structfield>encrypted</structfield> <type>boolean</type>
3571 </para>
3572 <para>
3573 True if GSSAPI encryption is in use on this connection
3574 </para></entry>
3575 </row>
3576 </tbody>
3577 </tgroup>
3578 </table>
3580 </sect2>
3582 <sect2 id="monitoring-pg-stat-archiver-view">
3583 <title><structname>pg_stat_archiver</structname></title>
3585 <indexterm>
3586 <primary>pg_stat_archiver</primary>
3587 </indexterm>
3589 <para>
3590 The <structname>pg_stat_archiver</structname> view will always have a
3591 single row, containing data about the archiver process of the cluster.
3592 </para>
3594 <table id="pg-stat-archiver-view" xreflabel="pg_stat_archiver">
3595 <title><structname>pg_stat_archiver</structname> View</title>
3596 <tgroup cols="1">
3597 <thead>
3598 <row>
3599 <entry role="catalog_table_entry"><para role="column_definition">
3600 Column Type
3601 </para>
3602 <para>
3603 Description
3604 </para></entry>
3605 </row>
3606 </thead>
3608 <tbody>
3609 <row>
3610 <entry role="catalog_table_entry"><para role="column_definition">
3611 <structfield>archived_count</structfield> <type>bigint</type>
3612 </para>
3613 <para>
3614 Number of WAL files that have been successfully archived
3615 </para></entry>
3616 </row>
3618 <row>
3619 <entry role="catalog_table_entry"><para role="column_definition">
3620 <structfield>last_archived_wal</structfield> <type>text</type>
3621 </para>
3622 <para>
3623 Name of the WAL file most recently successfully archived
3624 </para></entry>
3625 </row>
3627 <row>
3628 <entry role="catalog_table_entry"><para role="column_definition">
3629 <structfield>last_archived_time</structfield> <type>timestamp with time zone</type>
3630 </para>
3631 <para>
3632 Time of the most recent successful archive operation
3633 </para></entry>
3634 </row>
3636 <row>
3637 <entry role="catalog_table_entry"><para role="column_definition">
3638 <structfield>failed_count</structfield> <type>bigint</type>
3639 </para>
3640 <para>
3641 Number of failed attempts for archiving WAL files
3642 </para></entry>
3643 </row>
3645 <row>
3646 <entry role="catalog_table_entry"><para role="column_definition">
3647 <structfield>last_failed_wal</structfield> <type>text</type>
3648 </para>
3649 <para>
3650 Name of the WAL file of the most recent failed archival operation
3651 </para></entry>
3652 </row>
3654 <row>
3655 <entry role="catalog_table_entry"><para role="column_definition">
3656 <structfield>last_failed_time</structfield> <type>timestamp with time zone</type>
3657 </para>
3658 <para>
3659 Time of the most recent failed archival operation
3660 </para></entry>
3661 </row>
3663 <row>
3664 <entry role="catalog_table_entry"><para role="column_definition">
3665 <structfield>stats_reset</structfield> <type>timestamp with time zone</type>
3666 </para>
3667 <para>
3668 Time at which these statistics were last reset
3669 </para></entry>
3670 </row>
3671 </tbody>
3672 </tgroup>
3673 </table>
3675 <para>
3676 Normally, WAL files are archived in order, oldest to newest, but that is
3677 not guaranteed, and does not hold under special circumstances like when
3678 promoting a standby or after crash recovery. Therefore it is not safe to
3679 assume that all files older than
3680 <structfield>last_archived_wal</structfield> have also been successfully
3681 archived.
3682 </para>
3683 </sect2>
3685 <sect2 id="monitoring-pg-stat-io-view">
3686 <title><structname>pg_stat_io</structname></title>
3688 <indexterm>
3689 <primary>pg_stat_io</primary>
3690 </indexterm>
3692 <para>
3693 The <structname>pg_stat_io</structname> view will contain one row for each
3694 combination of backend type, target I/O object, and I/O context, showing
3695 cluster-wide I/O statistics. Combinations which do not make sense are
3696 omitted.
3697 </para>
3699 <para>
3700 Currently, I/O on relations (e.g. tables, indexes) is tracked. However,
3701 relation I/O which bypasses shared buffers (e.g. when moving a table from one
3702 tablespace to another) is currently not tracked.
3703 </para>
3705 <table id="pg-stat-io-view" xreflabel="pg_stat_io">
3706 <title><structname>pg_stat_io</structname> View</title>
3707 <tgroup cols="1">
3708 <thead>
3709 <row>
3710 <entry role="catalog_table_entry">
3711 <para role="column_definition">
3712 Column Type
3713 </para>
3714 <para>
3715 Description
3716 </para>
3717 </entry>
3718 </row>
3719 </thead>
3720 <tbody>
3721 <row>
3722 <entry role="catalog_table_entry">
3723 <para role="column_definition">
3724 <structfield>backend_type</structfield> <type>text</type>
3725 </para>
3726 <para>
3727 Type of backend (e.g. background worker, autovacuum worker). See <link
3728 linkend="monitoring-pg-stat-activity-view">
3729 <structname>pg_stat_activity</structname></link> for more information
3730 on <varname>backend_type</varname>s. Some
3731 <varname>backend_type</varname>s do not accumulate I/O operation
3732 statistics and will not be included in the view.
3733 </para>
3734 </entry>
3735 </row>
3737 <row>
3738 <entry role="catalog_table_entry">
3739 <para role="column_definition">
3740 <structfield>io_object</structfield> <type>text</type>
3741 </para>
3742 <para>
3743 Target object of an I/O operation. Possible values are:
3744 <itemizedlist>
3745 <listitem>
3746 <para>
3747 <literal>relation</literal>: Permanent relations.
3748 </para>
3749 </listitem>
3750 <listitem>
3751 <para>
3752 <literal>temp relation</literal>: Temporary relations.
3753 </para>
3754 </listitem>
3755 </itemizedlist>
3756 </para>
3757 </entry>
3758 </row>
3760 <row>
3761 <entry role="catalog_table_entry">
3762 <para role="column_definition">
3763 <structfield>io_context</structfield> <type>text</type>
3764 </para>
3765 <para>
3766 The context of an I/O operation. Possible values are:
3767 </para>
3768 <itemizedlist>
3769 <listitem>
3770 <para>
3771 <literal>normal</literal>: The default or standard
3772 <varname>io_context</varname> for a type of I/O operation. For
3773 example, by default, relation data is read into and written out from
3774 shared buffers. Thus, reads and writes of relation data to and from
3775 shared buffers are tracked in <varname>io_context</varname>
3776 <literal>normal</literal>.
3777 </para>
3778 </listitem>
3779 <listitem>
3780 <para>
3781 <literal>vacuum</literal>: I/O operations performed outside of shared
3782 buffers while vacuuming and analyzing permanent relations. Temporary
3783 table vacuums use the same local buffer pool as other temporary table
3784 IO operations and are tracked in <varname>io_context</varname>
3785 <literal>normal</literal>.
3786 </para>
3787 </listitem>
3788 <listitem>
3789 <para>
3790 <literal>bulkread</literal>: Certain large read I/O operations
3791 done outside of shared buffers, for example, a sequential scan of a
3792 large table.
3793 </para>
3794 </listitem>
3795 <listitem>
3796 <para>
3797 <literal>bulkwrite</literal>: Certain large write I/O operations
3798 done outside of shared buffers, such as <command>COPY</command>.
3799 </para>
3800 </listitem>
3801 </itemizedlist>
3802 </entry>
3803 </row>
3805 <row>
3806 <entry role="catalog_table_entry">
3807 <para role="column_definition">
3808 <structfield>reads</structfield> <type>bigint</type>
3809 </para>
3810 <para>
3811 Number of read operations, each of the size specified in
3812 <varname>op_bytes</varname>.
3813 </para>
3814 </entry>
3815 </row>
3817 <row>
3818 <entry role="catalog_table_entry">
3819 <para role="column_definition">
3820 <structfield>writes</structfield> <type>bigint</type>
3821 </para>
3822 <para>
3823 Number of write operations, each of the size specified in
3824 <varname>op_bytes</varname>.
3825 </para>
3826 </entry>
3827 </row>
3829 <row>
3830 <entry role="catalog_table_entry">
3831 <para role="column_definition">
3832 <structfield>extends</structfield> <type>bigint</type>
3833 </para>
3834 <para>
3835 Number of relation extend operations, each of the size specified in
3836 <varname>op_bytes</varname>.
3837 </para>
3838 </entry>
3839 </row>
3841 <row>
3842 <entry role="catalog_table_entry">
3843 <para role="column_definition">
3844 <structfield>op_bytes</structfield> <type>bigint</type>
3845 </para>
3846 <para>
3847 The number of bytes per unit of I/O read, written, or extended.
3848 </para>
3849 <para>
3850 Relation data reads, writes, and extends are done in
3851 <varname>block_size</varname> units, derived from the build-time
3852 parameter <symbol>BLCKSZ</symbol>, which is <literal>8192</literal> by
3853 default.
3854 </para>
3855 </entry>
3856 </row>
3858 <row>
3859 <entry role="catalog_table_entry">
3860 <para role="column_definition">
3861 <structfield>hits</structfield> <type>bigint</type>
3862 </para>
3863 <para>
3864 The number of times a desired block was found in a shared buffer.
3865 </para>
3866 </entry>
3867 </row>
3869 <row>
3870 <entry role="catalog_table_entry">
3871 <para role="column_definition">
3872 <structfield>evictions</structfield> <type>bigint</type>
3873 </para>
3874 <para>
3875 Number of times a block has been written out from a shared or local
3876 buffer in order to make it available for another use.
3877 </para>
3878 <para>
3879 In <varname>io_context</varname> <literal>normal</literal>, this counts
3880 the number of times a block was evicted from a buffer and replaced with
3881 another block. In <varname>io_context</varname>s
3882 <literal>bulkwrite</literal>, <literal>bulkread</literal>, and
3883 <literal>vacuum</literal>, this counts the number of times a block was
3884 evicted from shared buffers in order to add the shared buffer to a
3885 separate, size-limited ring buffer for use in a bulk I/O operation.
3886 </para>
3887 </entry>
3888 </row>
3890 <row>
3891 <entry role="catalog_table_entry">
3892 <para role="column_definition">
3893 <structfield>reuses</structfield> <type>bigint</type>
3894 </para>
3895 <para>
3896 The number of times an existing buffer in a size-limited ring buffer
3897 outside of shared buffers was reused as part of an I/O operation in the
3898 <literal>bulkread</literal>, <literal>bulkwrite</literal>, or
3899 <literal>vacuum</literal> <varname>io_context</varname>s.
3900 </para>
3901 </entry>
3902 </row>
3904 <row>
3905 <entry role="catalog_table_entry">
3906 <para role="column_definition">
3907 <structfield>fsyncs</structfield> <type>bigint</type>
3908 </para>
3909 <para>
3910 Number of <literal>fsync</literal> calls. These are only tracked in
3911 <varname>io_context</varname> <literal>normal</literal>.
3912 </para>
3913 </entry>
3914 </row>
3916 <row>
3917 <entry role="catalog_table_entry">
3918 <para role="column_definition">
3919 <structfield>stats_reset</structfield> <type>timestamp with time zone</type>
3920 </para>
3921 <para>
3922 Time at which these statistics were last reset.
3923 </para>
3924 </entry>
3925 </row>
3926 </tbody>
3927 </tgroup>
3928 </table>
3930 <para>
3931 Some backend types never perform I/O operations on some I/O objects and/or
3932 in some I/O contexts. These rows are omitted from the view. For example, the
3933 checkpointer does not checkpoint temporary tables, so there will be no rows
3934 for <varname>backend_type</varname> <literal>checkpointer</literal> and
3935 <varname>io_object</varname> <literal>temp relation</literal>.
3936 </para>
3938 <para>
3939 In addition, some I/O operations will never be performed either by certain
3940 backend types or on certain I/O objects and/or in certain I/O contexts.
3941 These cells will be NULL. For example, temporary tables are not
3942 <literal>fsync</literal>ed, so <varname>fsyncs</varname> will be NULL for
3943 <varname>io_object</varname> <literal>temp relation</literal>. Also, the
3944 background writer does not perform reads, so <varname>reads</varname> will
3945 be NULL in rows for <varname>backend_type</varname> <literal>background
3946 writer</literal>.
3947 </para>
3949 <para>
3950 <structname>pg_stat_io</structname> can be used to inform database tuning.
3951 For example:
3952 <itemizedlist>
3953 <listitem>
3954 <para>
3955 A high <varname>evictions</varname> count can indicate that shared
3956 buffers should be increased.
3957 </para>
3958 </listitem>
3959 <listitem>
3960 <para>
3961 Client backends rely on the checkpointer to ensure data is persisted to
3962 permanent storage. Large numbers of <varname>fsyncs</varname> by
3963 <literal>client backend</literal>s could indicate a misconfiguration of
3964 shared buffers or of the checkpointer. More information on configuring
3965 the checkpointer can be found in <xref linkend="wal-configuration"/>.
3966 </para>
3967 </listitem>
3968 <listitem>
3969 <para>
3970 Normally, client backends should be able to rely on auxiliary processes
3971 like the checkpointer and the background writer to write out dirty data
3972 as much as possible. Large numbers of writes by client backends could
3973 indicate a misconfiguration of shared buffers or of the checkpointer.
3974 More information on configuring the checkpointer can be found in <xref
3975 linkend="wal-configuration"/>.
3976 </para>
3977 </listitem>
3978 </itemizedlist>
3979 </para>
3982 </sect2>
3984 <sect2 id="monitoring-pg-stat-bgwriter-view">
3985 <title><structname>pg_stat_bgwriter</structname></title>
3987 <indexterm>
3988 <primary>pg_stat_bgwriter</primary>
3989 </indexterm>
3991 <para>
3992 The <structname>pg_stat_bgwriter</structname> view will always have a
3993 single row, containing global data for the cluster.
3994 </para>
3996 <table id="pg-stat-bgwriter-view" xreflabel="pg_stat_bgwriter">
3997 <title><structname>pg_stat_bgwriter</structname> View</title>
3998 <tgroup cols="1">
3999 <thead>
4000 <row>
4001 <entry role="catalog_table_entry"><para role="column_definition">
4002 Column Type
4003 </para>
4004 <para>
4005 Description
4006 </para></entry>
4007 </row>
4008 </thead>
4010 <tbody>
4011 <row>
4012 <entry role="catalog_table_entry"><para role="column_definition">
4013 <structfield>checkpoints_timed</structfield> <type>bigint</type>
4014 </para>
4015 <para>
4016 Number of scheduled checkpoints that have been performed
4017 </para></entry>
4018 </row>
4020 <row>
4021 <entry role="catalog_table_entry"><para role="column_definition">
4022 <structfield>checkpoints_req</structfield> <type>bigint</type>
4023 </para>
4024 <para>
4025 Number of requested checkpoints that have been performed
4026 </para></entry>
4027 </row>
4029 <row>
4030 <entry role="catalog_table_entry"><para role="column_definition">
4031 <structfield>checkpoint_write_time</structfield> <type>double precision</type>
4032 </para>
4033 <para>
4034 Total amount of time that has been spent in the portion of
4035 checkpoint processing where files are written to disk, in milliseconds
4036 </para></entry>
4037 </row>
4039 <row>
4040 <entry role="catalog_table_entry"><para role="column_definition">
4041 <structfield>checkpoint_sync_time</structfield> <type>double precision</type>
4042 </para>
4043 <para>
4044 Total amount of time that has been spent in the portion of
4045 checkpoint processing where files are synchronized to disk, in
4046 milliseconds
4047 </para></entry>
4048 </row>
4050 <row>
4051 <entry role="catalog_table_entry"><para role="column_definition">
4052 <structfield>buffers_checkpoint</structfield> <type>bigint</type>
4053 </para>
4054 <para>
4055 Number of buffers written during checkpoints
4056 </para></entry>
4057 </row>
4059 <row>
4060 <entry role="catalog_table_entry"><para role="column_definition">
4061 <structfield>buffers_clean</structfield> <type>bigint</type>
4062 </para>
4063 <para>
4064 Number of buffers written by the background writer
4065 </para></entry>
4066 </row>
4068 <row>
4069 <entry role="catalog_table_entry"><para role="column_definition">
4070 <structfield>maxwritten_clean</structfield> <type>bigint</type>
4071 </para>
4072 <para>
4073 Number of times the background writer stopped a cleaning
4074 scan because it had written too many buffers
4075 </para></entry>
4076 </row>
4078 <row>
4079 <entry role="catalog_table_entry"><para role="column_definition">
4080 <structfield>buffers_backend</structfield> <type>bigint</type>
4081 </para>
4082 <para>
4083 Number of buffers written directly by a backend
4084 </para></entry>
4085 </row>
4087 <row>
4088 <entry role="catalog_table_entry"><para role="column_definition">
4089 <structfield>buffers_backend_fsync</structfield> <type>bigint</type>
4090 </para>
4091 <para>
4092 Number of times a backend had to execute its own
4093 <function>fsync</function> call (normally the background writer handles those
4094 even when the backend does its own write)
4095 </para></entry>
4096 </row>
4098 <row>
4099 <entry role="catalog_table_entry"><para role="column_definition">
4100 <structfield>buffers_alloc</structfield> <type>bigint</type>
4101 </para>
4102 <para>
4103 Number of buffers allocated
4104 </para></entry>
4105 </row>
4107 <row>
4108 <entry role="catalog_table_entry"><para role="column_definition">
4109 <structfield>stats_reset</structfield> <type>timestamp with time zone</type>
4110 </para>
4111 <para>
4112 Time at which these statistics were last reset
4113 </para></entry>
4114 </row>
4115 </tbody>
4116 </tgroup>
4117 </table>
4119 </sect2>
4121 <sect2 id="monitoring-pg-stat-wal-view">
4122 <title><structname>pg_stat_wal</structname></title>
4124 <indexterm>
4125 <primary>pg_stat_wal</primary>
4126 </indexterm>
4128 <para>
4129 The <structname>pg_stat_wal</structname> view will always have a
4130 single row, containing data about WAL activity of the cluster.
4131 </para>
4133 <table id="pg-stat-wal-view" xreflabel="pg_stat_wal">
4134 <title><structname>pg_stat_wal</structname> View</title>
4135 <tgroup cols="1">
4136 <thead>
4137 <row>
4138 <entry role="catalog_table_entry"><para role="column_definition">
4139 Column Type
4140 </para>
4141 <para>
4142 Description
4143 </para></entry>
4144 </row>
4145 </thead>
4147 <tbody>
4148 <row>
4149 <entry role="catalog_table_entry"><para role="column_definition">
4150 <structfield>wal_records</structfield> <type>bigint</type>
4151 </para>
4152 <para>
4153 Total number of WAL records generated
4154 </para></entry>
4155 </row>
4157 <row>
4158 <entry role="catalog_table_entry"><para role="column_definition">
4159 <structfield>wal_fpi</structfield> <type>bigint</type>
4160 </para>
4161 <para>
4162 Total number of WAL full page images generated
4163 </para></entry>
4164 </row>
4166 <row>
4167 <entry role="catalog_table_entry"><para role="column_definition">
4168 <structfield>wal_bytes</structfield> <type>numeric</type>
4169 </para>
4170 <para>
4171 Total amount of WAL generated in bytes
4172 </para></entry>
4173 </row>
4175 <row>
4176 <entry role="catalog_table_entry"><para role="column_definition">
4177 <structfield>wal_buffers_full</structfield> <type>bigint</type>
4178 </para>
4179 <para>
4180 Number of times WAL data was written to disk because WAL buffers became full
4181 </para></entry>
4182 </row>
4184 <row>
4185 <entry role="catalog_table_entry"><para role="column_definition">
4186 <structfield>wal_write</structfield> <type>bigint</type>
4187 </para>
4188 <para>
4189 Number of times WAL buffers were written out to disk via
4190 <function>XLogWrite</function> request.
4191 See <xref linkend="wal-configuration"/> for more information about
4192 the internal WAL function <function>XLogWrite</function>.
4193 </para></entry>
4194 </row>
4196 <row>
4197 <entry role="catalog_table_entry"><para role="column_definition">
4198 <structfield>wal_sync</structfield> <type>bigint</type>
4199 </para>
4200 <para>
4201 Number of times WAL files were synced to disk via
4202 <function>issue_xlog_fsync</function> request
4203 (if <xref linkend="guc-fsync"/> is <literal>on</literal> and
4204 <xref linkend="guc-wal-sync-method"/> is either
4205 <literal>fdatasync</literal>, <literal>fsync</literal> or
4206 <literal>fsync_writethrough</literal>, otherwise zero).
4207 See <xref linkend="wal-configuration"/> for more information about
4208 the internal WAL function <function>issue_xlog_fsync</function>.
4209 </para></entry>
4210 </row>
4212 <row>
4213 <entry role="catalog_table_entry"><para role="column_definition">
4214 <structfield>wal_write_time</structfield> <type>double precision</type>
4215 </para>
4216 <para>
4217 Total amount of time spent writing WAL buffers to disk via
4218 <function>XLogWrite</function> request, in milliseconds
4219 (if <xref linkend="guc-track-wal-io-timing"/> is enabled,
4220 otherwise zero). This includes the sync time when
4221 <varname>wal_sync_method</varname> is either
4222 <literal>open_datasync</literal> or <literal>open_sync</literal>.
4223 </para></entry>
4224 </row>
4226 <row>
4227 <entry role="catalog_table_entry"><para role="column_definition">
4228 <structfield>wal_sync_time</structfield> <type>double precision</type>
4229 </para>
4230 <para>
4231 Total amount of time spent syncing WAL files to disk via
4232 <function>issue_xlog_fsync</function> request, in milliseconds
4233 (if <varname>track_wal_io_timing</varname> is enabled,
4234 <varname>fsync</varname> is <literal>on</literal>, and
4235 <varname>wal_sync_method</varname> is either
4236 <literal>fdatasync</literal>, <literal>fsync</literal> or
4237 <literal>fsync_writethrough</literal>, otherwise zero).
4238 </para></entry>
4239 </row>
4241 <row>
4242 <entry role="catalog_table_entry"><para role="column_definition">
4243 <structfield>stats_reset</structfield> <type>timestamp with time zone</type>
4244 </para>
4245 <para>
4246 Time at which these statistics were last reset
4247 </para></entry>
4248 </row>
4249 </tbody>
4250 </tgroup>
4251 </table>
4253 </sect2>
4255 <sect2 id="monitoring-pg-stat-database-view">
4256 <title><structname>pg_stat_database</structname></title>
4258 <indexterm>
4259 <primary>pg_stat_database</primary>
4260 </indexterm>
4262 <para>
4263 The <structname>pg_stat_database</structname> view will contain one row
4264 for each database in the cluster, plus one for shared objects, showing
4265 database-wide statistics.
4266 </para>
4268 <table id="pg-stat-database-view" xreflabel="pg_stat_database">
4269 <title><structname>pg_stat_database</structname> View</title>
4270 <tgroup cols="1">
4271 <thead>
4272 <row>
4273 <entry role="catalog_table_entry"><para role="column_definition">
4274 Column Type
4275 </para>
4276 <para>
4277 Description
4278 </para></entry>
4279 </row>
4280 </thead>
4282 <tbody>
4283 <row>
4284 <entry role="catalog_table_entry"><para role="column_definition">
4285 <structfield>datid</structfield> <type>oid</type>
4286 </para>
4287 <para>
4288 OID of this database, or 0 for objects belonging to a shared
4289 relation
4290 </para></entry>
4291 </row>
4293 <row>
4294 <entry role="catalog_table_entry"><para role="column_definition">
4295 <structfield>datname</structfield> <type>name</type>
4296 </para>
4297 <para>
4298 Name of this database, or <literal>NULL</literal> for shared
4299 objects.
4300 </para></entry>
4301 </row>
4303 <row>
4304 <entry role="catalog_table_entry"><para role="column_definition">
4305 <structfield>numbackends</structfield> <type>integer</type>
4306 </para>
4307 <para>
4308 Number of backends currently connected to this database, or
4309 <literal>NULL</literal> for shared objects. This is the only column
4310 in this view that returns a value reflecting current state; all other
4311 columns return the accumulated values since the last reset.
4312 </para></entry>
4313 </row>
4315 <row>
4316 <entry role="catalog_table_entry"><para role="column_definition">
4317 <structfield>xact_commit</structfield> <type>bigint</type>
4318 </para>
4319 <para>
4320 Number of transactions in this database that have been
4321 committed
4322 </para></entry>
4323 </row>
4325 <row>
4326 <entry role="catalog_table_entry"><para role="column_definition">
4327 <structfield>xact_rollback</structfield> <type>bigint</type>
4328 </para>
4329 <para>
4330 Number of transactions in this database that have been
4331 rolled back
4332 </para></entry>
4333 </row>
4335 <row>
4336 <entry role="catalog_table_entry"><para role="column_definition">
4337 <structfield>blks_read</structfield> <type>bigint</type>
4338 </para>
4339 <para>
4340 Number of disk blocks read in this database
4341 </para></entry>
4342 </row>
4344 <row>
4345 <entry role="catalog_table_entry"><para role="column_definition">
4346 <structfield>blks_hit</structfield> <type>bigint</type>
4347 </para>
4348 <para>
4349 Number of times disk blocks were found already in the buffer
4350 cache, so that a read was not necessary (this only includes hits in the
4351 PostgreSQL buffer cache, not the operating system's file system cache)
4352 </para></entry>
4353 </row>
4355 <row>
4356 <entry role="catalog_table_entry"><para role="column_definition">
4357 <structfield>tup_returned</structfield> <type>bigint</type>
4358 </para>
4359 <para>
4360 Number of live rows fetched by sequential scans and index entries returned by index scans in this database
4361 </para></entry>
4362 </row>
4364 <row>
4365 <entry role="catalog_table_entry"><para role="column_definition">
4366 <structfield>tup_fetched</structfield> <type>bigint</type>
4367 </para>
4368 <para>
4369 Number of live rows fetched by index scans in this database
4370 </para></entry>
4371 </row>
4373 <row>
4374 <entry role="catalog_table_entry"><para role="column_definition">
4375 <structfield>tup_inserted</structfield> <type>bigint</type>
4376 </para>
4377 <para>
4378 Number of rows inserted by queries in this database
4379 </para></entry>
4380 </row>
4382 <row>
4383 <entry role="catalog_table_entry"><para role="column_definition">
4384 <structfield>tup_updated</structfield> <type>bigint</type>
4385 </para>
4386 <para>
4387 Number of rows updated by queries in this database
4388 </para></entry>
4389 </row>
4391 <row>
4392 <entry role="catalog_table_entry"><para role="column_definition">
4393 <structfield>tup_deleted</structfield> <type>bigint</type>
4394 </para>
4395 <para>
4396 Number of rows deleted by queries in this database
4397 </para></entry>
4398 </row>
4400 <row>
4401 <entry role="catalog_table_entry"><para role="column_definition">
4402 <structfield>conflicts</structfield> <type>bigint</type>
4403 </para>
4404 <para>
4405 Number of queries canceled due to conflicts with recovery
4406 in this database. (Conflicts occur only on standby servers; see
4407 <link linkend="monitoring-pg-stat-database-conflicts-view">
4408 <structname>pg_stat_database_conflicts</structname></link> for details.)
4409 </para></entry>
4410 </row>
4412 <row>
4413 <entry role="catalog_table_entry"><para role="column_definition">
4414 <structfield>temp_files</structfield> <type>bigint</type>
4415 </para>
4416 <para>
4417 Number of temporary files created by queries in this database.
4418 All temporary files are counted, regardless of why the temporary file
4419 was created (e.g., sorting or hashing), and regardless of the
4420 <xref linkend="guc-log-temp-files"/> setting.
4421 </para></entry>
4422 </row>
4424 <row>
4425 <entry role="catalog_table_entry"><para role="column_definition">
4426 <structfield>temp_bytes</structfield> <type>bigint</type>
4427 </para>
4428 <para>
4429 Total amount of data written to temporary files by queries in
4430 this database. All temporary files are counted, regardless of why
4431 the temporary file was created, and
4432 regardless of the <xref linkend="guc-log-temp-files"/> setting.
4433 </para></entry>
4434 </row>
4436 <row>
4437 <entry role="catalog_table_entry"><para role="column_definition">
4438 <structfield>deadlocks</structfield> <type>bigint</type>
4439 </para>
4440 <para>
4441 Number of deadlocks detected in this database
4442 </para></entry>
4443 </row>
4445 <row>
4446 <entry role="catalog_table_entry"><para role="column_definition">
4447 <structfield>checksum_failures</structfield> <type>bigint</type>
4448 </para>
4449 <para>
4450 Number of data page checksum failures detected in this
4451 database (or on a shared object), or NULL if data checksums are not
4452 enabled.
4453 </para></entry>
4454 </row>
4456 <row>
4457 <entry role="catalog_table_entry"><para role="column_definition">
4458 <structfield>checksum_last_failure</structfield> <type>timestamp with time zone</type>
4459 </para>
4460 <para>
4461 Time at which the last data page checksum failure was detected in
4462 this database (or on a shared object), or NULL if data checksums are not
4463 enabled.
4464 </para></entry>
4465 </row>
4467 <row>
4468 <entry role="catalog_table_entry"><para role="column_definition">
4469 <structfield>blk_read_time</structfield> <type>double precision</type>
4470 </para>
4471 <para>
4472 Time spent reading data file blocks by backends in this database,
4473 in milliseconds (if <xref linkend="guc-track-io-timing"/> is enabled,
4474 otherwise zero)
4475 </para></entry>
4476 </row>
4478 <row>
4479 <entry role="catalog_table_entry"><para role="column_definition">
4480 <structfield>blk_write_time</structfield> <type>double precision</type>
4481 </para>
4482 <para>
4483 Time spent writing data file blocks by backends in this database,
4484 in milliseconds (if <xref linkend="guc-track-io-timing"/> is enabled,
4485 otherwise zero)
4486 </para></entry>
4487 </row>
4489 <row>
4490 <entry role="catalog_table_entry"><para role="column_definition">
4491 <structfield>session_time</structfield> <type>double precision</type>
4492 </para>
4493 <para>
4494 Time spent by database sessions in this database, in milliseconds
4495 (note that statistics are only updated when the state of a session
4496 changes, so if sessions have been idle for a long time, this idle time
4497 won't be included)
4498 </para></entry>
4499 </row>
4501 <row>
4502 <entry role="catalog_table_entry"><para role="column_definition">
4503 <structfield>active_time</structfield> <type>double precision</type>
4504 </para>
4505 <para>
4506 Time spent executing SQL statements in this database, in milliseconds
4507 (this corresponds to the states <literal>active</literal> and
4508 <literal>fastpath function call</literal> in
4509 <link linkend="monitoring-pg-stat-activity-view">
4510 <structname>pg_stat_activity</structname></link>)
4511 </para></entry>
4512 </row>
4514 <row>
4515 <entry role="catalog_table_entry"><para role="column_definition">
4516 <structfield>idle_in_transaction_time</structfield> <type>double precision</type>
4517 </para>
4518 <para>
4519 Time spent idling while in a transaction in this database, in milliseconds
4520 (this corresponds to the states <literal>idle in transaction</literal> and
4521 <literal>idle in transaction (aborted)</literal> in
4522 <link linkend="monitoring-pg-stat-activity-view">
4523 <structname>pg_stat_activity</structname></link>)
4524 </para></entry>
4525 </row>
4527 <row>
4528 <entry role="catalog_table_entry"><para role="column_definition">
4529 <structfield>sessions</structfield> <type>bigint</type>
4530 </para>
4531 <para>
4532 Total number of sessions established to this database
4533 </para></entry>
4534 </row>
4536 <row>
4537 <entry role="catalog_table_entry"><para role="column_definition">
4538 <structfield>sessions_abandoned</structfield> <type>bigint</type>
4539 </para>
4540 <para>
4541 Number of database sessions to this database that were terminated
4542 because connection to the client was lost
4543 </para></entry>
4544 </row>
4546 <row>
4547 <entry role="catalog_table_entry"><para role="column_definition">
4548 <structfield>sessions_fatal</structfield> <type>bigint</type>
4549 </para>
4550 <para>
4551 Number of database sessions to this database that were terminated
4552 by fatal errors
4553 </para></entry>
4554 </row>
4556 <row>
4557 <entry role="catalog_table_entry"><para role="column_definition">
4558 <structfield>sessions_killed</structfield> <type>bigint</type>
4559 </para>
4560 <para>
4561 Number of database sessions to this database that were terminated
4562 by operator intervention
4563 </para></entry>
4564 </row>
4566 <row>
4567 <entry role="catalog_table_entry"><para role="column_definition">
4568 <structfield>stats_reset</structfield> <type>timestamp with time zone</type>
4569 </para>
4570 <para>
4571 Time at which these statistics were last reset
4572 </para></entry>
4573 </row>
4574 </tbody>
4575 </tgroup>
4576 </table>
4578 </sect2>
4580 <sect2 id="monitoring-pg-stat-database-conflicts-view">
4581 <title><structname>pg_stat_database_conflicts</structname></title>
4583 <indexterm>
4584 <primary>pg_stat_database_conflicts</primary>
4585 </indexterm>
4587 <para>
4588 The <structname>pg_stat_database_conflicts</structname> view will contain
4589 one row per database, showing database-wide statistics about
4590 query cancels occurring due to conflicts with recovery on standby servers.
4591 This view will only contain information on standby servers, since
4592 conflicts do not occur on primary servers.
4593 </para>
4595 <table id="pg-stat-database-conflicts-view" xreflabel="pg_stat_database_conflicts">
4596 <title><structname>pg_stat_database_conflicts</structname> View</title>
4597 <tgroup cols="1">
4598 <thead>
4599 <row>
4600 <entry role="catalog_table_entry"><para role="column_definition">
4601 Column Type
4602 </para>
4603 <para>
4604 Description
4605 </para></entry>
4606 </row>
4607 </thead>
4609 <tbody>
4610 <row>
4611 <entry role="catalog_table_entry"><para role="column_definition">
4612 <structfield>datid</structfield> <type>oid</type>
4613 </para>
4614 <para>
4615 OID of a database
4616 </para></entry>
4617 </row>
4619 <row>
4620 <entry role="catalog_table_entry"><para role="column_definition">
4621 <structfield>datname</structfield> <type>name</type>
4622 </para>
4623 <para>
4624 Name of this database
4625 </para></entry>
4626 </row>
4628 <row>
4629 <entry role="catalog_table_entry"><para role="column_definition">
4630 <structfield>confl_tablespace</structfield> <type>bigint</type>
4631 </para>
4632 <para>
4633 Number of queries in this database that have been canceled due to
4634 dropped tablespaces
4635 </para></entry>
4636 </row>
4638 <row>
4639 <entry role="catalog_table_entry"><para role="column_definition">
4640 <structfield>confl_lock</structfield> <type>bigint</type>
4641 </para>
4642 <para>
4643 Number of queries in this database that have been canceled due to
4644 lock timeouts
4645 </para></entry>
4646 </row>
4648 <row>
4649 <entry role="catalog_table_entry"><para role="column_definition">
4650 <structfield>confl_snapshot</structfield> <type>bigint</type>
4651 </para>
4652 <para>
4653 Number of queries in this database that have been canceled due to
4654 old snapshots
4655 </para></entry>
4656 </row>
4658 <row>
4659 <entry role="catalog_table_entry"><para role="column_definition">
4660 <structfield>confl_bufferpin</structfield> <type>bigint</type>
4661 </para>
4662 <para>
4663 Number of queries in this database that have been canceled due to
4664 pinned buffers
4665 </para></entry>
4666 </row>
4668 <row>
4669 <entry role="catalog_table_entry"><para role="column_definition">
4670 <structfield>confl_deadlock</structfield> <type>bigint</type>
4671 </para>
4672 <para>
4673 Number of queries in this database that have been canceled due to
4674 deadlocks
4675 </para></entry>
4676 </row>
4677 </tbody>
4678 </tgroup>
4679 </table>
4681 </sect2>
4683 <sect2 id="monitoring-pg-stat-all-tables-view">
4684 <title><structname>pg_stat_all_tables</structname></title>
4686 <indexterm>
4687 <primary>pg_stat_all_tables</primary>
4688 </indexterm>
4690 <para>
4691 The <structname>pg_stat_all_tables</structname> view will contain
4692 one row for each table in the current database (including TOAST
4693 tables), showing statistics about accesses to that specific table. The
4694 <structname>pg_stat_user_tables</structname> and
4695 <structname>pg_stat_sys_tables</structname> views
4696 contain the same information,
4697 but filtered to only show user and system tables respectively.
4698 </para>
4700 <table id="pg-stat-all-tables-view" xreflabel="pg_stat_all_tables">
4701 <title><structname>pg_stat_all_tables</structname> View</title>
4702 <tgroup cols="1">
4703 <thead>
4704 <row>
4705 <entry role="catalog_table_entry"><para role="column_definition">
4706 Column Type
4707 </para>
4708 <para>
4709 Description
4710 </para></entry>
4711 </row>
4712 </thead>
4714 <tbody>
4715 <row>
4716 <entry role="catalog_table_entry"><para role="column_definition">
4717 <structfield>relid</structfield> <type>oid</type>
4718 </para>
4719 <para>
4720 OID of a table
4721 </para></entry>
4722 </row>
4724 <row>
4725 <entry role="catalog_table_entry"><para role="column_definition">
4726 <structfield>schemaname</structfield> <type>name</type>
4727 </para>
4728 <para>
4729 Name of the schema that this table is in
4730 </para></entry>
4731 </row>
4733 <row>
4734 <entry role="catalog_table_entry"><para role="column_definition">
4735 <structfield>relname</structfield> <type>name</type>
4736 </para>
4737 <para>
4738 Name of this table
4739 </para></entry>
4740 </row>
4742 <row>
4743 <entry role="catalog_table_entry"><para role="column_definition">
4744 <structfield>seq_scan</structfield> <type>bigint</type>
4745 </para>
4746 <para>
4747 Number of sequential scans initiated on this table
4748 </para></entry>
4749 </row>
4751 <row>
4752 <entry role="catalog_table_entry"><para role="column_definition">
4753 <structfield>last_seq_scan</structfield> <type>timestamptz</type>
4754 </para>
4755 <para>
4756 The time of the last sequential scan on this table, based on the
4757 most recent transaction stop time
4758 </para></entry>
4759 </row>
4761 <row>
4762 <entry role="catalog_table_entry"><para role="column_definition">
4763 <structfield>seq_tup_read</structfield> <type>bigint</type>
4764 </para>
4765 <para>
4766 Number of live rows fetched by sequential scans
4767 </para></entry>
4768 </row>
4770 <row>
4771 <entry role="catalog_table_entry"><para role="column_definition">
4772 <structfield>idx_scan</structfield> <type>bigint</type>
4773 </para>
4774 <para>
4775 Number of index scans initiated on this table
4776 </para></entry>
4777 </row>
4779 <row>
4780 <entry role="catalog_table_entry"><para role="column_definition">
4781 <structfield>last_idx_scan</structfield> <type>timestamptz</type>
4782 </para>
4783 <para>
4784 The time of the last index scan on this table, based on the
4785 most recent transaction stop time
4786 </para></entry>
4787 </row>
4789 <row>
4790 <entry role="catalog_table_entry"><para role="column_definition">
4791 <structfield>idx_tup_fetch</structfield> <type>bigint</type>
4792 </para>
4793 <para>
4794 Number of live rows fetched by index scans
4795 </para></entry>
4796 </row>
4798 <row>
4799 <entry role="catalog_table_entry"><para role="column_definition">
4800 <structfield>n_tup_ins</structfield> <type>bigint</type>
4801 </para>
4802 <para>
4803 Total number of rows inserted
4804 </para></entry>
4805 </row>
4807 <row>
4808 <entry role="catalog_table_entry"><para role="column_definition">
4809 <structfield>n_tup_upd</structfield> <type>bigint</type>
4810 </para>
4811 <para>
4812 Total number of rows updated. (This includes row updates
4813 counted in <structfield>n_tup_hot_upd</structfield> and
4814 <structfield>n_tup_newpage_upd</structfield>, and remaining
4815 non-<acronym>HOT</acronym> updates.)
4816 </para></entry>
4817 </row>
4819 <row>
4820 <entry role="catalog_table_entry"><para role="column_definition">
4821 <structfield>n_tup_del</structfield> <type>bigint</type>
4822 </para>
4823 <para>
4824 Total number of rows deleted
4825 </para></entry>
4826 </row>
4828 <row>
4829 <entry role="catalog_table_entry"><para role="column_definition">
4830 <structfield>n_tup_hot_upd</structfield> <type>bigint</type>
4831 </para>
4832 <para>
4833 Number of rows <link linkend="storage-hot">HOT updated</link>.
4834 These are updates where no successor versions are required in
4835 indexes.
4836 </para></entry>
4837 </row>
4839 <row>
4840 <entry role="catalog_table_entry"><para role="column_definition">
4841 <structfield>n_tup_newpage_upd</structfield> <type>bigint</type>
4842 </para>
4843 <para>
4844 Number of rows updated where the successor version goes onto a
4845 <emphasis>new</emphasis> heap page, leaving behind an original
4846 version with a
4847 <link linkend="storage-tuple-layout"><structfield>t_ctid</structfield>
4848 field</link> that points to a different heap page. These are
4849 always non-<acronym>HOT</acronym> updates.
4850 </para></entry>
4851 </row>
4853 <row>
4854 <entry role="catalog_table_entry"><para role="column_definition">
4855 <structfield>n_live_tup</structfield> <type>bigint</type>
4856 </para>
4857 <para>
4858 Estimated number of live rows
4859 </para></entry>
4860 </row>
4862 <row>
4863 <entry role="catalog_table_entry"><para role="column_definition">
4864 <structfield>n_dead_tup</structfield> <type>bigint</type>
4865 </para>
4866 <para>
4867 Estimated number of dead rows
4868 </para></entry>
4869 </row>
4871 <row>
4872 <entry role="catalog_table_entry"><para role="column_definition">
4873 <structfield>n_mod_since_analyze</structfield> <type>bigint</type>
4874 </para>
4875 <para>
4876 Estimated number of rows modified since this table was last analyzed
4877 </para></entry>
4878 </row>
4880 <row>
4881 <entry role="catalog_table_entry"><para role="column_definition">
4882 <structfield>n_ins_since_vacuum</structfield> <type>bigint</type>
4883 </para>
4884 <para>
4885 Estimated number of rows inserted since this table was last vacuumed
4886 </para></entry>
4887 </row>
4889 <row>
4890 <entry role="catalog_table_entry"><para role="column_definition">
4891 <structfield>last_vacuum</structfield> <type>timestamp with time zone</type>
4892 </para>
4893 <para>
4894 Last time at which this table was manually vacuumed
4895 (not counting <command>VACUUM FULL</command>)
4896 </para></entry>
4897 </row>
4899 <row>
4900 <entry role="catalog_table_entry"><para role="column_definition">
4901 <structfield>last_autovacuum</structfield> <type>timestamp with time zone</type>
4902 </para>
4903 <para>
4904 Last time at which this table was vacuumed by the autovacuum
4905 daemon
4906 </para></entry>
4907 </row>
4909 <row>
4910 <entry role="catalog_table_entry"><para role="column_definition">
4911 <structfield>last_analyze</structfield> <type>timestamp with time zone</type>
4912 </para>
4913 <para>
4914 Last time at which this table was manually analyzed
4915 </para></entry>
4916 </row>
4918 <row>
4919 <entry role="catalog_table_entry"><para role="column_definition">
4920 <structfield>last_autoanalyze</structfield> <type>timestamp with time zone</type>
4921 </para>
4922 <para>
4923 Last time at which this table was analyzed by the autovacuum
4924 daemon
4925 </para></entry>
4926 </row>
4928 <row>
4929 <entry role="catalog_table_entry"><para role="column_definition">
4930 <structfield>vacuum_count</structfield> <type>bigint</type>
4931 </para>
4932 <para>
4933 Number of times this table has been manually vacuumed
4934 (not counting <command>VACUUM FULL</command>)
4935 </para></entry>
4936 </row>
4938 <row>
4939 <entry role="catalog_table_entry"><para role="column_definition">
4940 <structfield>autovacuum_count</structfield> <type>bigint</type>
4941 </para>
4942 <para>
4943 Number of times this table has been vacuumed by the autovacuum
4944 daemon
4945 </para></entry>
4946 </row>
4948 <row>
4949 <entry role="catalog_table_entry"><para role="column_definition">
4950 <structfield>analyze_count</structfield> <type>bigint</type>
4951 </para>
4952 <para>
4953 Number of times this table has been manually analyzed
4954 </para></entry>
4955 </row>
4957 <row>
4958 <entry role="catalog_table_entry"><para role="column_definition">
4959 <structfield>autoanalyze_count</structfield> <type>bigint</type>
4960 </para>
4961 <para>
4962 Number of times this table has been analyzed by the autovacuum
4963 daemon
4964 </para></entry>
4965 </row>
4966 </tbody>
4967 </tgroup>
4968 </table>
4970 </sect2>
4972 <sect2 id="monitoring-pg-stat-all-indexes-view">
4973 <title><structname>pg_stat_all_indexes</structname></title>
4975 <indexterm>
4976 <primary>pg_stat_all_indexes</primary>
4977 </indexterm>
4979 <para>
4980 The <structname>pg_stat_all_indexes</structname> view will contain
4981 one row for each index in the current database,
4982 showing statistics about accesses to that specific index. The
4983 <structname>pg_stat_user_indexes</structname> and
4984 <structname>pg_stat_sys_indexes</structname> views
4985 contain the same information,
4986 but filtered to only show user and system indexes respectively.
4987 </para>
4989 <table id="pg-stat-all-indexes-view" xreflabel="pg_stat_all_indexes">
4990 <title><structname>pg_stat_all_indexes</structname> View</title>
4991 <tgroup cols="1">
4992 <thead>
4993 <row>
4994 <entry role="catalog_table_entry"><para role="column_definition">
4995 Column Type
4996 </para>
4997 <para>
4998 Description
4999 </para></entry>
5000 </row>
5001 </thead>
5003 <tbody>
5004 <row>
5005 <entry role="catalog_table_entry"><para role="column_definition">
5006 <structfield>relid</structfield> <type>oid</type>
5007 </para>
5008 <para>
5009 OID of the table for this index
5010 </para></entry>
5011 </row>
5013 <row>
5014 <entry role="catalog_table_entry"><para role="column_definition">
5015 <structfield>indexrelid</structfield> <type>oid</type>
5016 </para>
5017 <para>
5018 OID of this index
5019 </para></entry>
5020 </row>
5022 <row>
5023 <entry role="catalog_table_entry"><para role="column_definition">
5024 <structfield>schemaname</structfield> <type>name</type>
5025 </para>
5026 <para>
5027 Name of the schema this index is in
5028 </para></entry>
5029 </row>
5031 <row>
5032 <entry role="catalog_table_entry"><para role="column_definition">
5033 <structfield>relname</structfield> <type>name</type>
5034 </para>
5035 <para>
5036 Name of the table for this index
5037 </para></entry>
5038 </row>
5040 <row>
5041 <entry role="catalog_table_entry"><para role="column_definition">
5042 <structfield>indexrelname</structfield> <type>name</type>
5043 </para>
5044 <para>
5045 Name of this index
5046 </para></entry>
5047 </row>
5049 <row>
5050 <entry role="catalog_table_entry"><para role="column_definition">
5051 <structfield>idx_scan</structfield> <type>bigint</type>
5052 </para>
5053 <para>
5054 Number of index scans initiated on this index
5055 </para></entry>
5056 </row>
5058 <row>
5059 <entry role="catalog_table_entry"><para role="column_definition">
5060 <structfield>last_idx_scan</structfield> <type>timestamptz</type>
5061 </para>
5062 <para>
5063 The time of the last scan on this index, based on the
5064 most recent transaction stop time
5065 </para></entry>
5066 </row>
5068 <row>
5069 <entry role="catalog_table_entry"><para role="column_definition">
5070 <structfield>idx_tup_read</structfield> <type>bigint</type>
5071 </para>
5072 <para>
5073 Number of index entries returned by scans on this index
5074 </para></entry>
5075 </row>
5077 <row>
5078 <entry role="catalog_table_entry"><para role="column_definition">
5079 <structfield>idx_tup_fetch</structfield> <type>bigint</type>
5080 </para>
5081 <para>
5082 Number of live table rows fetched by simple index scans using this
5083 index
5084 </para></entry>
5085 </row>
5086 </tbody>
5087 </tgroup>
5088 </table>
5090 <para>
5091 Indexes can be used by simple index scans, <quote>bitmap</quote> index scans,
5092 and the optimizer. In a bitmap scan
5093 the output of several indexes can be combined via AND or OR rules,
5094 so it is difficult to associate individual heap row fetches
5095 with specific indexes when a bitmap scan is used. Therefore, a bitmap
5096 scan increments the
5097 <structname>pg_stat_all_indexes</structname>.<structfield>idx_tup_read</structfield>
5098 count(s) for the index(es) it uses, and it increments the
5099 <structname>pg_stat_all_tables</structname>.<structfield>idx_tup_fetch</structfield>
5100 count for the table, but it does not affect
5101 <structname>pg_stat_all_indexes</structname>.<structfield>idx_tup_fetch</structfield>.
5102 The optimizer also accesses indexes to check for supplied constants
5103 whose values are outside the recorded range of the optimizer statistics
5104 because the optimizer statistics might be stale.
5105 </para>
5107 <note>
5108 <para>
5109 The <structfield>idx_tup_read</structfield> and <structfield>idx_tup_fetch</structfield> counts
5110 can be different even without any use of bitmap scans,
5111 because <structfield>idx_tup_read</structfield> counts
5112 index entries retrieved from the index while <structfield>idx_tup_fetch</structfield>
5113 counts live rows fetched from the table. The latter will be less if any
5114 dead or not-yet-committed rows are fetched using the index, or if any
5115 heap fetches are avoided by means of an index-only scan.
5116 </para>
5117 </note>
5119 </sect2>
5121 <sect2 id="monitoring-pg-statio-all-tables-view">
5122 <title><structname>pg_statio_all_tables</structname></title>
5124 <indexterm>
5125 <primary>pg_statio_all_tables</primary>
5126 </indexterm>
5128 <para>
5129 The <structname>pg_statio_all_tables</structname> view will contain
5130 one row for each table in the current database (including TOAST
5131 tables), showing statistics about I/O on that specific table. The
5132 <structname>pg_statio_user_tables</structname> and
5133 <structname>pg_statio_sys_tables</structname> views
5134 contain the same information,
5135 but filtered to only show user and system tables respectively.
5136 </para>
5138 <table id="pg-statio-all-tables-view" xreflabel="pg_statio_all_tables">
5139 <title><structname>pg_statio_all_tables</structname> View</title>
5140 <tgroup cols="1">
5141 <thead>
5142 <row>
5143 <entry role="catalog_table_entry"><para role="column_definition">
5144 Column Type
5145 </para>
5146 <para>
5147 Description
5148 </para></entry>
5149 </row>
5150 </thead>
5152 <tbody>
5153 <row>
5154 <entry role="catalog_table_entry"><para role="column_definition">
5155 <structfield>relid</structfield> <type>oid</type>
5156 </para>
5157 <para>
5158 OID of a table
5159 </para></entry>
5160 </row>
5162 <row>
5163 <entry role="catalog_table_entry"><para role="column_definition">
5164 <structfield>schemaname</structfield> <type>name</type>
5165 </para>
5166 <para>
5167 Name of the schema that this table is in
5168 </para></entry>
5169 </row>
5171 <row>
5172 <entry role="catalog_table_entry"><para role="column_definition">
5173 <structfield>relname</structfield> <type>name</type>
5174 </para>
5175 <para>
5176 Name of this table
5177 </para></entry>
5178 </row>
5180 <row>
5181 <entry role="catalog_table_entry"><para role="column_definition">
5182 <structfield>heap_blks_read</structfield> <type>bigint</type>
5183 </para>
5184 <para>
5185 Number of disk blocks read from this table
5186 </para></entry>
5187 </row>
5189 <row>
5190 <entry role="catalog_table_entry"><para role="column_definition">
5191 <structfield>heap_blks_hit</structfield> <type>bigint</type>
5192 </para>
5193 <para>
5194 Number of buffer hits in this table
5195 </para></entry>
5196 </row>
5198 <row>
5199 <entry role="catalog_table_entry"><para role="column_definition">
5200 <structfield>idx_blks_read</structfield> <type>bigint</type>
5201 </para>
5202 <para>
5203 Number of disk blocks read from all indexes on this table
5204 </para></entry>
5205 </row>
5207 <row>
5208 <entry role="catalog_table_entry"><para role="column_definition">
5209 <structfield>idx_blks_hit</structfield> <type>bigint</type>
5210 </para>
5211 <para>
5212 Number of buffer hits in all indexes on this table
5213 </para></entry>
5214 </row>
5216 <row>
5217 <entry role="catalog_table_entry"><para role="column_definition">
5218 <structfield>toast_blks_read</structfield> <type>bigint</type>
5219 </para>
5220 <para>
5221 Number of disk blocks read from this table's TOAST table (if any)
5222 </para></entry>
5223 </row>
5225 <row>
5226 <entry role="catalog_table_entry"><para role="column_definition">
5227 <structfield>toast_blks_hit</structfield> <type>bigint</type>
5228 </para>
5229 <para>
5230 Number of buffer hits in this table's TOAST table (if any)
5231 </para></entry>
5232 </row>
5234 <row>
5235 <entry role="catalog_table_entry"><para role="column_definition">
5236 <structfield>tidx_blks_read</structfield> <type>bigint</type>
5237 </para>
5238 <para>
5239 Number of disk blocks read from this table's TOAST table indexes (if any)
5240 </para></entry>
5241 </row>
5243 <row>
5244 <entry role="catalog_table_entry"><para role="column_definition">
5245 <structfield>tidx_blks_hit</structfield> <type>bigint</type>
5246 </para>
5247 <para>
5248 Number of buffer hits in this table's TOAST table indexes (if any)
5249 </para></entry>
5250 </row>
5251 </tbody>
5252 </tgroup>
5253 </table>
5255 </sect2>
5257 <sect2 id="monitoring-pg-statio-all-indexes-view">
5258 <title><structname>pg_statio_all_indexes</structname></title>
5260 <indexterm>
5261 <primary>pg_statio_all_indexes</primary>
5262 </indexterm>
5264 <para>
5265 The <structname>pg_statio_all_indexes</structname> view will contain
5266 one row for each index in the current database,
5267 showing statistics about I/O on that specific index. The
5268 <structname>pg_statio_user_indexes</structname> and
5269 <structname>pg_statio_sys_indexes</structname> views
5270 contain the same information,
5271 but filtered to only show user and system indexes respectively.
5272 </para>
5274 <table id="pg-statio-all-indexes-view" xreflabel="pg_statio_all_indexes">
5275 <title><structname>pg_statio_all_indexes</structname> View</title>
5276 <tgroup cols="1">
5277 <thead>
5278 <row>
5279 <entry role="catalog_table_entry"><para role="column_definition">
5280 Column Type
5281 </para>
5282 <para>
5283 Description
5284 </para></entry>
5285 </row>
5286 </thead>
5288 <tbody>
5289 <row>
5290 <entry role="catalog_table_entry"><para role="column_definition">
5291 <structfield>relid</structfield> <type>oid</type>
5292 </para>
5293 <para>
5294 OID of the table for this index
5295 </para></entry>
5296 </row>
5298 <row>
5299 <entry role="catalog_table_entry"><para role="column_definition">
5300 <structfield>indexrelid</structfield> <type>oid</type>
5301 </para>
5302 <para>
5303 OID of this index
5304 </para></entry>
5305 </row>
5307 <row>
5308 <entry role="catalog_table_entry"><para role="column_definition">
5309 <structfield>schemaname</structfield> <type>name</type>
5310 </para>
5311 <para>
5312 Name of the schema this index is in
5313 </para></entry>
5314 </row>
5316 <row>
5317 <entry role="catalog_table_entry"><para role="column_definition">
5318 <structfield>relname</structfield> <type>name</type>
5319 </para>
5320 <para>
5321 Name of the table for this index
5322 </para></entry>
5323 </row>
5325 <row>
5326 <entry role="catalog_table_entry"><para role="column_definition">
5327 <structfield>indexrelname</structfield> <type>name</type>
5328 </para>
5329 <para>
5330 Name of this index
5331 </para></entry>
5332 </row>
5334 <row>
5335 <entry role="catalog_table_entry"><para role="column_definition">
5336 <structfield>idx_blks_read</structfield> <type>bigint</type>
5337 </para>
5338 <para>
5339 Number of disk blocks read from this index
5340 </para></entry>
5341 </row>
5343 <row>
5344 <entry role="catalog_table_entry"><para role="column_definition">
5345 <structfield>idx_blks_hit</structfield> <type>bigint</type>
5346 </para>
5347 <para>
5348 Number of buffer hits in this index
5349 </para></entry>
5350 </row>
5351 </tbody>
5352 </tgroup>
5353 </table>
5355 </sect2>
5357 <sect2 id="monitoring-pg-statio-all-sequences-view">
5358 <title><structname>pg_statio_all_sequences</structname></title>
5360 <indexterm>
5361 <primary>pg_statio_all_sequences</primary>
5362 </indexterm>
5364 <para>
5365 The <structname>pg_statio_all_sequences</structname> view will contain
5366 one row for each sequence in the current database,
5367 showing statistics about I/O on that specific sequence.
5368 </para>
5370 <table id="pg-statio-all-sequences-view" xreflabel="pg_statio_all_sequences">
5371 <title><structname>pg_statio_all_sequences</structname> View</title>
5372 <tgroup cols="1">
5373 <thead>
5374 <row>
5375 <entry role="catalog_table_entry"><para role="column_definition">
5376 Column Type
5377 </para>
5378 <para>
5379 Description
5380 </para></entry>
5381 </row>
5382 </thead>
5384 <tbody>
5385 <row>
5386 <entry role="catalog_table_entry"><para role="column_definition">
5387 <structfield>relid</structfield> <type>oid</type>
5388 </para>
5389 <para>
5390 OID of a sequence
5391 </para></entry>
5392 </row>
5394 <row>
5395 <entry role="catalog_table_entry"><para role="column_definition">
5396 <structfield>schemaname</structfield> <type>name</type>
5397 </para>
5398 <para>
5399 Name of the schema this sequence is in
5400 </para></entry>
5401 </row>
5403 <row>
5404 <entry role="catalog_table_entry"><para role="column_definition">
5405 <structfield>relname</structfield> <type>name</type>
5406 </para>
5407 <para>
5408 Name of this sequence
5409 </para></entry>
5410 </row>
5412 <row>
5413 <entry role="catalog_table_entry"><para role="column_definition">
5414 <structfield>blks_read</structfield> <type>bigint</type>
5415 </para>
5416 <para>
5417 Number of disk blocks read from this sequence
5418 </para></entry>
5419 </row>
5421 <row>
5422 <entry role="catalog_table_entry"><para role="column_definition">
5423 <structfield>blks_hit</structfield> <type>bigint</type>
5424 </para>
5425 <para>
5426 Number of buffer hits in this sequence
5427 </para></entry>
5428 </row>
5429 </tbody>
5430 </tgroup>
5431 </table>
5433 </sect2>
5435 <sect2 id="monitoring-pg-stat-user-functions-view">
5436 <title><structname>pg_stat_user_functions</structname></title>
5438 <indexterm>
5439 <primary>pg_stat_user_functions</primary>
5440 </indexterm>
5442 <para>
5443 The <structname>pg_stat_user_functions</structname> view will contain
5444 one row for each tracked function, showing statistics about executions of
5445 that function. The <xref linkend="guc-track-functions"/> parameter
5446 controls exactly which functions are tracked.
5447 </para>
5449 <table id="pg-stat-user-functions-view" xreflabel="pg_stat_user_functions">
5450 <title><structname>pg_stat_user_functions</structname> View</title>
5451 <tgroup cols="1">
5452 <thead>
5453 <row>
5454 <entry role="catalog_table_entry"><para role="column_definition">
5455 Column Type
5456 </para>
5457 <para>
5458 Description
5459 </para></entry>
5460 </row>
5461 </thead>
5463 <tbody>
5464 <row>
5465 <entry role="catalog_table_entry"><para role="column_definition">
5466 <structfield>funcid</structfield> <type>oid</type>
5467 </para>
5468 <para>
5469 OID of a function
5470 </para></entry>
5471 </row>
5473 <row>
5474 <entry role="catalog_table_entry"><para role="column_definition">
5475 <structfield>schemaname</structfield> <type>name</type>
5476 </para>
5477 <para>
5478 Name of the schema this function is in
5479 </para></entry>
5480 </row>
5482 <row>
5483 <entry role="catalog_table_entry"><para role="column_definition">
5484 <structfield>funcname</structfield> <type>name</type>
5485 </para>
5486 <para>
5487 Name of this function
5488 </para></entry>
5489 </row>
5491 <row>
5492 <entry role="catalog_table_entry"><para role="column_definition">
5493 <structfield>calls</structfield> <type>bigint</type>
5494 </para>
5495 <para>
5496 Number of times this function has been called
5497 </para></entry>
5498 </row>
5500 <row>
5501 <entry role="catalog_table_entry"><para role="column_definition">
5502 <structfield>total_time</structfield> <type>double precision</type>
5503 </para>
5504 <para>
5505 Total time spent in this function and all other functions
5506 called by it, in milliseconds
5507 </para></entry>
5508 </row>
5510 <row>
5511 <entry role="catalog_table_entry"><para role="column_definition">
5512 <structfield>self_time</structfield> <type>double precision</type>
5513 </para>
5514 <para>
5515 Total time spent in this function itself, not including
5516 other functions called by it, in milliseconds
5517 </para></entry>
5518 </row>
5519 </tbody>
5520 </tgroup>
5521 </table>
5523 </sect2>
5525 <sect2 id="monitoring-pg-stat-slru-view">
5526 <title><structname>pg_stat_slru</structname></title>
5528 <indexterm>
5529 <primary>SLRU</primary>
5530 </indexterm>
5532 <indexterm>
5533 <primary>pg_stat_slru</primary>
5534 </indexterm>
5536 <para>
5537 <productname>PostgreSQL</productname> accesses certain on-disk information
5538 via <firstterm>SLRU</firstterm> (simple least-recently-used) caches.
5539 The <structname>pg_stat_slru</structname> view will contain
5540 one row for each tracked SLRU cache, showing statistics about access
5541 to cached pages.
5542 </para>
5544 <table id="pg-stat-slru-view" xreflabel="pg_stat_slru">
5545 <title><structname>pg_stat_slru</structname> View</title>
5546 <tgroup cols="1">
5547 <thead>
5548 <row>
5549 <entry role="catalog_table_entry"><para role="column_definition">
5550 Column Type
5551 </para>
5552 <para>
5553 Description
5554 </para></entry>
5555 </row>
5556 </thead>
5558 <tbody>
5559 <row>
5560 <entry role="catalog_table_entry"><para role="column_definition">
5561 <structfield>name</structfield> <type>text</type>
5562 </para>
5563 <para>
5564 Name of the SLRU
5565 </para></entry>
5566 </row>
5568 <row>
5569 <entry role="catalog_table_entry"><para role="column_definition">
5570 <structfield>blks_zeroed</structfield> <type>bigint</type>
5571 </para>
5572 <para>
5573 Number of blocks zeroed during initializations
5574 </para></entry>
5575 </row>
5577 <row>
5578 <entry role="catalog_table_entry"><para role="column_definition">
5579 <structfield>blks_hit</structfield> <type>bigint</type>
5580 </para>
5581 <para>
5582 Number of times disk blocks were found already in the SLRU,
5583 so that a read was not necessary (this only includes hits in the
5584 SLRU, not the operating system's file system cache)
5585 </para></entry>
5586 </row>
5588 <row>
5589 <entry role="catalog_table_entry"><para role="column_definition">
5590 <structfield>blks_read</structfield> <type>bigint</type>
5591 </para>
5592 <para>
5593 Number of disk blocks read for this SLRU
5594 </para></entry>
5595 </row>
5597 <row>
5598 <entry role="catalog_table_entry"><para role="column_definition">
5599 <structfield>blks_written</structfield> <type>bigint</type>
5600 </para>
5601 <para>
5602 Number of disk blocks written for this SLRU
5603 </para></entry>
5604 </row>
5606 <row>
5607 <entry role="catalog_table_entry"><para role="column_definition">
5608 <structfield>blks_exists</structfield> <type>bigint</type>
5609 </para>
5610 <para>
5611 Number of blocks checked for existence for this SLRU
5612 </para></entry>
5613 </row>
5615 <row>
5616 <entry role="catalog_table_entry"><para role="column_definition">
5617 <structfield>flushes</structfield> <type>bigint</type>
5618 </para>
5619 <para>
5620 Number of flushes of dirty data for this SLRU
5621 </para></entry>
5622 </row>
5624 <row>
5625 <entry role="catalog_table_entry"><para role="column_definition">
5626 <structfield>truncates</structfield> <type>bigint</type>
5627 </para>
5628 <para>
5629 Number of truncates for this SLRU
5630 </para></entry>
5631 </row>
5633 <row>
5634 <entry role="catalog_table_entry"><para role="column_definition">
5635 <structfield>stats_reset</structfield> <type>timestamp with time zone</type>
5636 </para>
5637 <para>
5638 Time at which these statistics were last reset
5639 </para></entry>
5640 </row>
5641 </tbody>
5642 </tgroup>
5643 </table>
5645 </sect2>
5647 <sect2 id="monitoring-stats-functions">
5648 <title>Statistics Functions</title>
5650 <para>
5651 Other ways of looking at the statistics can be set up by writing
5652 queries that use the same underlying statistics access functions used by
5653 the standard views shown above. For details such as the functions' names,
5654 consult the definitions of the standard views. (For example, in
5655 <application>psql</application> you could issue <literal>\d+ pg_stat_activity</literal>.)
5656 The access functions for per-database statistics take a database OID as an
5657 argument to identify which database to report on.
5658 The per-table and per-index functions take a table or index OID.
5659 The functions for per-function statistics take a function OID.
5660 Note that only tables, indexes, and functions in the current database
5661 can be seen with these functions.
5662 </para>
5664 <para>
5665 Additional functions related to the cumulative statistics system are listed
5666 in <xref linkend="monitoring-stats-funcs-table"/>.
5667 </para>
5669 <table id="monitoring-stats-funcs-table">
5670 <title>Additional Statistics Functions</title>
5671 <tgroup cols="1">
5672 <thead>
5673 <row>
5674 <entry role="func_table_entry"><para role="func_signature">
5675 Function
5676 </para>
5677 <para>
5678 Description
5679 </para></entry>
5680 </row>
5681 </thead>
5683 <tbody>
5684 <row>
5685 <!-- See also the entry for this in func.sgml -->
5686 <entry role="func_table_entry"><para role="func_signature">
5687 <function>pg_backend_pid</function> ()
5688 <returnvalue>integer</returnvalue>
5689 </para>
5690 <para>
5691 Returns the process ID of the server process attached to the current
5692 session.
5693 </para></entry>
5694 </row>
5696 <row>
5697 <entry role="func_table_entry"><para role="func_signature">
5698 <indexterm>
5699 <primary>pg_stat_get_activity</primary>
5700 </indexterm>
5701 <function>pg_stat_get_activity</function> ( <type>integer</type> )
5702 <returnvalue>setof record</returnvalue>
5703 </para>
5704 <para>
5705 Returns a record of information about the backend with the specified
5706 process ID, or one record for each active backend in the system
5707 if <literal>NULL</literal> is specified. The fields returned are a
5708 subset of those in the <structname>pg_stat_activity</structname> view.
5709 </para></entry>
5710 </row>
5712 <row>
5713 <entry role="func_table_entry"><para role="func_signature">
5714 <indexterm>
5715 <primary>pg_stat_get_snapshot_timestamp</primary>
5716 </indexterm>
5717 <function>pg_stat_get_snapshot_timestamp</function> ()
5718 <returnvalue>timestamp with time zone</returnvalue>
5719 </para>
5720 <para>
5721 Returns the timestamp of the current statistics snapshot, or NULL if
5722 no statistics snapshot has been taken. A snapshot is taken the first
5723 time cumulative statistics are accessed in a transaction if
5724 <varname>stats_fetch_consistency</varname> is set to
5725 <literal>snapshot</literal>
5726 </para></entry>
5727 </row>
5729 <row>
5730 <entry role="func_table_entry"><para role="func_signature">
5731 <indexterm>
5732 <primary>pg_stat_get_xact_blocks_fetched</primary>
5733 </indexterm>
5734 <function>pg_stat_get_xact_blocks_fetched</function> ( <type>oid</type> )
5735 <returnvalue>bigint</returnvalue>
5736 </para>
5737 <para>
5738 Returns the number of block read requests for table or index, in the
5739 current transaction. This number minus
5740 <function>pg_stat_get_xact_blocks_hit</function> gives the number of
5741 kernel <function>read()</function> calls; the number of actual
5742 physical reads is usually lower due to kernel-level buffering.
5743 </para></entry>
5744 </row>
5746 <row>
5747 <entry role="func_table_entry"><para role="func_signature">
5748 <indexterm>
5749 <primary>pg_stat_get_xact_blocks_hit</primary>
5750 </indexterm>
5751 <function>pg_stat_get_xact_blocks_hit</function> ( <type>oid</type> )
5752 <returnvalue>bigint</returnvalue>
5753 </para>
5754 <para>
5755 Returns the number of block read requests for table or index, in the
5756 current transaction, found in cache (not triggering kernel
5757 <function>read()</function> calls).
5758 </para></entry>
5759 </row>
5761 <row>
5762 <entry role="func_table_entry"><para role="func_signature">
5763 <indexterm>
5764 <primary>pg_stat_clear_snapshot</primary>
5765 </indexterm>
5766 <function>pg_stat_clear_snapshot</function> ()
5767 <returnvalue>void</returnvalue>
5768 </para>
5769 <para>
5770 Discards the current statistics snapshot or cached information.
5771 </para></entry>
5772 </row>
5774 <row>
5775 <entry role="func_table_entry"><para role="func_signature">
5776 <indexterm>
5777 <primary>pg_stat_reset</primary>
5778 </indexterm>
5779 <function>pg_stat_reset</function> ()
5780 <returnvalue>void</returnvalue>
5781 </para>
5782 <para>
5783 Resets all statistics counters for the current database to zero.
5784 </para>
5785 <para>
5786 This function is restricted to superusers by default, but other users
5787 can be granted EXECUTE to run the function.
5788 </para></entry>
5789 </row>
5791 <row>
5792 <entry role="func_table_entry"><para role="func_signature">
5793 <indexterm>
5794 <primary>pg_stat_reset_shared</primary>
5795 </indexterm>
5796 <function>pg_stat_reset_shared</function> ( <type>text</type> )
5797 <returnvalue>void</returnvalue>
5798 </para>
5799 <para>
5800 Resets some cluster-wide statistics counters to zero, depending on the
5801 argument. The argument can be <literal>bgwriter</literal> to reset
5802 all the counters shown in
5803 the <structname>pg_stat_bgwriter</structname>
5804 view, <literal>archiver</literal> to reset all the counters shown in
5805 the <structname>pg_stat_archiver</structname> view,
5806 <literal>io</literal> to reset all the counters shown in the
5807 <structname>pg_stat_io</structname> view,
5808 <literal>wal</literal> to reset all the counters shown in the
5809 <structname>pg_stat_wal</structname> view or
5810 <literal>recovery_prefetch</literal> to reset all the counters shown
5811 in the <structname>pg_stat_recovery_prefetch</structname> view.
5812 </para>
5813 <para>
5814 This function is restricted to superusers by default, but other users
5815 can be granted EXECUTE to run the function.
5816 </para></entry>
5817 </row>
5819 <row>
5820 <entry role="func_table_entry"><para role="func_signature">
5821 <indexterm>
5822 <primary>pg_stat_reset_single_table_counters</primary>
5823 </indexterm>
5824 <function>pg_stat_reset_single_table_counters</function> ( <type>oid</type> )
5825 <returnvalue>void</returnvalue>
5826 </para>
5827 <para>
5828 Resets statistics for a single table or index in the current database
5829 or shared across all databases in the cluster to zero.
5830 </para>
5831 <para>
5832 This function is restricted to superusers by default, but other users
5833 can be granted EXECUTE to run the function.
5834 </para></entry>
5835 </row>
5837 <row>
5838 <entry role="func_table_entry"><para role="func_signature">
5839 <indexterm>
5840 <primary>pg_stat_reset_single_function_counters</primary>
5841 </indexterm>
5842 <function>pg_stat_reset_single_function_counters</function> ( <type>oid</type> )
5843 <returnvalue>void</returnvalue>
5844 </para>
5845 <para>
5846 Resets statistics for a single function in the current database to
5847 zero.
5848 </para>
5849 <para>
5850 This function is restricted to superusers by default, but other users
5851 can be granted EXECUTE to run the function.
5852 </para></entry>
5853 </row>
5855 <row>
5856 <entry role="func_table_entry"><para role="func_signature">
5857 <indexterm>
5858 <primary>pg_stat_reset_slru</primary>
5859 </indexterm>
5860 <function>pg_stat_reset_slru</function> ( <type>text</type> )
5861 <returnvalue>void</returnvalue>
5862 </para>
5863 <para>
5864 Resets statistics to zero for a single SLRU cache, or for all SLRUs in
5865 the cluster. If the argument is NULL, all counters shown in
5866 the <structname>pg_stat_slru</structname> view for all SLRU caches are
5867 reset. The argument can be one of
5868 <literal>CommitTs</literal>,
5869 <literal>MultiXactMember</literal>,
5870 <literal>MultiXactOffset</literal>,
5871 <literal>Notify</literal>,
5872 <literal>Serial</literal>,
5873 <literal>Subtrans</literal>, or
5874 <literal>Xact</literal>
5875 to reset the counters for only that entry.
5876 If the argument is <literal>other</literal> (or indeed, any
5877 unrecognized name), then the counters for all other SLRU caches, such
5878 as extension-defined caches, are reset.
5879 </para>
5880 <para>
5881 This function is restricted to superusers by default, but other users
5882 can be granted EXECUTE to run the function.
5883 </para></entry>
5884 </row>
5886 <row>
5887 <entry role="func_table_entry"><para role="func_signature">
5888 <indexterm>
5889 <primary>pg_stat_reset_replication_slot</primary>
5890 </indexterm>
5891 <function>pg_stat_reset_replication_slot</function> ( <type>text</type> )
5892 <returnvalue>void</returnvalue>
5893 </para>
5894 <para>
5895 Resets statistics of the replication slot defined by the argument. If
5896 the argument is <literal>NULL</literal>, resets statistics for all
5897 the replication slots.
5898 </para>
5899 <para>
5900 This function is restricted to superusers by default, but other users
5901 can be granted EXECUTE to run the function.
5902 </para></entry>
5903 </row>
5905 <row>
5906 <entry role="func_table_entry"><para role="func_signature">
5907 <indexterm>
5908 <primary>pg_stat_reset_subscription_stats</primary>
5909 </indexterm>
5910 <function>pg_stat_reset_subscription_stats</function> ( <type>oid</type> )
5911 <returnvalue>void</returnvalue>
5912 </para>
5913 <para>
5914 Resets statistics for a single subscription shown in the
5915 <structname>pg_stat_subscription_stats</structname> view to zero. If
5916 the argument is <literal>NULL</literal>, reset statistics for all
5917 subscriptions.
5918 </para>
5919 <para>
5920 This function is restricted to superusers by default, but other users
5921 can be granted EXECUTE to run the function.
5922 </para></entry>
5923 </row>
5924 </tbody>
5925 </tgroup>
5926 </table>
5928 <warning>
5929 <para>
5930 Using <function>pg_stat_reset()</function> also resets counters that
5931 autovacuum uses to determine when to trigger a vacuum or an analyze.
5932 Resetting these counters can cause autovacuum to not perform necessary
5933 work, which can cause problems such as table bloat or out-dated
5934 table statistics. A database-wide <command>ANALYZE</command> is
5935 recommended after the statistics have been reset.
5936 </para>
5937 </warning>
5939 <para>
5940 <function>pg_stat_get_activity</function>, the underlying function of
5941 the <structname>pg_stat_activity</structname> view, returns a set of records
5942 containing all the available information about each backend process.
5943 Sometimes it may be more convenient to obtain just a subset of this
5944 information. In such cases, another set of per-backend statistics
5945 access functions can be used; these are shown in <xref
5946 linkend="monitoring-stats-backend-funcs-table"/>.
5947 These access functions use the session's backend ID number, which is a
5948 small positive integer that is distinct from the backend ID of any
5949 concurrent session, although a session's ID can be recycled as soon as
5950 it exits. The backend ID is used, among other things, to identify the
5951 session's temporary schema if it has one.
5952 The function <function>pg_stat_get_backend_idset</function> provides a
5953 convenient way to list all the active backends' ID numbers for
5954 invoking these functions. For example, to show the <acronym>PID</acronym>s and
5955 current queries of all backends:
5957 <programlisting>
5958 SELECT pg_stat_get_backend_pid(backendid) AS pid,
5959 pg_stat_get_backend_activity(backendid) AS query
5960 FROM pg_stat_get_backend_idset() AS backendid;
5961 </programlisting>
5962 </para>
5964 <table id="monitoring-stats-backend-funcs-table">
5965 <title>Per-Backend Statistics Functions</title>
5966 <tgroup cols="1">
5967 <thead>
5968 <row>
5969 <entry role="func_table_entry"><para role="func_signature">
5970 Function
5971 </para>
5972 <para>
5973 Description
5974 </para></entry>
5975 </row>
5976 </thead>
5978 <tbody>
5979 <row>
5980 <entry role="func_table_entry"><para role="func_signature">
5981 <indexterm>
5982 <primary>pg_stat_get_backend_activity</primary>
5983 </indexterm>
5984 <function>pg_stat_get_backend_activity</function> ( <type>integer</type> )
5985 <returnvalue>text</returnvalue>
5986 </para>
5987 <para>
5988 Returns the text of this backend's most recent query.
5989 </para></entry>
5990 </row>
5992 <row>
5993 <entry role="func_table_entry"><para role="func_signature">
5994 <indexterm>
5995 <primary>pg_stat_get_backend_activity_start</primary>
5996 </indexterm>
5997 <function>pg_stat_get_backend_activity_start</function> ( <type>integer</type> )
5998 <returnvalue>timestamp with time zone</returnvalue>
5999 </para>
6000 <para>
6001 Returns the time when the backend's most recent query was started.
6002 </para></entry>
6003 </row>
6005 <row>
6006 <entry role="func_table_entry"><para role="func_signature">
6007 <indexterm>
6008 <primary>pg_stat_get_backend_client_addr</primary>
6009 </indexterm>
6010 <function>pg_stat_get_backend_client_addr</function> ( <type>integer</type> )
6011 <returnvalue>inet</returnvalue>
6012 </para>
6013 <para>
6014 Returns the IP address of the client connected to this backend.
6015 </para></entry>
6016 </row>
6018 <row>
6019 <entry role="func_table_entry"><para role="func_signature">
6020 <indexterm>
6021 <primary>pg_stat_get_backend_client_port</primary>
6022 </indexterm>
6023 <function>pg_stat_get_backend_client_port</function> ( <type>integer</type> )
6024 <returnvalue>integer</returnvalue>
6025 </para>
6026 <para>
6027 Returns the TCP port number that the client is using for communication.
6028 </para></entry>
6029 </row>
6031 <row>
6032 <entry role="func_table_entry"><para role="func_signature">
6033 <indexterm>
6034 <primary>pg_stat_get_backend_dbid</primary>
6035 </indexterm>
6036 <function>pg_stat_get_backend_dbid</function> ( <type>integer</type> )
6037 <returnvalue>oid</returnvalue>
6038 </para>
6039 <para>
6040 Returns the OID of the database this backend is connected to.
6041 </para></entry>
6042 </row>
6044 <row>
6045 <entry role="func_table_entry"><para role="func_signature">
6046 <indexterm>
6047 <primary>pg_stat_get_backend_idset</primary>
6048 </indexterm>
6049 <function>pg_stat_get_backend_idset</function> ()
6050 <returnvalue>setof integer</returnvalue>
6051 </para>
6052 <para>
6053 Returns the set of currently active backend ID numbers.
6054 </para></entry>
6055 </row>
6057 <row>
6058 <entry role="func_table_entry"><para role="func_signature">
6059 <indexterm>
6060 <primary>pg_stat_get_backend_pid</primary>
6061 </indexterm>
6062 <function>pg_stat_get_backend_pid</function> ( <type>integer</type> )
6063 <returnvalue>integer</returnvalue>
6064 </para>
6065 <para>
6066 Returns the process ID of this backend.
6067 </para></entry>
6068 </row>
6070 <row>
6071 <entry role="func_table_entry"><para role="func_signature">
6072 <indexterm>
6073 <primary>pg_stat_get_backend_start</primary>
6074 </indexterm>
6075 <function>pg_stat_get_backend_start</function> ( <type>integer</type> )
6076 <returnvalue>timestamp with time zone</returnvalue>
6077 </para>
6078 <para>
6079 Returns the time when this process was started.
6080 </para></entry>
6081 </row>
6083 <row>
6084 <entry role="func_table_entry"><para role="func_signature">
6085 <indexterm>
6086 <primary>pg_stat_get_backend_subxact</primary>
6087 </indexterm>
6088 <function>pg_stat_get_backend_subxact</function> ( <type>integer</type> )
6089 <returnvalue>record</returnvalue>
6090 </para>
6091 <para>
6092 Returns a record of information about the subtransactions of the
6093 backend with the specified ID.
6094 The fields returned are <parameter>subxact_count</parameter>, which
6095 is the number of subtransactions in the backend's subtransaction cache,
6096 and <parameter>subxact_overflow</parameter>, which indicates whether
6097 the backend's subtransaction cache is overflowed or not.
6098 </para></entry>
6099 </row>
6101 <row>
6102 <entry role="func_table_entry"><para role="func_signature">
6103 <indexterm>
6104 <primary>pg_stat_get_backend_userid</primary>
6105 </indexterm>
6106 <function>pg_stat_get_backend_userid</function> ( <type>integer</type> )
6107 <returnvalue>oid</returnvalue>
6108 </para>
6109 <para>
6110 Returns the OID of the user logged into this backend.
6111 </para></entry>
6112 </row>
6114 <row>
6115 <entry role="func_table_entry"><para role="func_signature">
6116 <indexterm>
6117 <primary>pg_stat_get_backend_wait_event</primary>
6118 </indexterm>
6119 <function>pg_stat_get_backend_wait_event</function> ( <type>integer</type> )
6120 <returnvalue>text</returnvalue>
6121 </para>
6122 <para>
6123 Returns the wait event name if this backend is currently waiting,
6124 otherwise NULL. See <xref linkend="wait-event-activity-table"/> through
6125 <xref linkend="wait-event-timeout-table"/>.
6126 </para></entry>
6127 </row>
6129 <row>
6130 <entry role="func_table_entry"><para role="func_signature">
6131 <indexterm>
6132 <primary>pg_stat_get_backend_wait_event_type</primary>
6133 </indexterm>
6134 <function>pg_stat_get_backend_wait_event_type</function> ( <type>integer</type> )
6135 <returnvalue>text</returnvalue>
6136 </para>
6137 <para>
6138 Returns the wait event type name if this backend is currently waiting,
6139 otherwise NULL. See <xref linkend="wait-event-table"/> for details.
6140 </para></entry>
6141 </row>
6143 <row>
6144 <entry role="func_table_entry"><para role="func_signature">
6145 <indexterm>
6146 <primary>pg_stat_get_backend_xact_start</primary>
6147 </indexterm>
6148 <function>pg_stat_get_backend_xact_start</function> ( <type>integer</type> )
6149 <returnvalue>timestamp with time zone</returnvalue>
6150 </para>
6151 <para>
6152 Returns the time when the backend's current transaction was started.
6153 </para></entry>
6154 </row>
6155 </tbody>
6156 </tgroup>
6157 </table>
6159 </sect2>
6160 </sect1>
6162 <sect1 id="monitoring-locks">
6163 <title>Viewing Locks</title>
6165 <indexterm zone="monitoring-locks">
6166 <primary>lock</primary>
6167 <secondary>monitoring</secondary>
6168 </indexterm>
6170 <para>
6171 Another useful tool for monitoring database activity is the
6172 <structname>pg_locks</structname> system table. It allows the
6173 database administrator to view information about the outstanding
6174 locks in the lock manager. For example, this capability can be used
6177 <itemizedlist>
6178 <listitem>
6179 <para>
6180 View all the locks currently outstanding, all the locks on
6181 relations in a particular database, all the locks on a
6182 particular relation, or all the locks held by a particular
6183 <productname>PostgreSQL</productname> session.
6184 </para>
6185 </listitem>
6187 <listitem>
6188 <para>
6189 Determine the relation in the current database with the most
6190 ungranted locks (which might be a source of contention among
6191 database clients).
6192 </para>
6193 </listitem>
6195 <listitem>
6196 <para>
6197 Determine the effect of lock contention on overall database
6198 performance, as well as the extent to which contention varies
6199 with overall database traffic.
6200 </para>
6201 </listitem>
6202 </itemizedlist>
6204 Details of the <structname>pg_locks</structname> view appear in
6205 <xref linkend="view-pg-locks"/>.
6206 For more information on locking and managing concurrency with
6207 <productname>PostgreSQL</productname>, refer to <xref linkend="mvcc"/>.
6208 </para>
6209 </sect1>
6211 <sect1 id="progress-reporting">
6212 <title>Progress Reporting</title>
6214 <para>
6215 <productname>PostgreSQL</productname> has the ability to report the progress of
6216 certain commands during command execution. Currently, the only commands
6217 which support progress reporting are <command>ANALYZE</command>,
6218 <command>CLUSTER</command>,
6219 <command>CREATE INDEX</command>, <command>VACUUM</command>,
6220 <command>COPY</command>,
6221 and <xref linkend="protocol-replication-base-backup"/> (i.e., replication
6222 command that <xref linkend="app-pgbasebackup"/> issues to take
6223 a base backup).
6224 This may be expanded in the future.
6225 </para>
6227 <sect2 id="analyze-progress-reporting">
6228 <title>ANALYZE Progress Reporting</title>
6230 <indexterm>
6231 <primary>pg_stat_progress_analyze</primary>
6232 </indexterm>
6234 <para>
6235 Whenever <command>ANALYZE</command> is running, the
6236 <structname>pg_stat_progress_analyze</structname> view will contain a
6237 row for each backend that is currently running that command. The tables
6238 below describe the information that will be reported and provide
6239 information about how to interpret it.
6240 </para>
6242 <table id="pg-stat-progress-analyze-view" xreflabel="pg_stat_progress_analyze">
6243 <title><structname>pg_stat_progress_analyze</structname> View</title>
6244 <tgroup cols="1">
6245 <thead>
6246 <row>
6247 <entry role="catalog_table_entry"><para role="column_definition">
6248 Column Type
6249 </para>
6250 <para>
6251 Description
6252 </para></entry>
6253 </row>
6254 </thead>
6256 <tbody>
6257 <row>
6258 <entry role="catalog_table_entry"><para role="column_definition">
6259 <structfield>pid</structfield> <type>integer</type>
6260 </para>
6261 <para>
6262 Process ID of backend.
6263 </para></entry>
6264 </row>
6266 <row>
6267 <entry role="catalog_table_entry"><para role="column_definition">
6268 <structfield>datid</structfield> <type>oid</type>
6269 </para>
6270 <para>
6271 OID of the database to which this backend is connected.
6272 </para></entry>
6273 </row>
6275 <row>
6276 <entry role="catalog_table_entry"><para role="column_definition">
6277 <structfield>datname</structfield> <type>name</type>
6278 </para>
6279 <para>
6280 Name of the database to which this backend is connected.
6281 </para></entry>
6282 </row>
6284 <row>
6285 <entry role="catalog_table_entry"><para role="column_definition">
6286 <structfield>relid</structfield> <type>oid</type>
6287 </para>
6288 <para>
6289 OID of the table being analyzed.
6290 </para></entry>
6291 </row>
6293 <row>
6294 <entry role="catalog_table_entry"><para role="column_definition">
6295 <structfield>phase</structfield> <type>text</type>
6296 </para>
6297 <para>
6298 Current processing phase. See <xref linkend="analyze-phases"/>.
6299 </para></entry>
6300 </row>
6302 <row>
6303 <entry role="catalog_table_entry"><para role="column_definition">
6304 <structfield>sample_blks_total</structfield> <type>bigint</type>
6305 </para>
6306 <para>
6307 Total number of heap blocks that will be sampled.
6308 </para></entry>
6309 </row>
6311 <row>
6312 <entry role="catalog_table_entry"><para role="column_definition">
6313 <structfield>sample_blks_scanned</structfield> <type>bigint</type>
6314 </para>
6315 <para>
6316 Number of heap blocks scanned.
6317 </para></entry>
6318 </row>
6320 <row>
6321 <entry role="catalog_table_entry"><para role="column_definition">
6322 <structfield>ext_stats_total</structfield> <type>bigint</type>
6323 </para>
6324 <para>
6325 Number of extended statistics.
6326 </para></entry>
6327 </row>
6329 <row>
6330 <entry role="catalog_table_entry"><para role="column_definition">
6331 <structfield>ext_stats_computed</structfield> <type>bigint</type>
6332 </para>
6333 <para>
6334 Number of extended statistics computed. This counter only advances
6335 when the phase is <literal>computing extended statistics</literal>.
6336 </para></entry>
6337 </row>
6339 <row>
6340 <entry role="catalog_table_entry"><para role="column_definition">
6341 <structfield>child_tables_total</structfield> <type>bigint</type>
6342 </para>
6343 <para>
6344 Number of child tables.
6345 </para></entry>
6346 </row>
6348 <row>
6349 <entry role="catalog_table_entry"><para role="column_definition">
6350 <structfield>child_tables_done</structfield> <type>bigint</type>
6351 </para>
6352 <para>
6353 Number of child tables scanned. This counter only advances when the
6354 phase is <literal>acquiring inherited sample rows</literal>.
6355 </para></entry>
6356 </row>
6358 <row>
6359 <entry role="catalog_table_entry"><para role="column_definition">
6360 <structfield>current_child_table_relid</structfield> <type>oid</type>
6361 </para>
6362 <para>
6363 OID of the child table currently being scanned. This field is
6364 only valid when the phase is
6365 <literal>acquiring inherited sample rows</literal>.
6366 </para></entry>
6367 </row>
6368 </tbody>
6369 </tgroup>
6370 </table>
6372 <table id="analyze-phases">
6373 <title>ANALYZE Phases</title>
6374 <tgroup cols="2">
6375 <colspec colname="col1" colwidth="1*"/>
6376 <colspec colname="col2" colwidth="2*"/>
6377 <thead>
6378 <row>
6379 <entry>Phase</entry>
6380 <entry>Description</entry>
6381 </row>
6382 </thead>
6383 <tbody>
6384 <row>
6385 <entry><literal>initializing</literal></entry>
6386 <entry>
6387 The command is preparing to begin scanning the heap. This phase is
6388 expected to be very brief.
6389 </entry>
6390 </row>
6391 <row>
6392 <entry><literal>acquiring sample rows</literal></entry>
6393 <entry>
6394 The command is currently scanning the table given by
6395 <structfield>relid</structfield> to obtain sample rows.
6396 </entry>
6397 </row>
6398 <row>
6399 <entry><literal>acquiring inherited sample rows</literal></entry>
6400 <entry>
6401 The command is currently scanning child tables to obtain sample rows.
6402 Columns <structfield>child_tables_total</structfield>,
6403 <structfield>child_tables_done</structfield>, and
6404 <structfield>current_child_table_relid</structfield> contain the
6405 progress information for this phase.
6406 </entry>
6407 </row>
6408 <row>
6409 <entry><literal>computing statistics</literal></entry>
6410 <entry>
6411 The command is computing statistics from the sample rows obtained
6412 during the table scan.
6413 </entry>
6414 </row>
6415 <row>
6416 <entry><literal>computing extended statistics</literal></entry>
6417 <entry>
6418 The command is computing extended statistics from the sample rows
6419 obtained during the table scan.
6420 </entry>
6421 </row>
6422 <row>
6423 <entry><literal>finalizing analyze</literal></entry>
6424 <entry>
6425 The command is updating <structname>pg_class</structname>. When this
6426 phase is completed, <command>ANALYZE</command> will end.
6427 </entry>
6428 </row>
6429 </tbody>
6430 </tgroup>
6431 </table>
6433 <note>
6434 <para>
6435 Note that when <command>ANALYZE</command> is run on a partitioned table,
6436 all of its partitions are also recursively analyzed.
6437 In that case, <command>ANALYZE</command>
6438 progress is reported first for the parent table, whereby its inheritance
6439 statistics are collected, followed by that for each partition.
6440 </para>
6441 </note>
6442 </sect2>
6444 <sect2 id="cluster-progress-reporting">
6445 <title>CLUSTER Progress Reporting</title>
6447 <indexterm>
6448 <primary>pg_stat_progress_cluster</primary>
6449 </indexterm>
6451 <para>
6452 Whenever <command>CLUSTER</command> or <command>VACUUM FULL</command> is
6453 running, the <structname>pg_stat_progress_cluster</structname> view will
6454 contain a row for each backend that is currently running either command.
6455 The tables below describe the information that will be reported and
6456 provide information about how to interpret it.
6457 </para>
6459 <table id="pg-stat-progress-cluster-view" xreflabel="pg_stat_progress_cluster">
6460 <title><structname>pg_stat_progress_cluster</structname> View</title>
6461 <tgroup cols="1">
6462 <thead>
6463 <row>
6464 <entry role="catalog_table_entry"><para role="column_definition">
6465 Column Type
6466 </para>
6467 <para>
6468 Description
6469 </para></entry>
6470 </row>
6471 </thead>
6473 <tbody>
6474 <row>
6475 <entry role="catalog_table_entry"><para role="column_definition">
6476 <structfield>pid</structfield> <type>integer</type>
6477 </para>
6478 <para>
6479 Process ID of backend.
6480 </para></entry>
6481 </row>
6483 <row>
6484 <entry role="catalog_table_entry"><para role="column_definition">
6485 <structfield>datid</structfield> <type>oid</type>
6486 </para>
6487 <para>
6488 OID of the database to which this backend is connected.
6489 </para></entry>
6490 </row>
6492 <row>
6493 <entry role="catalog_table_entry"><para role="column_definition">
6494 <structfield>datname</structfield> <type>name</type>
6495 </para>
6496 <para>
6497 Name of the database to which this backend is connected.
6498 </para></entry>
6499 </row>
6501 <row>
6502 <entry role="catalog_table_entry"><para role="column_definition">
6503 <structfield>relid</structfield> <type>oid</type>
6504 </para>
6505 <para>
6506 OID of the table being clustered.
6507 </para></entry>
6508 </row>
6510 <row>
6511 <entry role="catalog_table_entry"><para role="column_definition">
6512 <structfield>command</structfield> <type>text</type>
6513 </para>
6514 <para>
6515 The command that is running. Either <literal>CLUSTER</literal> or <literal>VACUUM FULL</literal>.
6516 </para></entry>
6517 </row>
6519 <row>
6520 <entry role="catalog_table_entry"><para role="column_definition">
6521 <structfield>phase</structfield> <type>text</type>
6522 </para>
6523 <para>
6524 Current processing phase. See <xref linkend="cluster-phases"/>.
6525 </para></entry>
6526 </row>
6528 <row>
6529 <entry role="catalog_table_entry"><para role="column_definition">
6530 <structfield>cluster_index_relid</structfield> <type>oid</type>
6531 </para>
6532 <para>
6533 If the table is being scanned using an index, this is the OID of the
6534 index being used; otherwise, it is zero.
6535 </para></entry>
6536 </row>
6538 <row>
6539 <entry role="catalog_table_entry"><para role="column_definition">
6540 <structfield>heap_tuples_scanned</structfield> <type>bigint</type>
6541 </para>
6542 <para>
6543 Number of heap tuples scanned.
6544 This counter only advances when the phase is
6545 <literal>seq scanning heap</literal>,
6546 <literal>index scanning heap</literal>
6547 or <literal>writing new heap</literal>.
6548 </para></entry>
6549 </row>
6551 <row>
6552 <entry role="catalog_table_entry"><para role="column_definition">
6553 <structfield>heap_tuples_written</structfield> <type>bigint</type>
6554 </para>
6555 <para>
6556 Number of heap tuples written.
6557 This counter only advances when the phase is
6558 <literal>seq scanning heap</literal>,
6559 <literal>index scanning heap</literal>
6560 or <literal>writing new heap</literal>.
6561 </para></entry>
6562 </row>
6564 <row>
6565 <entry role="catalog_table_entry"><para role="column_definition">
6566 <structfield>heap_blks_total</structfield> <type>bigint</type>
6567 </para>
6568 <para>
6569 Total number of heap blocks in the table. This number is reported
6570 as of the beginning of <literal>seq scanning heap</literal>.
6571 </para></entry>
6572 </row>
6574 <row>
6575 <entry role="catalog_table_entry"><para role="column_definition">
6576 <structfield>heap_blks_scanned</structfield> <type>bigint</type>
6577 </para>
6578 <para>
6579 Number of heap blocks scanned. This counter only advances when the
6580 phase is <literal>seq scanning heap</literal>.
6581 </para></entry>
6582 </row>
6584 <row>
6585 <entry role="catalog_table_entry"><para role="column_definition">
6586 <structfield>index_rebuild_count</structfield> <type>bigint</type>
6587 </para>
6588 <para>
6589 Number of indexes rebuilt. This counter only advances when the phase
6590 is <literal>rebuilding index</literal>.
6591 </para></entry>
6592 </row>
6593 </tbody>
6594 </tgroup>
6595 </table>
6597 <table id="cluster-phases">
6598 <title>CLUSTER and VACUUM FULL Phases</title>
6599 <tgroup cols="2">
6600 <colspec colname="col1" colwidth="1*"/>
6601 <colspec colname="col2" colwidth="2*"/>
6602 <thead>
6603 <row>
6604 <entry>Phase</entry>
6605 <entry>Description</entry>
6606 </row>
6607 </thead>
6609 <tbody>
6610 <row>
6611 <entry><literal>initializing</literal></entry>
6612 <entry>
6613 The command is preparing to begin scanning the heap. This phase is
6614 expected to be very brief.
6615 </entry>
6616 </row>
6617 <row>
6618 <entry><literal>seq scanning heap</literal></entry>
6619 <entry>
6620 The command is currently scanning the table using a sequential scan.
6621 </entry>
6622 </row>
6623 <row>
6624 <entry><literal>index scanning heap</literal></entry>
6625 <entry>
6626 <command>CLUSTER</command> is currently scanning the table using an index scan.
6627 </entry>
6628 </row>
6629 <row>
6630 <entry><literal>sorting tuples</literal></entry>
6631 <entry>
6632 <command>CLUSTER</command> is currently sorting tuples.
6633 </entry>
6634 </row>
6635 <row>
6636 <entry><literal>writing new heap</literal></entry>
6637 <entry>
6638 <command>CLUSTER</command> is currently writing the new heap.
6639 </entry>
6640 </row>
6641 <row>
6642 <entry><literal>swapping relation files</literal></entry>
6643 <entry>
6644 The command is currently swapping newly-built files into place.
6645 </entry>
6646 </row>
6647 <row>
6648 <entry><literal>rebuilding index</literal></entry>
6649 <entry>
6650 The command is currently rebuilding an index.
6651 </entry>
6652 </row>
6653 <row>
6654 <entry><literal>performing final cleanup</literal></entry>
6655 <entry>
6656 The command is performing final cleanup. When this phase is
6657 completed, <command>CLUSTER</command>
6658 or <command>VACUUM FULL</command> will end.
6659 </entry>
6660 </row>
6661 </tbody>
6662 </tgroup>
6663 </table>
6664 </sect2>
6666 <sect2 id="copy-progress-reporting">
6667 <title>COPY Progress Reporting</title>
6669 <indexterm>
6670 <primary>pg_stat_progress_copy</primary>
6671 </indexterm>
6673 <para>
6674 Whenever <command>COPY</command> is running, the
6675 <structname>pg_stat_progress_copy</structname> view will contain one row
6676 for each backend that is currently running a <command>COPY</command> command.
6677 The table below describes the information that will be reported and provides
6678 information about how to interpret it.
6679 </para>
6681 <table id="pg-stat-progress-copy-view" xreflabel="pg_stat_progress_copy">
6682 <title><structname>pg_stat_progress_copy</structname> View</title>
6683 <tgroup cols="1">
6684 <thead>
6685 <row>
6686 <entry role="catalog_table_entry"><para role="column_definition">
6687 Column Type
6688 </para>
6689 <para>
6690 Description
6691 </para></entry>
6692 </row>
6693 </thead>
6695 <tbody>
6696 <row>
6697 <entry role="catalog_table_entry"><para role="column_definition">
6698 <structfield>pid</structfield> <type>integer</type>
6699 </para>
6700 <para>
6701 Process ID of backend.
6702 </para></entry>
6703 </row>
6705 <row>
6706 <entry role="catalog_table_entry"><para role="column_definition">
6707 <structfield>datid</structfield> <type>oid</type>
6708 </para>
6709 <para>
6710 OID of the database to which this backend is connected.
6711 </para></entry>
6712 </row>
6714 <row>
6715 <entry role="catalog_table_entry"><para role="column_definition">
6716 <structfield>datname</structfield> <type>name</type>
6717 </para>
6718 <para>
6719 Name of the database to which this backend is connected.
6720 </para></entry>
6721 </row>
6723 <row>
6724 <entry role="catalog_table_entry"><para role="column_definition">
6725 <structfield>relid</structfield> <type>oid</type>
6726 </para>
6727 <para>
6728 OID of the table on which the <command>COPY</command> command is
6729 executed. It is set to <literal>0</literal> if copying from a
6730 <command>SELECT</command> query.
6731 </para></entry>
6732 </row>
6734 <row>
6735 <entry role="catalog_table_entry"><para role="column_definition">
6736 <structfield>command</structfield> <type>text</type>
6737 </para>
6738 <para>
6739 The command that is running: <literal>COPY FROM</literal>, or
6740 <literal>COPY TO</literal>.
6741 </para></entry>
6742 </row>
6744 <row>
6745 <entry role="catalog_table_entry"><para role="column_definition">
6746 <structfield>type</structfield> <type>text</type>
6747 </para>
6748 <para>
6749 The io type that the data is read from or written to:
6750 <literal>FILE</literal>, <literal>PROGRAM</literal>,
6751 <literal>PIPE</literal> (for <command>COPY FROM STDIN</command> and
6752 <command>COPY TO STDOUT</command>), or <literal>CALLBACK</literal>
6753 (used for example during the initial table synchronization in
6754 logical replication).
6755 </para></entry>
6756 </row>
6758 <row>
6759 <entry role="catalog_table_entry"><para role="column_definition">
6760 <structfield>bytes_processed</structfield> <type>bigint</type>
6761 </para>
6762 <para>
6763 Number of bytes already processed by <command>COPY</command> command.
6764 </para></entry>
6765 </row>
6767 <row>
6768 <entry role="catalog_table_entry"><para role="column_definition">
6769 <structfield>bytes_total</structfield> <type>bigint</type>
6770 </para>
6771 <para>
6772 Size of source file for <command>COPY FROM</command> command in bytes.
6773 It is set to <literal>0</literal> if not available.
6774 </para></entry>
6775 </row>
6777 <row>
6778 <entry role="catalog_table_entry"><para role="column_definition">
6779 <structfield>tuples_processed</structfield> <type>bigint</type>
6780 </para>
6781 <para>
6782 Number of tuples already processed by <command>COPY</command> command.
6783 </para></entry>
6784 </row>
6786 <row>
6787 <entry role="catalog_table_entry"><para role="column_definition">
6788 <structfield>tuples_excluded</structfield> <type>bigint</type>
6789 </para>
6790 <para>
6791 Number of tuples not processed because they were excluded by the
6792 <command>WHERE</command> clause of the <command>COPY</command> command.
6793 </para></entry>
6794 </row>
6795 </tbody>
6796 </tgroup>
6797 </table>
6798 </sect2>
6800 <sect2 id="create-index-progress-reporting">
6801 <title>CREATE INDEX Progress Reporting</title>
6803 <indexterm>
6804 <primary>pg_stat_progress_create_index</primary>
6805 </indexterm>
6807 <para>
6808 Whenever <command>CREATE INDEX</command> or <command>REINDEX</command> is running, the
6809 <structname>pg_stat_progress_create_index</structname> view will contain
6810 one row for each backend that is currently creating indexes. The tables
6811 below describe the information that will be reported and provide information
6812 about how to interpret it.
6813 </para>
6815 <table id="pg-stat-progress-create-index-view" xreflabel="pg_stat_progress_create_index">
6816 <title><structname>pg_stat_progress_create_index</structname> View</title>
6817 <tgroup cols="1">
6818 <thead>
6819 <row>
6820 <entry role="catalog_table_entry"><para role="column_definition">
6821 Column Type
6822 </para>
6823 <para>
6824 Description
6825 </para></entry>
6826 </row>
6827 </thead>
6829 <tbody>
6830 <row>
6831 <entry role="catalog_table_entry"><para role="column_definition">
6832 <structfield>pid</structfield> <type>integer</type>
6833 </para>
6834 <para>
6835 Process ID of the backend creating indexes.
6836 </para></entry>
6837 </row>
6839 <row>
6840 <entry role="catalog_table_entry"><para role="column_definition">
6841 <structfield>datid</structfield> <type>oid</type>
6842 </para>
6843 <para>
6844 OID of the database to which this backend is connected.
6845 </para></entry>
6846 </row>
6848 <row>
6849 <entry role="catalog_table_entry"><para role="column_definition">
6850 <structfield>datname</structfield> <type>name</type>
6851 </para>
6852 <para>
6853 Name of the database to which this backend is connected.
6854 </para></entry>
6855 </row>
6857 <row>
6858 <entry role="catalog_table_entry"><para role="column_definition">
6859 <structfield>relid</structfield> <type>oid</type>
6860 </para>
6861 <para>
6862 OID of the table on which the index is being created.
6863 </para></entry>
6864 </row>
6866 <row>
6867 <entry role="catalog_table_entry"><para role="column_definition">
6868 <structfield>index_relid</structfield> <type>oid</type>
6869 </para>
6870 <para>
6871 OID of the index being created or reindexed. During a
6872 non-concurrent <command>CREATE INDEX</command>, this is 0.
6873 </para></entry>
6874 </row>
6876 <row>
6877 <entry role="catalog_table_entry"><para role="column_definition">
6878 <structfield>command</structfield> <type>text</type>
6879 </para>
6880 <para>
6881 Specific command type: <literal>CREATE INDEX</literal>,
6882 <literal>CREATE INDEX CONCURRENTLY</literal>,
6883 <literal>REINDEX</literal>, or <literal>REINDEX CONCURRENTLY</literal>.
6884 </para></entry>
6885 </row>
6887 <row>
6888 <entry role="catalog_table_entry"><para role="column_definition">
6889 <structfield>phase</structfield> <type>text</type>
6890 </para>
6891 <para>
6892 Current processing phase of index creation. See <xref linkend="create-index-phases"/>.
6893 </para></entry>
6894 </row>
6896 <row>
6897 <entry role="catalog_table_entry"><para role="column_definition">
6898 <structfield>lockers_total</structfield> <type>bigint</type>
6899 </para>
6900 <para>
6901 Total number of lockers to wait for, when applicable.
6902 </para></entry>
6903 </row>
6905 <row>
6906 <entry role="catalog_table_entry"><para role="column_definition">
6907 <structfield>lockers_done</structfield> <type>bigint</type>
6908 </para>
6909 <para>
6910 Number of lockers already waited for.
6911 </para></entry>
6912 </row>
6914 <row>
6915 <entry role="catalog_table_entry"><para role="column_definition">
6916 <structfield>current_locker_pid</structfield> <type>bigint</type>
6917 </para>
6918 <para>
6919 Process ID of the locker currently being waited for.
6920 </para></entry>
6921 </row>
6923 <row>
6924 <entry role="catalog_table_entry"><para role="column_definition">
6925 <structfield>blocks_total</structfield> <type>bigint</type>
6926 </para>
6927 <para>
6928 Total number of blocks to be processed in the current phase.
6929 </para></entry>
6930 </row>
6932 <row>
6933 <entry role="catalog_table_entry"><para role="column_definition">
6934 <structfield>blocks_done</structfield> <type>bigint</type>
6935 </para>
6936 <para>
6937 Number of blocks already processed in the current phase.
6938 </para></entry>
6939 </row>
6941 <row>
6942 <entry role="catalog_table_entry"><para role="column_definition">
6943 <structfield>tuples_total</structfield> <type>bigint</type>
6944 </para>
6945 <para>
6946 Total number of tuples to be processed in the current phase.
6947 </para></entry>
6948 </row>
6950 <row>
6951 <entry role="catalog_table_entry"><para role="column_definition">
6952 <structfield>tuples_done</structfield> <type>bigint</type>
6953 </para>
6954 <para>
6955 Number of tuples already processed in the current phase.
6956 </para></entry>
6957 </row>
6959 <row>
6960 <entry role="catalog_table_entry"><para role="column_definition">
6961 <structfield>partitions_total</structfield> <type>bigint</type>
6962 </para>
6963 <para>
6964 Total number of partitions on which the index is to be created
6965 or attached, including both direct and indirect partitions.
6966 <literal>0</literal> during a <literal>REINDEX</literal>, or when
6967 the index is not partitioned.
6968 </para></entry>
6969 </row>
6971 <row>
6972 <entry role="catalog_table_entry"><para role="column_definition">
6973 <structfield>partitions_done</structfield> <type>bigint</type>
6974 </para>
6975 <para>
6976 Number of partitions on which the index has already been created
6977 or attached, including both direct and indirect partitions.
6978 <literal>0</literal> during a <literal>REINDEX</literal>, or when
6979 the index is not partitioned.
6980 </para></entry>
6981 </row>
6982 </tbody>
6983 </tgroup>
6984 </table>
6986 <table id="create-index-phases">
6987 <title>CREATE INDEX Phases</title>
6988 <tgroup cols="2">
6989 <colspec colname="col1" colwidth="1*"/>
6990 <colspec colname="col2" colwidth="2*"/>
6991 <thead>
6992 <row>
6993 <entry>Phase</entry>
6994 <entry>Description</entry>
6995 </row>
6996 </thead>
6997 <tbody>
6998 <row>
6999 <entry><literal>initializing</literal></entry>
7000 <entry>
7001 <command>CREATE INDEX</command> or <command>REINDEX</command> is preparing to create the index. This
7002 phase is expected to be very brief.
7003 </entry>
7004 </row>
7005 <row>
7006 <entry><literal>waiting for writers before build</literal></entry>
7007 <entry>
7008 <command>CREATE INDEX CONCURRENTLY</command> or <command>REINDEX CONCURRENTLY</command> is waiting for transactions
7009 with write locks that can potentially see the table to finish.
7010 This phase is skipped when not in concurrent mode.
7011 Columns <structname>lockers_total</structname>, <structname>lockers_done</structname>
7012 and <structname>current_locker_pid</structname> contain the progress
7013 information for this phase.
7014 </entry>
7015 </row>
7016 <row>
7017 <entry><literal>building index</literal></entry>
7018 <entry>
7019 The index is being built by the access method-specific code. In this phase,
7020 access methods that support progress reporting fill in their own progress data,
7021 and the subphase is indicated in this column. Typically,
7022 <structname>blocks_total</structname> and <structname>blocks_done</structname>
7023 will contain progress data, as well as potentially
7024 <structname>tuples_total</structname> and <structname>tuples_done</structname>.
7025 </entry>
7026 </row>
7027 <row>
7028 <entry><literal>waiting for writers before validation</literal></entry>
7029 <entry>
7030 <command>CREATE INDEX CONCURRENTLY</command> or <command>REINDEX CONCURRENTLY</command> is waiting for transactions
7031 with write locks that can potentially write into the table to finish.
7032 This phase is skipped when not in concurrent mode.
7033 Columns <structname>lockers_total</structname>, <structname>lockers_done</structname>
7034 and <structname>current_locker_pid</structname> contain the progress
7035 information for this phase.
7036 </entry>
7037 </row>
7038 <row>
7039 <entry><literal>index validation: scanning index</literal></entry>
7040 <entry>
7041 <command>CREATE INDEX CONCURRENTLY</command> is scanning the index searching
7042 for tuples that need to be validated.
7043 This phase is skipped when not in concurrent mode.
7044 Columns <structname>blocks_total</structname> (set to the total size of the index)
7045 and <structname>blocks_done</structname> contain the progress information for this phase.
7046 </entry>
7047 </row>
7048 <row>
7049 <entry><literal>index validation: sorting tuples</literal></entry>
7050 <entry>
7051 <command>CREATE INDEX CONCURRENTLY</command> is sorting the output of the
7052 index scanning phase.
7053 </entry>
7054 </row>
7055 <row>
7056 <entry><literal>index validation: scanning table</literal></entry>
7057 <entry>
7058 <command>CREATE INDEX CONCURRENTLY</command> is scanning the table
7059 to validate the index tuples collected in the previous two phases.
7060 This phase is skipped when not in concurrent mode.
7061 Columns <structname>blocks_total</structname> (set to the total size of the table)
7062 and <structname>blocks_done</structname> contain the progress information for this phase.
7063 </entry>
7064 </row>
7065 <row>
7066 <entry><literal>waiting for old snapshots</literal></entry>
7067 <entry>
7068 <command>CREATE INDEX CONCURRENTLY</command> or <command>REINDEX CONCURRENTLY</command> is waiting for transactions
7069 that can potentially see the table to release their snapshots. This
7070 phase is skipped when not in concurrent mode.
7071 Columns <structname>lockers_total</structname>, <structname>lockers_done</structname>
7072 and <structname>current_locker_pid</structname> contain the progress
7073 information for this phase.
7074 </entry>
7075 </row>
7076 <row>
7077 <entry><literal>waiting for readers before marking dead</literal></entry>
7078 <entry>
7079 <command>REINDEX CONCURRENTLY</command> is waiting for transactions
7080 with read locks on the table to finish, before marking the old index dead.
7081 This phase is skipped when not in concurrent mode.
7082 Columns <structname>lockers_total</structname>, <structname>lockers_done</structname>
7083 and <structname>current_locker_pid</structname> contain the progress
7084 information for this phase.
7085 </entry>
7086 </row>
7087 <row>
7088 <entry><literal>waiting for readers before dropping</literal></entry>
7089 <entry>
7090 <command>REINDEX CONCURRENTLY</command> is waiting for transactions
7091 with read locks on the table to finish, before dropping the old index.
7092 This phase is skipped when not in concurrent mode.
7093 Columns <structname>lockers_total</structname>, <structname>lockers_done</structname>
7094 and <structname>current_locker_pid</structname> contain the progress
7095 information for this phase.
7096 </entry>
7097 </row>
7098 </tbody>
7099 </tgroup>
7100 </table>
7102 </sect2>
7104 <sect2 id="vacuum-progress-reporting">
7105 <title>VACUUM Progress Reporting</title>
7107 <indexterm>
7108 <primary>pg_stat_progress_vacuum</primary>
7109 </indexterm>
7111 <para>
7112 Whenever <command>VACUUM</command> is running, the
7113 <structname>pg_stat_progress_vacuum</structname> view will contain
7114 one row for each backend (including autovacuum worker processes) that is
7115 currently vacuuming. The tables below describe the information
7116 that will be reported and provide information about how to interpret it.
7117 Progress for <command>VACUUM FULL</command> commands is reported via
7118 <structname>pg_stat_progress_cluster</structname>
7119 because both <command>VACUUM FULL</command> and <command>CLUSTER</command>
7120 rewrite the table, while regular <command>VACUUM</command> only modifies it
7121 in place. See <xref linkend="cluster-progress-reporting"/>.
7122 </para>
7124 <table id="pg-stat-progress-vacuum-view" xreflabel="pg_stat_progress_vacuum">
7125 <title><structname>pg_stat_progress_vacuum</structname> View</title>
7126 <tgroup cols="1">
7127 <thead>
7128 <row>
7129 <entry role="catalog_table_entry"><para role="column_definition">
7130 Column Type
7131 </para>
7132 <para>
7133 Description
7134 </para></entry>
7135 </row>
7136 </thead>
7138 <tbody>
7139 <row>
7140 <entry role="catalog_table_entry"><para role="column_definition">
7141 <structfield>pid</structfield> <type>integer</type>
7142 </para>
7143 <para>
7144 Process ID of backend.
7145 </para></entry>
7146 </row>
7148 <row>
7149 <entry role="catalog_table_entry"><para role="column_definition">
7150 <structfield>datid</structfield> <type>oid</type>
7151 </para>
7152 <para>
7153 OID of the database to which this backend is connected.
7154 </para></entry>
7155 </row>
7157 <row>
7158 <entry role="catalog_table_entry"><para role="column_definition">
7159 <structfield>datname</structfield> <type>name</type>
7160 </para>
7161 <para>
7162 Name of the database to which this backend is connected.
7163 </para></entry>
7164 </row>
7166 <row>
7167 <entry role="catalog_table_entry"><para role="column_definition">
7168 <structfield>relid</structfield> <type>oid</type>
7169 </para>
7170 <para>
7171 OID of the table being vacuumed.
7172 </para></entry>
7173 </row>
7175 <row>
7176 <entry role="catalog_table_entry"><para role="column_definition">
7177 <structfield>phase</structfield> <type>text</type>
7178 </para>
7179 <para>
7180 Current processing phase of vacuum. See <xref linkend="vacuum-phases"/>.
7181 </para></entry>
7182 </row>
7184 <row>
7185 <entry role="catalog_table_entry"><para role="column_definition">
7186 <structfield>heap_blks_total</structfield> <type>bigint</type>
7187 </para>
7188 <para>
7189 Total number of heap blocks in the table. This number is reported
7190 as of the beginning of the scan; blocks added later will not be (and
7191 need not be) visited by this <command>VACUUM</command>.
7192 </para></entry>
7193 </row>
7195 <row>
7196 <entry role="catalog_table_entry"><para role="column_definition">
7197 <structfield>heap_blks_scanned</structfield> <type>bigint</type>
7198 </para>
7199 <para>
7200 Number of heap blocks scanned. Because the
7201 <link linkend="storage-vm">visibility map</link> is used to optimize scans,
7202 some blocks will be skipped without inspection; skipped blocks are
7203 included in this total, so that this number will eventually become
7204 equal to <structfield>heap_blks_total</structfield> when the vacuum is complete.
7205 This counter only advances when the phase is <literal>scanning heap</literal>.
7206 </para></entry>
7207 </row>
7209 <row>
7210 <entry role="catalog_table_entry"><para role="column_definition">
7211 <structfield>heap_blks_vacuumed</structfield> <type>bigint</type>
7212 </para>
7213 <para>
7214 Number of heap blocks vacuumed. Unless the table has no indexes, this
7215 counter only advances when the phase is <literal>vacuuming heap</literal>.
7216 Blocks that contain no dead tuples are skipped, so the counter may
7217 sometimes skip forward in large increments.
7218 </para></entry>
7219 </row>
7221 <row>
7222 <entry role="catalog_table_entry"><para role="column_definition">
7223 <structfield>index_vacuum_count</structfield> <type>bigint</type>
7224 </para>
7225 <para>
7226 Number of completed index vacuum cycles.
7227 </para></entry>
7228 </row>
7230 <row>
7231 <entry role="catalog_table_entry"><para role="column_definition">
7232 <structfield>max_dead_tuples</structfield> <type>bigint</type>
7233 </para>
7234 <para>
7235 Number of dead tuples that we can store before needing to perform
7236 an index vacuum cycle, based on
7237 <xref linkend="guc-maintenance-work-mem"/>.
7238 </para></entry>
7239 </row>
7241 <row>
7242 <entry role="catalog_table_entry"><para role="column_definition">
7243 <structfield>num_dead_tuples</structfield> <type>bigint</type>
7244 </para>
7245 <para>
7246 Number of dead tuples collected since the last index vacuum cycle.
7247 </para></entry>
7248 </row>
7249 </tbody>
7250 </tgroup>
7251 </table>
7253 <table id="vacuum-phases">
7254 <title>VACUUM Phases</title>
7255 <tgroup cols="2">
7256 <colspec colname="col1" colwidth="1*"/>
7257 <colspec colname="col2" colwidth="2*"/>
7258 <thead>
7259 <row>
7260 <entry>Phase</entry>
7261 <entry>Description</entry>
7262 </row>
7263 </thead>
7265 <tbody>
7266 <row>
7267 <entry><literal>initializing</literal></entry>
7268 <entry>
7269 <command>VACUUM</command> is preparing to begin scanning the heap. This
7270 phase is expected to be very brief.
7271 </entry>
7272 </row>
7273 <row>
7274 <entry><literal>scanning heap</literal></entry>
7275 <entry>
7276 <command>VACUUM</command> is currently scanning the heap. It will prune and
7277 defragment each page if required, and possibly perform freezing
7278 activity. The <structfield>heap_blks_scanned</structfield> column can be used
7279 to monitor the progress of the scan.
7280 </entry>
7281 </row>
7282 <row>
7283 <entry><literal>vacuuming indexes</literal></entry>
7284 <entry>
7285 <command>VACUUM</command> is currently vacuuming the indexes. If a table has
7286 any indexes, this will happen at least once per vacuum, after the heap
7287 has been completely scanned. It may happen multiple times per vacuum
7288 if <xref linkend="guc-maintenance-work-mem"/> (or, in the case of autovacuum,
7289 <xref linkend="guc-autovacuum-work-mem"/> if set) is insufficient to store
7290 the number of dead tuples found.
7291 </entry>
7292 </row>
7293 <row>
7294 <entry><literal>vacuuming heap</literal></entry>
7295 <entry>
7296 <command>VACUUM</command> is currently vacuuming the heap. Vacuuming the heap
7297 is distinct from scanning the heap, and occurs after each instance of
7298 vacuuming indexes. If <structfield>heap_blks_scanned</structfield> is less than
7299 <structfield>heap_blks_total</structfield>, the system will return to scanning
7300 the heap after this phase is completed; otherwise, it will begin
7301 cleaning up indexes after this phase is completed.
7302 </entry>
7303 </row>
7304 <row>
7305 <entry><literal>cleaning up indexes</literal></entry>
7306 <entry>
7307 <command>VACUUM</command> is currently cleaning up indexes. This occurs after
7308 the heap has been completely scanned and all vacuuming of the indexes
7309 and the heap has been completed.
7310 </entry>
7311 </row>
7312 <row>
7313 <entry><literal>truncating heap</literal></entry>
7314 <entry>
7315 <command>VACUUM</command> is currently truncating the heap so as to return
7316 empty pages at the end of the relation to the operating system. This
7317 occurs after cleaning up indexes.
7318 </entry>
7319 </row>
7320 <row>
7321 <entry><literal>performing final cleanup</literal></entry>
7322 <entry>
7323 <command>VACUUM</command> is performing final cleanup. During this phase,
7324 <command>VACUUM</command> will vacuum the free space map, update statistics
7325 in <literal>pg_class</literal>, and report statistics to the cumulative
7326 statistics system. When this phase is completed, <command>VACUUM</command> will end.
7327 </entry>
7328 </row>
7329 </tbody>
7330 </tgroup>
7331 </table>
7332 </sect2>
7334 <sect2 id="basebackup-progress-reporting">
7335 <title>Base Backup Progress Reporting</title>
7337 <indexterm>
7338 <primary>pg_stat_progress_basebackup</primary>
7339 </indexterm>
7341 <para>
7342 Whenever an application like <application>pg_basebackup</application>
7343 is taking a base backup, the
7344 <structname>pg_stat_progress_basebackup</structname>
7345 view will contain a row for each WAL sender process that is currently
7346 running the <command>BASE_BACKUP</command> replication command
7347 and streaming the backup. The tables below describe the information
7348 that will be reported and provide information about how to interpret it.
7349 </para>
7351 <table id="pg-stat-progress-basebackup-view" xreflabel="pg_stat_progress_basebackup">
7352 <title><structname>pg_stat_progress_basebackup</structname> View</title>
7353 <tgroup cols="1">
7354 <thead>
7355 <row>
7356 <entry role="catalog_table_entry"><para role="column_definition">
7357 Column Type
7358 </para>
7359 <para>
7360 Description
7361 </para></entry>
7362 </row>
7363 </thead>
7365 <tbody>
7366 <row>
7367 <entry role="catalog_table_entry"><para role="column_definition">
7368 <structfield>pid</structfield> <type>integer</type>
7369 </para>
7370 <para>
7371 Process ID of a WAL sender process.
7372 </para></entry>
7373 </row>
7375 <row>
7376 <entry role="catalog_table_entry"><para role="column_definition">
7377 <structfield>phase</structfield> <type>text</type>
7378 </para>
7379 <para>
7380 Current processing phase. See <xref linkend="basebackup-phases"/>.
7381 </para></entry>
7382 </row>
7384 <row>
7385 <entry role="catalog_table_entry"><para role="column_definition">
7386 <structfield>backup_total</structfield> <type>bigint</type>
7387 </para>
7388 <para>
7389 Total amount of data that will be streamed. This is estimated and
7390 reported as of the beginning of
7391 <literal>streaming database files</literal> phase. Note that
7392 this is only an approximation since the database
7393 may change during <literal>streaming database files</literal> phase
7394 and WAL log may be included in the backup later. This is always
7395 the same value as <structfield>backup_streamed</structfield>
7396 once the amount of data streamed exceeds the estimated
7397 total size. If the estimation is disabled in
7398 <application>pg_basebackup</application>
7399 (i.e., <literal>--no-estimate-size</literal> option is specified),
7400 this is <literal>NULL</literal>.
7401 </para></entry>
7402 </row>
7404 <row>
7405 <entry role="catalog_table_entry"><para role="column_definition">
7406 <structfield>backup_streamed</structfield> <type>bigint</type>
7407 </para>
7408 <para>
7409 Amount of data streamed. This counter only advances
7410 when the phase is <literal>streaming database files</literal> or
7411 <literal>transferring wal files</literal>.
7412 </para></entry>
7413 </row>
7415 <row>
7416 <entry role="catalog_table_entry"><para role="column_definition">
7417 <structfield>tablespaces_total</structfield> <type>bigint</type>
7418 </para>
7419 <para>
7420 Total number of tablespaces that will be streamed.
7421 </para></entry>
7422 </row>
7424 <row>
7425 <entry role="catalog_table_entry"><para role="column_definition">
7426 <structfield>tablespaces_streamed</structfield> <type>bigint</type>
7427 </para>
7428 <para>
7429 Number of tablespaces streamed. This counter only
7430 advances when the phase is <literal>streaming database files</literal>.
7431 </para></entry>
7432 </row>
7433 </tbody>
7434 </tgroup>
7435 </table>
7437 <table id="basebackup-phases">
7438 <title>Base Backup Phases</title>
7439 <tgroup cols="2">
7440 <colspec colname="col1" colwidth="1*"/>
7441 <colspec colname="col2" colwidth="2*"/>
7442 <thead>
7443 <row>
7444 <entry>Phase</entry>
7445 <entry>Description</entry>
7446 </row>
7447 </thead>
7448 <tbody>
7449 <row>
7450 <entry><literal>initializing</literal></entry>
7451 <entry>
7452 The WAL sender process is preparing to begin the backup.
7453 This phase is expected to be very brief.
7454 </entry>
7455 </row>
7456 <row>
7457 <entry><literal>waiting for checkpoint to finish</literal></entry>
7458 <entry>
7459 The WAL sender process is currently performing
7460 <function>pg_backup_start</function> to prepare to
7461 take a base backup, and waiting for the start-of-backup
7462 checkpoint to finish.
7463 </entry>
7464 </row>
7465 <row>
7466 <entry><literal>estimating backup size</literal></entry>
7467 <entry>
7468 The WAL sender process is currently estimating the total amount
7469 of database files that will be streamed as a base backup.
7470 </entry>
7471 </row>
7472 <row>
7473 <entry><literal>streaming database files</literal></entry>
7474 <entry>
7475 The WAL sender process is currently streaming database files
7476 as a base backup.
7477 </entry>
7478 </row>
7479 <row>
7480 <entry><literal>waiting for wal archiving to finish</literal></entry>
7481 <entry>
7482 The WAL sender process is currently performing
7483 <function>pg_backup_stop</function> to finish the backup,
7484 and waiting for all the WAL files required for the base backup
7485 to be successfully archived.
7486 If either <literal>--wal-method=none</literal> or
7487 <literal>--wal-method=stream</literal> is specified in
7488 <application>pg_basebackup</application>, the backup will end
7489 when this phase is completed.
7490 </entry>
7491 </row>
7492 <row>
7493 <entry><literal>transferring wal files</literal></entry>
7494 <entry>
7495 The WAL sender process is currently transferring all WAL logs
7496 generated during the backup. This phase occurs after
7497 <literal>waiting for wal archiving to finish</literal> phase if
7498 <literal>--wal-method=fetch</literal> is specified in
7499 <application>pg_basebackup</application>. The backup will end
7500 when this phase is completed.
7501 </entry>
7502 </row>
7503 </tbody>
7504 </tgroup>
7505 </table>
7507 </sect2>
7509 </sect1>
7511 <sect1 id="dynamic-trace">
7512 <title>Dynamic Tracing</title>
7514 <indexterm zone="dynamic-trace">
7515 <primary>DTrace</primary>
7516 </indexterm>
7518 <para>
7519 <productname>PostgreSQL</productname> provides facilities to support
7520 dynamic tracing of the database server. This allows an external
7521 utility to be called at specific points in the code and thereby trace
7522 execution.
7523 </para>
7525 <para>
7526 A number of probes or trace points are already inserted into the source
7527 code. These probes are intended to be used by database developers and
7528 administrators. By default the probes are not compiled into
7529 <productname>PostgreSQL</productname>; the user needs to explicitly tell
7530 the configure script to make the probes available.
7531 </para>
7533 <para>
7534 Currently, the
7535 <ulink url="https://en.wikipedia.org/wiki/DTrace">DTrace</ulink>
7536 utility is supported, which, at the time of this writing, is available
7537 on Solaris, macOS, FreeBSD, NetBSD, and Oracle Linux. The
7538 <ulink url="https://sourceware.org/systemtap/">SystemTap</ulink> project
7539 for Linux provides a DTrace equivalent and can also be used. Supporting other dynamic
7540 tracing utilities is theoretically possible by changing the definitions for
7541 the macros in <filename>src/include/utils/probes.h</filename>.
7542 </para>
7544 <sect2 id="compiling-for-trace">
7545 <title>Compiling for Dynamic Tracing</title>
7547 <para>
7548 By default, probes are not available, so you will need to
7549 explicitly tell the configure script to make the probes available
7550 in <productname>PostgreSQL</productname>. To include DTrace support
7551 specify <option>--enable-dtrace</option> to configure. See <xref
7552 linkend="configure-options-devel"/> for further information.
7553 </para>
7554 </sect2>
7556 <sect2 id="trace-points">
7557 <title>Built-in Probes</title>
7559 <para>
7560 A number of standard probes are provided in the source code,
7561 as shown in <xref linkend="dtrace-probe-point-table"/>;
7562 <xref linkend="typedefs-table"/>
7563 shows the types used in the probes. More probes can certainly be
7564 added to enhance <productname>PostgreSQL</productname>'s observability.
7565 </para>
7567 <table id="dtrace-probe-point-table">
7568 <title>Built-in DTrace Probes</title>
7569 <tgroup cols="3">
7570 <colspec colname="col1" colwidth="2*"/>
7571 <colspec colname="col2" colwidth="3*"/>
7572 <colspec colname="col3" colwidth="3*"/>
7573 <thead>
7574 <row>
7575 <entry>Name</entry>
7576 <entry>Parameters</entry>
7577 <entry>Description</entry>
7578 </row>
7579 </thead>
7581 <tbody>
7583 <row>
7584 <entry><literal>transaction-start</literal></entry>
7585 <entry><literal>(LocalTransactionId)</literal></entry>
7586 <entry>Probe that fires at the start of a new transaction.
7587 arg0 is the transaction ID.</entry>
7588 </row>
7589 <row>
7590 <entry><literal>transaction-commit</literal></entry>
7591 <entry><literal>(LocalTransactionId)</literal></entry>
7592 <entry>Probe that fires when a transaction completes successfully.
7593 arg0 is the transaction ID.</entry>
7594 </row>
7595 <row>
7596 <entry><literal>transaction-abort</literal></entry>
7597 <entry><literal>(LocalTransactionId)</literal></entry>
7598 <entry>Probe that fires when a transaction completes unsuccessfully.
7599 arg0 is the transaction ID.</entry>
7600 </row>
7601 <row>
7602 <entry><literal>query-start</literal></entry>
7603 <entry><literal>(const char *)</literal></entry>
7604 <entry>Probe that fires when the processing of a query is started.
7605 arg0 is the query string.</entry>
7606 </row>
7607 <row>
7608 <entry><literal>query-done</literal></entry>
7609 <entry><literal>(const char *)</literal></entry>
7610 <entry>Probe that fires when the processing of a query is complete.
7611 arg0 is the query string.</entry>
7612 </row>
7613 <row>
7614 <entry><literal>query-parse-start</literal></entry>
7615 <entry><literal>(const char *)</literal></entry>
7616 <entry>Probe that fires when the parsing of a query is started.
7617 arg0 is the query string.</entry>
7618 </row>
7619 <row>
7620 <entry><literal>query-parse-done</literal></entry>
7621 <entry><literal>(const char *)</literal></entry>
7622 <entry>Probe that fires when the parsing of a query is complete.
7623 arg0 is the query string.</entry>
7624 </row>
7625 <row>
7626 <entry><literal>query-rewrite-start</literal></entry>
7627 <entry><literal>(const char *)</literal></entry>
7628 <entry>Probe that fires when the rewriting of a query is started.
7629 arg0 is the query string.</entry>
7630 </row>
7631 <row>
7632 <entry><literal>query-rewrite-done</literal></entry>
7633 <entry><literal>(const char *)</literal></entry>
7634 <entry>Probe that fires when the rewriting of a query is complete.
7635 arg0 is the query string.</entry>
7636 </row>
7637 <row>
7638 <entry><literal>query-plan-start</literal></entry>
7639 <entry><literal>()</literal></entry>
7640 <entry>Probe that fires when the planning of a query is started.</entry>
7641 </row>
7642 <row>
7643 <entry><literal>query-plan-done</literal></entry>
7644 <entry><literal>()</literal></entry>
7645 <entry>Probe that fires when the planning of a query is complete.</entry>
7646 </row>
7647 <row>
7648 <entry><literal>query-execute-start</literal></entry>
7649 <entry><literal>()</literal></entry>
7650 <entry>Probe that fires when the execution of a query is started.</entry>
7651 </row>
7652 <row>
7653 <entry><literal>query-execute-done</literal></entry>
7654 <entry><literal>()</literal></entry>
7655 <entry>Probe that fires when the execution of a query is complete.</entry>
7656 </row>
7657 <row>
7658 <entry><literal>statement-status</literal></entry>
7659 <entry><literal>(const char *)</literal></entry>
7660 <entry>Probe that fires anytime the server process updates its
7661 <structname>pg_stat_activity</structname>.<structfield>status</structfield>.
7662 arg0 is the new status string.</entry>
7663 </row>
7664 <row>
7665 <entry><literal>checkpoint-start</literal></entry>
7666 <entry><literal>(int)</literal></entry>
7667 <entry>Probe that fires when a checkpoint is started.
7668 arg0 holds the bitwise flags used to distinguish different checkpoint
7669 types, such as shutdown, immediate or force.</entry>
7670 </row>
7671 <row>
7672 <entry><literal>checkpoint-done</literal></entry>
7673 <entry><literal>(int, int, int, int, int)</literal></entry>
7674 <entry>Probe that fires when a checkpoint is complete.
7675 (The probes listed next fire in sequence during checkpoint processing.)
7676 arg0 is the number of buffers written. arg1 is the total number of
7677 buffers. arg2, arg3 and arg4 contain the number of WAL files added,
7678 removed and recycled respectively.</entry>
7679 </row>
7680 <row>
7681 <entry><literal>clog-checkpoint-start</literal></entry>
7682 <entry><literal>(bool)</literal></entry>
7683 <entry>Probe that fires when the CLOG portion of a checkpoint is started.
7684 arg0 is true for normal checkpoint, false for shutdown
7685 checkpoint.</entry>
7686 </row>
7687 <row>
7688 <entry><literal>clog-checkpoint-done</literal></entry>
7689 <entry><literal>(bool)</literal></entry>
7690 <entry>Probe that fires when the CLOG portion of a checkpoint is
7691 complete. arg0 has the same meaning as for <literal>clog-checkpoint-start</literal>.</entry>
7692 </row>
7693 <row>
7694 <entry><literal>subtrans-checkpoint-start</literal></entry>
7695 <entry><literal>(bool)</literal></entry>
7696 <entry>Probe that fires when the SUBTRANS portion of a checkpoint is
7697 started.
7698 arg0 is true for normal checkpoint, false for shutdown
7699 checkpoint.</entry>
7700 </row>
7701 <row>
7702 <entry><literal>subtrans-checkpoint-done</literal></entry>
7703 <entry><literal>(bool)</literal></entry>
7704 <entry>Probe that fires when the SUBTRANS portion of a checkpoint is
7705 complete. arg0 has the same meaning as for
7706 <literal>subtrans-checkpoint-start</literal>.</entry>
7707 </row>
7708 <row>
7709 <entry><literal>multixact-checkpoint-start</literal></entry>
7710 <entry><literal>(bool)</literal></entry>
7711 <entry>Probe that fires when the MultiXact portion of a checkpoint is
7712 started.
7713 arg0 is true for normal checkpoint, false for shutdown
7714 checkpoint.</entry>
7715 </row>
7716 <row>
7717 <entry><literal>multixact-checkpoint-done</literal></entry>
7718 <entry><literal>(bool)</literal></entry>
7719 <entry>Probe that fires when the MultiXact portion of a checkpoint is
7720 complete. arg0 has the same meaning as for
7721 <literal>multixact-checkpoint-start</literal>.</entry>
7722 </row>
7723 <row>
7724 <entry><literal>buffer-checkpoint-start</literal></entry>
7725 <entry><literal>(int)</literal></entry>
7726 <entry>Probe that fires when the buffer-writing portion of a checkpoint
7727 is started.
7728 arg0 holds the bitwise flags used to distinguish different checkpoint
7729 types, such as shutdown, immediate or force.</entry>
7730 </row>
7731 <row>
7732 <entry><literal>buffer-sync-start</literal></entry>
7733 <entry><literal>(int, int)</literal></entry>
7734 <entry>Probe that fires when we begin to write dirty buffers during
7735 checkpoint (after identifying which buffers must be written).
7736 arg0 is the total number of buffers.
7737 arg1 is the number that are currently dirty and need to be written.</entry>
7738 </row>
7739 <row>
7740 <entry><literal>buffer-sync-written</literal></entry>
7741 <entry><literal>(int)</literal></entry>
7742 <entry>Probe that fires after each buffer is written during checkpoint.
7743 arg0 is the ID number of the buffer.</entry>
7744 </row>
7745 <row>
7746 <entry><literal>buffer-sync-done</literal></entry>
7747 <entry><literal>(int, int, int)</literal></entry>
7748 <entry>Probe that fires when all dirty buffers have been written.
7749 arg0 is the total number of buffers.
7750 arg1 is the number of buffers actually written by the checkpoint process.
7751 arg2 is the number that were expected to be written (arg1 of
7752 <literal>buffer-sync-start</literal>); any difference reflects other processes flushing
7753 buffers during the checkpoint.</entry>
7754 </row>
7755 <row>
7756 <entry><literal>buffer-checkpoint-sync-start</literal></entry>
7757 <entry><literal>()</literal></entry>
7758 <entry>Probe that fires after dirty buffers have been written to the
7759 kernel, and before starting to issue fsync requests.</entry>
7760 </row>
7761 <row>
7762 <entry><literal>buffer-checkpoint-done</literal></entry>
7763 <entry><literal>()</literal></entry>
7764 <entry>Probe that fires when syncing of buffers to disk is
7765 complete.</entry>
7766 </row>
7767 <row>
7768 <entry><literal>twophase-checkpoint-start</literal></entry>
7769 <entry><literal>()</literal></entry>
7770 <entry>Probe that fires when the two-phase portion of a checkpoint is
7771 started.</entry>
7772 </row>
7773 <row>
7774 <entry><literal>twophase-checkpoint-done</literal></entry>
7775 <entry><literal>()</literal></entry>
7776 <entry>Probe that fires when the two-phase portion of a checkpoint is
7777 complete.</entry>
7778 </row>
7779 <row>
7780 <entry><literal>buffer-read-start</literal></entry>
7781 <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int, bool)</literal></entry>
7782 <entry>Probe that fires when a buffer read is started.
7783 arg0 and arg1 contain the fork and block numbers of the page (but
7784 arg1 will be -1 if this is a relation extension request).
7785 arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
7786 identifying the relation.
7787 arg5 is the ID of the backend which created the temporary relation for a
7788 local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.
7789 arg6 is true for a relation extension request, false for normal
7790 read.</entry>
7791 </row>
7792 <row>
7793 <entry><literal>buffer-read-done</literal></entry>
7794 <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int, bool, bool)</literal></entry>
7795 <entry>Probe that fires when a buffer read is complete.
7796 arg0 and arg1 contain the fork and block numbers of the page (if this
7797 is a relation extension request, arg1 now contains the block number
7798 of the newly added block).
7799 arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
7800 identifying the relation.
7801 arg5 is the ID of the backend which created the temporary relation for a
7802 local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.
7803 arg6 is true for a relation extension request, false for normal
7804 read.
7805 arg7 is true if the buffer was found in the pool, false if not.</entry>
7806 </row>
7807 <row>
7808 <entry><literal>buffer-flush-start</literal></entry>
7809 <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid)</literal></entry>
7810 <entry>Probe that fires before issuing any write request for a shared
7811 buffer.
7812 arg0 and arg1 contain the fork and block numbers of the page.
7813 arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
7814 identifying the relation.</entry>
7815 </row>
7816 <row>
7817 <entry><literal>buffer-flush-done</literal></entry>
7818 <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid)</literal></entry>
7819 <entry>Probe that fires when a write request is complete. (Note
7820 that this just reflects the time to pass the data to the kernel;
7821 it's typically not actually been written to disk yet.)
7822 The arguments are the same as for <literal>buffer-flush-start</literal>.</entry>
7823 </row>
7824 <row>
7825 <entry><literal>wal-buffer-write-dirty-start</literal></entry>
7826 <entry><literal>()</literal></entry>
7827 <entry>Probe that fires when a server process begins to write a
7828 dirty WAL buffer because no more WAL buffer space is available.
7829 (If this happens often, it implies that
7830 <xref linkend="guc-wal-buffers"/> is too small.)</entry>
7831 </row>
7832 <row>
7833 <entry><literal>wal-buffer-write-dirty-done</literal></entry>
7834 <entry><literal>()</literal></entry>
7835 <entry>Probe that fires when a dirty WAL buffer write is complete.</entry>
7836 </row>
7837 <row>
7838 <entry><literal>wal-insert</literal></entry>
7839 <entry><literal>(unsigned char, unsigned char)</literal></entry>
7840 <entry>Probe that fires when a WAL record is inserted.
7841 arg0 is the resource manager (rmid) for the record.
7842 arg1 contains the info flags.</entry>
7843 </row>
7844 <row>
7845 <entry><literal>wal-switch</literal></entry>
7846 <entry><literal>()</literal></entry>
7847 <entry>Probe that fires when a WAL segment switch is requested.</entry>
7848 </row>
7849 <row>
7850 <entry><literal>smgr-md-read-start</literal></entry>
7851 <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int)</literal></entry>
7852 <entry>Probe that fires when beginning to read a block from a relation.
7853 arg0 and arg1 contain the fork and block numbers of the page.
7854 arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
7855 identifying the relation.
7856 arg5 is the ID of the backend which created the temporary relation for a
7857 local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.</entry>
7858 </row>
7859 <row>
7860 <entry><literal>smgr-md-read-done</literal></entry>
7861 <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int, int)</literal></entry>
7862 <entry>Probe that fires when a block read is complete.
7863 arg0 and arg1 contain the fork and block numbers of the page.
7864 arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
7865 identifying the relation.
7866 arg5 is the ID of the backend which created the temporary relation for a
7867 local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.
7868 arg6 is the number of bytes actually read, while arg7 is the number
7869 requested (if these are different it indicates trouble).</entry>
7870 </row>
7871 <row>
7872 <entry><literal>smgr-md-write-start</literal></entry>
7873 <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int)</literal></entry>
7874 <entry>Probe that fires when beginning to write a block to a relation.
7875 arg0 and arg1 contain the fork and block numbers of the page.
7876 arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
7877 identifying the relation.
7878 arg5 is the ID of the backend which created the temporary relation for a
7879 local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.</entry>
7880 </row>
7881 <row>
7882 <entry><literal>smgr-md-write-done</literal></entry>
7883 <entry><literal>(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int, int)</literal></entry>
7884 <entry>Probe that fires when a block write is complete.
7885 arg0 and arg1 contain the fork and block numbers of the page.
7886 arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
7887 identifying the relation.
7888 arg5 is the ID of the backend which created the temporary relation for a
7889 local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.
7890 arg6 is the number of bytes actually written, while arg7 is the number
7891 requested (if these are different it indicates trouble).</entry>
7892 </row>
7893 <row>
7894 <entry><literal>sort-start</literal></entry>
7895 <entry><literal>(int, bool, int, int, bool, int)</literal></entry>
7896 <entry>Probe that fires when a sort operation is started.
7897 arg0 indicates heap, index or datum sort.
7898 arg1 is true for unique-value enforcement.
7899 arg2 is the number of key columns.
7900 arg3 is the number of kilobytes of work memory allowed.
7901 arg4 is true if random access to the sort result is required.
7902 arg5 indicates serial when <literal>0</literal>, parallel worker when
7903 <literal>1</literal>, or parallel leader when <literal>2</literal>.</entry>
7904 </row>
7905 <row>
7906 <entry><literal>sort-done</literal></entry>
7907 <entry><literal>(bool, long)</literal></entry>
7908 <entry>Probe that fires when a sort is complete.
7909 arg0 is true for external sort, false for internal sort.
7910 arg1 is the number of disk blocks used for an external sort,
7911 or kilobytes of memory used for an internal sort.</entry>
7912 </row>
7913 <row>
7914 <entry><literal>lwlock-acquire</literal></entry>
7915 <entry><literal>(char *, LWLockMode)</literal></entry>
7916 <entry>Probe that fires when an LWLock has been acquired.
7917 arg0 is the LWLock's tranche.
7918 arg1 is the requested lock mode, either exclusive or shared.</entry>
7919 </row>
7920 <row>
7921 <entry><literal>lwlock-release</literal></entry>
7922 <entry><literal>(char *)</literal></entry>
7923 <entry>Probe that fires when an LWLock has been released (but note
7924 that any released waiters have not yet been awakened).
7925 arg0 is the LWLock's tranche.</entry>
7926 </row>
7927 <row>
7928 <entry><literal>lwlock-wait-start</literal></entry>
7929 <entry><literal>(char *, LWLockMode)</literal></entry>
7930 <entry>Probe that fires when an LWLock was not immediately available and
7931 a server process has begun to wait for the lock to become available.
7932 arg0 is the LWLock's tranche.
7933 arg1 is the requested lock mode, either exclusive or shared.</entry>
7934 </row>
7935 <row>
7936 <entry><literal>lwlock-wait-done</literal></entry>
7937 <entry><literal>(char *, LWLockMode)</literal></entry>
7938 <entry>Probe that fires when a server process has been released from its
7939 wait for an LWLock (it does not actually have the lock yet).
7940 arg0 is the LWLock's tranche.
7941 arg1 is the requested lock mode, either exclusive or shared.</entry>
7942 </row>
7943 <row>
7944 <entry><literal>lwlock-condacquire</literal></entry>
7945 <entry><literal>(char *, LWLockMode)</literal></entry>
7946 <entry>Probe that fires when an LWLock was successfully acquired when the
7947 caller specified no waiting.
7948 arg0 is the LWLock's tranche.
7949 arg1 is the requested lock mode, either exclusive or shared.</entry>
7950 </row>
7951 <row>
7952 <entry><literal>lwlock-condacquire-fail</literal></entry>
7953 <entry><literal>(char *, LWLockMode)</literal></entry>
7954 <entry>Probe that fires when an LWLock was not successfully acquired when
7955 the caller specified no waiting.
7956 arg0 is the LWLock's tranche.
7957 arg1 is the requested lock mode, either exclusive or shared.</entry>
7958 </row>
7959 <row>
7960 <entry><literal>lock-wait-start</literal></entry>
7961 <entry><literal>(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE)</literal></entry>
7962 <entry>Probe that fires when a request for a heavyweight lock (lmgr lock)
7963 has begun to wait because the lock is not available.
7964 arg0 through arg3 are the tag fields identifying the object being
7965 locked. arg4 indicates the type of object being locked.
7966 arg5 indicates the lock type being requested.</entry>
7967 </row>
7968 <row>
7969 <entry><literal>lock-wait-done</literal></entry>
7970 <entry><literal>(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE)</literal></entry>
7971 <entry>Probe that fires when a request for a heavyweight lock (lmgr lock)
7972 has finished waiting (i.e., has acquired the lock).
7973 The arguments are the same as for <literal>lock-wait-start</literal>.</entry>
7974 </row>
7975 <row>
7976 <entry><literal>deadlock-found</literal></entry>
7977 <entry><literal>()</literal></entry>
7978 <entry>Probe that fires when a deadlock is found by the deadlock
7979 detector.</entry>
7980 </row>
7982 </tbody>
7983 </tgroup>
7984 </table>
7986 <table id="typedefs-table">
7987 <title>Defined Types Used in Probe Parameters</title>
7988 <tgroup cols="2">
7989 <thead>
7990 <row>
7991 <entry>Type</entry>
7992 <entry>Definition</entry>
7993 </row>
7994 </thead>
7996 <tbody>
7998 <row>
7999 <entry><type>LocalTransactionId</type></entry>
8000 <entry><type>unsigned int</type></entry>
8001 </row>
8002 <row>
8003 <entry><type>LWLockMode</type></entry>
8004 <entry><type>int</type></entry>
8005 </row>
8006 <row>
8007 <entry><type>LOCKMODE</type></entry>
8008 <entry><type>int</type></entry>
8009 </row>
8010 <row>
8011 <entry><type>BlockNumber</type></entry>
8012 <entry><type>unsigned int</type></entry>
8013 </row>
8014 <row>
8015 <entry><type>Oid</type></entry>
8016 <entry><type>unsigned int</type></entry>
8017 </row>
8018 <row>
8019 <entry><type>ForkNumber</type></entry>
8020 <entry><type>int</type></entry>
8021 </row>
8022 <row>
8023 <entry><type>bool</type></entry>
8024 <entry><type>unsigned char</type></entry>
8025 </row>
8027 </tbody>
8028 </tgroup>
8029 </table>
8032 </sect2>
8034 <sect2 id="using-trace-points">
8035 <title>Using Probes</title>
8037 <para>
8038 The example below shows a DTrace script for analyzing transaction
8039 counts in the system, as an alternative to snapshotting
8040 <structname>pg_stat_database</structname> before and after a performance test:
8041 <programlisting>
8042 #!/usr/sbin/dtrace -qs
8044 postgresql$1:::transaction-start
8046 @start["Start"] = count();
8047 self->ts = timestamp;
8050 postgresql$1:::transaction-abort
8052 @abort["Abort"] = count();
8055 postgresql$1:::transaction-commit
8056 /self->ts/
8058 @commit["Commit"] = count();
8059 @time["Total time (ns)"] = sum(timestamp - self->ts);
8060 self->ts=0;
8062 </programlisting>
8063 When executed, the example D script gives output such as:
8064 <screen>
8065 # ./txn_count.d `pgrep -n postgres` or ./txn_count.d &lt;PID&gt;
8068 Start 71
8069 Commit 70
8070 Total time (ns) 2312105013
8071 </screen>
8072 </para>
8074 <note>
8075 <para>
8076 SystemTap uses a different notation for trace scripts than DTrace does,
8077 even though the underlying trace points are compatible. One point worth
8078 noting is that at this writing, SystemTap scripts must reference probe
8079 names using double underscores in place of hyphens. This is expected to
8080 be fixed in future SystemTap releases.
8081 </para>
8082 </note>
8084 <para>
8085 You should remember that DTrace scripts need to be carefully written and
8086 debugged, otherwise the trace information collected might
8087 be meaningless. In most cases where problems are found it is the
8088 instrumentation that is at fault, not the underlying system. When
8089 discussing information found using dynamic tracing, be sure to enclose
8090 the script used to allow that too to be checked and discussed.
8091 </para>
8092 </sect2>
8094 <sect2 id="defining-trace-points">
8095 <title>Defining New Probes</title>
8097 <para>
8098 New probes can be defined within the code wherever the developer
8099 desires, though this will require a recompilation. Below are the steps
8100 for inserting new probes:
8101 </para>
8103 <procedure>
8104 <step>
8105 <para>
8106 Decide on probe names and data to be made available through the probes
8107 </para>
8108 </step>
8110 <step>
8111 <para>
8112 Add the probe definitions to <filename>src/backend/utils/probes.d</filename>
8113 </para>
8114 </step>
8116 <step>
8117 <para>
8118 Include <filename>pg_trace.h</filename> if it is not already present in the
8119 module(s) containing the probe points, and insert
8120 <literal>TRACE_POSTGRESQL</literal> probe macros at the desired locations
8121 in the source code
8122 </para>
8123 </step>
8125 <step>
8126 <para>
8127 Recompile and verify that the new probes are available
8128 </para>
8129 </step>
8130 </procedure>
8132 <formalpara>
8133 <title>Example:</title>
8134 <para>
8135 Here is an example of how you would add a probe to trace all new
8136 transactions by transaction ID.
8137 </para>
8138 </formalpara>
8140 <procedure>
8141 <step>
8142 <para>
8143 Decide that the probe will be named <literal>transaction-start</literal> and
8144 requires a parameter of type <type>LocalTransactionId</type>
8145 </para>
8146 </step>
8148 <step>
8149 <para>
8150 Add the probe definition to <filename>src/backend/utils/probes.d</filename>:
8151 <programlisting>
8152 probe transaction__start(LocalTransactionId);
8153 </programlisting>
8154 Note the use of the double underline in the probe name. In a DTrace
8155 script using the probe, the double underline needs to be replaced with a
8156 hyphen, so <literal>transaction-start</literal> is the name to document for
8157 users.
8158 </para>
8159 </step>
8161 <step>
8162 <para>
8163 At compile time, <literal>transaction__start</literal> is converted to a macro
8164 called <literal>TRACE_POSTGRESQL_TRANSACTION_START</literal> (notice the
8165 underscores are single here), which is available by including
8166 <filename>pg_trace.h</filename>. Add the macro call to the appropriate location
8167 in the source code. In this case, it looks like the following:
8169 <programlisting>
8170 TRACE_POSTGRESQL_TRANSACTION_START(vxid.localTransactionId);
8171 </programlisting>
8172 </para>
8173 </step>
8175 <step>
8176 <para>
8177 After recompiling and running the new binary, check that your newly added
8178 probe is available by executing the following DTrace command. You
8179 should see similar output:
8180 <screen>
8181 # dtrace -ln transaction-start
8182 ID PROVIDER MODULE FUNCTION NAME
8183 18705 postgresql49878 postgres StartTransactionCommand transaction-start
8184 18755 postgresql49877 postgres StartTransactionCommand transaction-start
8185 18805 postgresql49876 postgres StartTransactionCommand transaction-start
8186 18855 postgresql49875 postgres StartTransactionCommand transaction-start
8187 18986 postgresql49873 postgres StartTransactionCommand transaction-start
8188 </screen>
8189 </para>
8190 </step>
8191 </procedure>
8193 <para>
8194 There are a few things to be careful about when adding trace macros
8195 to the C code:
8197 <itemizedlist>
8198 <listitem>
8199 <para>
8200 You should take care that the data types specified for a probe's
8201 parameters match the data types of the variables used in the macro.
8202 Otherwise, you will get compilation errors.
8203 </para>
8204 </listitem>
8207 <listitem>
8208 <para>
8209 On most platforms, if <productname>PostgreSQL</productname> is
8210 built with <option>--enable-dtrace</option>, the arguments to a trace
8211 macro will be evaluated whenever control passes through the
8212 macro, <emphasis>even if no tracing is being done</emphasis>. This is
8213 usually not worth worrying about if you are just reporting the
8214 values of a few local variables. But beware of putting expensive
8215 function calls into the arguments. If you need to do that,
8216 consider protecting the macro with a check to see if the trace
8217 is actually enabled:
8219 <programlisting>
8220 if (TRACE_POSTGRESQL_TRANSACTION_START_ENABLED())
8221 TRACE_POSTGRESQL_TRANSACTION_START(some_function(...));
8222 </programlisting>
8224 Each trace macro has a corresponding <literal>ENABLED</literal> macro.
8225 </para>
8226 </listitem>
8227 </itemizedlist>
8229 </para>
8231 </sect2>
8233 </sect1>
8235 </chapter>