2 27.4. Progress Reporting #
4 27.4.1. ANALYZE Progress Reporting
5 27.4.2. CLUSTER Progress Reporting
6 27.4.3. COPY Progress Reporting
7 27.4.4. CREATE INDEX Progress Reporting
8 27.4.5. VACUUM Progress Reporting
9 27.4.6. Base Backup Progress Reporting
11 PostgreSQL has the ability to report the progress of certain commands
12 during command execution. Currently, the only commands which support
13 progress reporting are ANALYZE, CLUSTER, CREATE INDEX, VACUUM, COPY,
14 and BASE_BACKUP (i.e., replication command that pg_basebackup issues to
15 take a base backup). This may be expanded in the future.
17 27.4.1. ANALYZE Progress Reporting #
19 Whenever ANALYZE is running, the pg_stat_progress_analyze view will
20 contain a row for each backend that is currently running that command.
21 The tables below describe the information that will be reported and
22 provide information about how to interpret it.
24 Table 27.38. pg_stat_progress_analyze View
32 Process ID of backend.
36 OID of the database to which this backend is connected.
40 Name of the database to which this backend is connected.
44 OID of the table being analyzed.
48 Current processing phase. See Table 27.39.
50 sample_blks_total bigint
52 Total number of heap blocks that will be sampled.
54 sample_blks_scanned bigint
56 Number of heap blocks scanned.
58 ext_stats_total bigint
60 Number of extended statistics.
62 ext_stats_computed bigint
64 Number of extended statistics computed. This counter only advances when
65 the phase is computing extended statistics.
67 child_tables_total bigint
69 Number of child tables.
71 child_tables_done bigint
73 Number of child tables scanned. This counter only advances when the
74 phase is acquiring inherited sample rows.
76 current_child_table_relid oid
78 OID of the child table currently being scanned. This field is only
79 valid when the phase is acquiring inherited sample rows.
81 delay_time double precision
83 Total time spent sleeping due to cost-based delay (see Section 19.10.2,
84 in milliseconds (if track_cost_delay_timing is enabled, otherwise
87 Table 27.39. ANALYZE Phases
89 initializing The command is preparing to begin scanning the heap. This
90 phase is expected to be very brief.
91 acquiring sample rows The command is currently scanning the table given
92 by relid to obtain sample rows.
93 acquiring inherited sample rows The command is currently scanning child
94 tables to obtain sample rows. Columns child_tables_total,
95 child_tables_done, and current_child_table_relid contain the progress
96 information for this phase.
97 computing statistics The command is computing statistics from the
98 sample rows obtained during the table scan.
99 computing extended statistics The command is computing extended
100 statistics from the sample rows obtained during the table scan.
101 finalizing analyze The command is updating pg_class. When this phase is
102 completed, ANALYZE will end.
106 Note that when ANALYZE is run on a partitioned table without the ONLY
107 keyword, all of its partitions are also recursively analyzed. In that
108 case, ANALYZE progress is reported first for the parent table, whereby
109 its inheritance statistics are collected, followed by that for each
112 27.4.2. CLUSTER Progress Reporting #
114 Whenever CLUSTER or VACUUM FULL is running, the
115 pg_stat_progress_cluster view will contain a row for each backend that
116 is currently running either command. The tables below describe the
117 information that will be reported and provide information about how to
120 Table 27.40. pg_stat_progress_cluster View
128 Process ID of backend.
132 OID of the database to which this backend is connected.
136 Name of the database to which this backend is connected.
140 OID of the table being clustered.
144 The command that is running. Either CLUSTER or VACUUM FULL.
148 Current processing phase. See Table 27.41.
150 cluster_index_relid oid
152 If the table is being scanned using an index, this is the OID of the
153 index being used; otherwise, it is zero.
155 heap_tuples_scanned bigint
157 Number of heap tuples scanned. This counter only advances when the
158 phase is seq scanning heap, index scanning heap or writing new heap.
160 heap_tuples_written bigint
162 Number of heap tuples written. This counter only advances when the
163 phase is seq scanning heap, index scanning heap or writing new heap.
165 heap_blks_total bigint
167 Total number of heap blocks in the table. This number is reported as of
168 the beginning of seq scanning heap.
170 heap_blks_scanned bigint
172 Number of heap blocks scanned. This counter only advances when the
173 phase is seq scanning heap.
175 index_rebuild_count bigint
177 Number of indexes rebuilt. This counter only advances when the phase is
180 Table 27.41. CLUSTER and VACUUM FULL Phases
182 initializing The command is preparing to begin scanning the heap. This
183 phase is expected to be very brief.
184 seq scanning heap The command is currently scanning the table using a
186 index scanning heap CLUSTER is currently scanning the table using an
188 sorting tuples CLUSTER is currently sorting tuples.
189 writing new heap CLUSTER is currently writing the new heap.
190 swapping relation files The command is currently swapping newly-built
192 rebuilding index The command is currently rebuilding an index.
193 performing final cleanup The command is performing final cleanup. When
194 this phase is completed, CLUSTER or VACUUM FULL will end.
196 27.4.3. COPY Progress Reporting #
198 Whenever COPY is running, the pg_stat_progress_copy view will contain
199 one row for each backend that is currently running a COPY command. The
200 table below describes the information that will be reported and
201 provides information about how to interpret it.
203 Table 27.42. pg_stat_progress_copy View
211 Process ID of backend.
215 OID of the database to which this backend is connected.
219 Name of the database to which this backend is connected.
223 OID of the table on which the COPY command is executed. It is set to 0
224 if copying from a SELECT query.
228 The command that is running: COPY FROM, or COPY TO.
232 The I/O type that the data is read from or written to: FILE, PROGRAM,
233 PIPE (for COPY FROM STDIN and COPY TO STDOUT), or CALLBACK (used for
234 example during the initial table synchronization in logical
237 bytes_processed bigint
239 Number of bytes already processed by COPY command.
243 Size of source file for COPY FROM command in bytes. It is set to 0 if
246 tuples_processed bigint
248 Number of tuples already processed by COPY command.
250 tuples_excluded bigint
252 Number of tuples not processed because they were excluded by the WHERE
253 clause of the COPY command.
255 tuples_skipped bigint
257 Number of tuples skipped because they contain malformed data. This
258 counter only advances when a value other than stop is specified to the
261 27.4.4. CREATE INDEX Progress Reporting #
263 Whenever CREATE INDEX or REINDEX is running, the
264 pg_stat_progress_create_index view will contain one row for each
265 backend that is currently creating indexes. The tables below describe
266 the information that will be reported and provide information about how
269 Table 27.43. pg_stat_progress_create_index View
277 Process ID of the backend creating indexes.
281 OID of the database to which this backend is connected.
285 Name of the database to which this backend is connected.
289 OID of the table on which the index is being created.
293 OID of the index being created or reindexed. During a non-concurrent
294 CREATE INDEX, this is 0.
298 Specific command type: CREATE INDEX, CREATE INDEX CONCURRENTLY,
299 REINDEX, or REINDEX CONCURRENTLY.
303 Current processing phase of index creation. See Table 27.44.
307 Total number of lockers to wait for, when applicable.
311 Number of lockers already waited for.
313 current_locker_pid bigint
315 Process ID of the locker currently being waited for.
319 Total number of blocks to be processed in the current phase.
323 Number of blocks already processed in the current phase.
327 Total number of tuples to be processed in the current phase.
331 Number of tuples already processed in the current phase.
333 partitions_total bigint
335 Total number of partitions on which the index is to be created or
336 attached, including both direct and indirect partitions. 0 during a
337 REINDEX, or when the index is not partitioned.
339 partitions_done bigint
341 Number of partitions on which the index has already been created or
342 attached, including both direct and indirect partitions. 0 during a
343 REINDEX, or when the index is not partitioned.
345 Table 27.44. CREATE INDEX Phases
347 initializing CREATE INDEX or REINDEX is preparing to create the index.
348 This phase is expected to be very brief.
349 waiting for writers before build CREATE INDEX CONCURRENTLY or REINDEX
350 CONCURRENTLY is waiting for transactions with write locks that can
351 potentially see the table to finish. This phase is skipped when not in
352 concurrent mode. Columns lockers_total, lockers_done and
353 current_locker_pid contain the progress information for this phase.
354 building index The index is being built by the access method-specific
355 code. In this phase, access methods that support progress reporting
356 fill in their own progress data, and the subphase is indicated in this
357 column. Typically, blocks_total and blocks_done will contain progress
358 data, as well as potentially tuples_total and tuples_done.
359 waiting for writers before validation CREATE INDEX CONCURRENTLY or
360 REINDEX CONCURRENTLY is waiting for transactions with write locks that
361 can potentially write into the table to finish. This phase is skipped
362 when not in concurrent mode. Columns lockers_total, lockers_done and
363 current_locker_pid contain the progress information for this phase.
364 index validation: scanning index CREATE INDEX CONCURRENTLY is scanning
365 the index searching for tuples that need to be validated. This phase is
366 skipped when not in concurrent mode. Columns blocks_total (set to the
367 total size of the index) and blocks_done contain the progress
368 information for this phase.
369 index validation: sorting tuples CREATE INDEX CONCURRENTLY is sorting
370 the output of the index scanning phase.
371 index validation: scanning table CREATE INDEX CONCURRENTLY is scanning
372 the table to validate the index tuples collected in the previous two
373 phases. This phase is skipped when not in concurrent mode. Columns
374 blocks_total (set to the total size of the table) and blocks_done
375 contain the progress information for this phase.
376 waiting for old snapshots CREATE INDEX CONCURRENTLY or REINDEX
377 CONCURRENTLY is waiting for transactions that can potentially see the
378 table to release their snapshots. This phase is skipped when not in
379 concurrent mode. Columns lockers_total, lockers_done and
380 current_locker_pid contain the progress information for this phase.
381 waiting for readers before marking dead REINDEX CONCURRENTLY is waiting
382 for transactions with read locks on the table to finish, before marking
383 the old index dead. This phase is skipped when not in concurrent mode.
384 Columns lockers_total, lockers_done and current_locker_pid contain the
385 progress information for this phase.
386 waiting for readers before dropping REINDEX CONCURRENTLY is waiting for
387 transactions with read locks on the table to finish, before dropping
388 the old index. This phase is skipped when not in concurrent mode.
389 Columns lockers_total, lockers_done and current_locker_pid contain the
390 progress information for this phase.
392 27.4.5. VACUUM Progress Reporting #
394 Whenever VACUUM is running, the pg_stat_progress_vacuum view will
395 contain one row for each backend (including autovacuum worker
396 processes) that is currently vacuuming. The tables below describe the
397 information that will be reported and provide information about how to
398 interpret it. Progress for VACUUM FULL commands is reported via
399 pg_stat_progress_cluster because both VACUUM FULL and CLUSTER rewrite
400 the table, while regular VACUUM only modifies it in place. See
403 Table 27.45. pg_stat_progress_vacuum View
411 Process ID of backend.
415 OID of the database to which this backend is connected.
419 Name of the database to which this backend is connected.
423 OID of the table being vacuumed.
427 Current processing phase of vacuum. See Table 27.46.
429 heap_blks_total bigint
431 Total number of heap blocks in the table. This number is reported as of
432 the beginning of the scan; blocks added later will not be (and need not
433 be) visited by this VACUUM.
435 heap_blks_scanned bigint
437 Number of heap blocks scanned. Because the visibility map is used to
438 optimize scans, some blocks will be skipped without inspection; skipped
439 blocks are included in this total, so that this number will eventually
440 become equal to heap_blks_total when the vacuum is complete. This
441 counter only advances when the phase is scanning heap.
443 heap_blks_vacuumed bigint
445 Number of heap blocks vacuumed. Unless the table has no indexes, this
446 counter only advances when the phase is vacuuming heap. Blocks that
447 contain no dead tuples are skipped, so the counter may sometimes skip
448 forward in large increments.
450 index_vacuum_count bigint
452 Number of completed index vacuum cycles.
454 max_dead_tuple_bytes bigint
456 Amount of dead tuple data that we can store before needing to perform
457 an index vacuum cycle, based on maintenance_work_mem.
459 dead_tuple_bytes bigint
461 Amount of dead tuple data collected since the last index vacuum cycle.
463 num_dead_item_ids bigint
465 Number of dead item identifiers collected since the last index vacuum
470 Total number of indexes that will be vacuumed or cleaned up. This
471 number is reported at the beginning of the vacuuming indexes phase or
472 the cleaning up indexes phase.
474 indexes_processed bigint
476 Number of indexes processed. This counter only advances when the phase
477 is vacuuming indexes or cleaning up indexes.
479 delay_time double precision
481 Total time spent sleeping due to cost-based delay (see
482 Section 19.10.2), in milliseconds (if track_cost_delay_timing is
483 enabled, otherwise zero). This includes the time that any associated
484 parallel workers have slept. However, parallel workers report their
485 sleep time no more frequently than once per second, so the reported
486 value may be slightly stale.
488 Table 27.46. VACUUM Phases
490 initializing VACUUM is preparing to begin scanning the heap. This phase
491 is expected to be very brief.
492 scanning heap VACUUM is currently scanning the heap. It will prune and
493 defragment each page if required, and possibly perform freezing
494 activity. The heap_blks_scanned column can be used to monitor the
495 progress of the scan.
496 vacuuming indexes VACUUM is currently vacuuming the indexes. If a table
497 has any indexes, this will happen at least once per vacuum, after the
498 heap has been completely scanned. It may happen multiple times per
499 vacuum if maintenance_work_mem (or, in the case of autovacuum,
500 autovacuum_work_mem if set) is insufficient to store the number of dead
502 vacuuming heap VACUUM is currently vacuuming the heap. Vacuuming the
503 heap is distinct from scanning the heap, and occurs after each instance
504 of vacuuming indexes. If heap_blks_scanned is less than
505 heap_blks_total, the system will return to scanning the heap after this
506 phase is completed; otherwise, it will begin cleaning up indexes after
507 this phase is completed.
508 cleaning up indexes VACUUM is currently cleaning up indexes. This
509 occurs after the heap has been completely scanned and all vacuuming of
510 the indexes and the heap has been completed.
511 truncating heap VACUUM is currently truncating the heap so as to return
512 empty pages at the end of the relation to the operating system. This
513 occurs after cleaning up indexes.
514 performing final cleanup VACUUM is performing final cleanup. During
515 this phase, VACUUM will vacuum the free space map, update statistics in
516 pg_class, and report statistics to the cumulative statistics system.
517 When this phase is completed, VACUUM will end.
519 27.4.6. Base Backup Progress Reporting #
521 Whenever an application like pg_basebackup is taking a base backup, the
522 pg_stat_progress_basebackup view will contain a row for each WAL sender
523 process that is currently running the BASE_BACKUP replication command
524 and streaming the backup. The tables below describe the information
525 that will be reported and provide information about how to interpret
528 Table 27.47. pg_stat_progress_basebackup View
536 Process ID of a WAL sender process.
540 Current processing phase. See Table 27.48.
544 Total amount of data that will be streamed. This is estimated and
545 reported as of the beginning of streaming database files phase. Note
546 that this is only an approximation since the database may change during
547 streaming database files phase and WAL log may be included in the
548 backup later. This is always the same value as backup_streamed once the
549 amount of data streamed exceeds the estimated total size. If the
550 estimation is disabled in pg_basebackup (i.e., --no-estimate-size
551 option is specified), this is NULL.
553 backup_streamed bigint
555 Amount of data streamed. This counter only advances when the phase is
556 streaming database files or transferring wal files.
558 tablespaces_total bigint
560 Total number of tablespaces that will be streamed.
562 tablespaces_streamed bigint
564 Number of tablespaces streamed. This counter only advances when the
565 phase is streaming database files.
567 Table 27.48. Base Backup Phases
569 initializing The WAL sender process is preparing to begin the backup.
570 This phase is expected to be very brief.
571 waiting for checkpoint to finish The WAL sender process is currently
572 performing pg_backup_start to prepare to take a base backup, and
573 waiting for the start-of-backup checkpoint to finish.
574 estimating backup size The WAL sender process is currently estimating
575 the total amount of database files that will be streamed as a base
577 streaming database files The WAL sender process is currently streaming
578 database files as a base backup.
579 waiting for wal archiving to finish The WAL sender process is currently
580 performing pg_backup_stop to finish the backup, and waiting for all the
581 WAL files required for the base backup to be successfully archived. If
582 either --wal-method=none or --wal-method=stream is specified in
583 pg_basebackup, the backup will end when this phase is completed.
584 transferring wal files The WAL sender process is currently transferring
585 all WAL logs generated during the backup. This phase occurs after
586 waiting for wal archiving to finish phase if --wal-method=fetch is
587 specified in pg_basebackup. The backup will end when this phase is