gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
25KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>27.4. Progress Reporting</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="monitoring-locks.html" title="27.3. Viewing Locks" /><link rel="next" href="dynamic-trace.html" title="27.5. Dynamic Tracing" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">27.4. Progress Reporting</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="monitoring-locks.html" title="27.3. Viewing Locks">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="monitoring.html" title="Chapter 27. Monitoring Database Activity">Up</a></td><th width="60%" align="center">Chapter 27. Monitoring Database Activity</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="dynamic-trace.html" title="27.5. Dynamic Tracing">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="PROGRESS-REPORTING"><div class="titlepage"><div><div><h2 class="title" style="clear: both">27.4. Progress Reporting</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="progress-reporting.html#CREATE-INDEX-PROGRESS-REPORTING">27.4.1. CREATE INDEX Progress Reporting</a></span></dt><dt><span class="sect2"><a href="progress-reporting.html#VACUUM-PROGRESS-REPORTING">27.4.2. VACUUM Progress Reporting</a></span></dt><dt><span class="sect2"><a href="progress-reporting.html#CLUSTER-PROGRESS-REPORTING">27.4.3. CLUSTER Progress Reporting</a></span></dt></dl></div><p>
  3. <span class="productname">PostgreSQL</span> has the ability to report the progress of
  4. certain commands during command execution. Currently, the only commands
  5. which support progress reporting are <code class="command">CREATE INDEX</code>,
  6. <code class="command">VACUUM</code> and
  7. <code class="command">CLUSTER</code>. This may be expanded in the future.
  8. </p><div class="sect2" id="CREATE-INDEX-PROGRESS-REPORTING"><div class="titlepage"><div><div><h3 class="title">27.4.1. CREATE INDEX Progress Reporting</h3></div></div></div><p>
  9. Whenever <code class="command">CREATE INDEX</code> or <code class="command">REINDEX</code> is running, the
  10. <code class="structname">pg_stat_progress_create_index</code> view will contain
  11. one row for each backend that is currently creating indexes. The tables
  12. below describe the information that will be reported and provide information
  13. about how to interpret it.
  14. </p><div class="table" id="PG-STAT-PROGRESS-CREATE-INDEX-VIEW"><p class="title"><strong>Table 27.22. <code class="structname">pg_stat_progress_create_index</code> View</strong></p><div class="table-contents"><table class="table" summary="pg_stat_progress_create_index View" border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Column</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="structfield">pid</code></td><td><code class="type">integer</code></td><td>Process ID of backend.</td></tr><tr><td><code class="structfield">datid</code></td><td><code class="type">oid</code></td><td>OID of the database to which this backend is connected.</td></tr><tr><td><code class="structfield">datname</code></td><td><code class="type">name</code></td><td>Name of the database to which this backend is connected.</td></tr><tr><td><code class="structfield">relid</code></td><td><code class="type">oid</code></td><td>OID of the table on which the index is being created.</td></tr><tr><td><code class="structfield">index_relid</code></td><td><code class="type">oid</code></td><td>OID of the index being created or reindexed. During a
  15. non-concurrent <code class="command">CREATE INDEX</code>, this is 0.</td></tr><tr><td><code class="structfield">command</code></td><td><code class="type">text</code></td><td>
  16. The command that is running: <code class="literal">CREATE INDEX</code>,
  17. <code class="literal">CREATE INDEX CONCURRENTLY</code>,
  18. <code class="literal">REINDEX</code>, or <code class="literal">REINDEX CONCURRENTLY</code>.
  19. </td></tr><tr><td><code class="structfield">phase</code></td><td><code class="type">text</code></td><td>
  20. Current processing phase of index creation. See <a class="xref" href="progress-reporting.html#CREATE-INDEX-PHASES" title="Table 27.23. CREATE INDEX Phases">Table 27.23</a>.
  21. </td></tr><tr><td><code class="structfield">lockers_total</code></td><td><code class="type">bigint</code></td><td>
  22. Total number of lockers to wait for, when applicable.
  23. </td></tr><tr><td><code class="structfield">lockers_done</code></td><td><code class="type">bigint</code></td><td>
  24. Number of lockers already waited for.
  25. </td></tr><tr><td><code class="structfield">current_locker_pid</code></td><td><code class="type">bigint</code></td><td>
  26. Process ID of the locker currently being waited for.
  27. </td></tr><tr><td><code class="structfield">blocks_total</code></td><td><code class="type">bigint</code></td><td>
  28. Total number of blocks to be processed in the current phase.
  29. </td></tr><tr><td><code class="structfield">blocks_done</code></td><td><code class="type">bigint</code></td><td>
  30. Number of blocks already processed in the current phase.
  31. </td></tr><tr><td><code class="structfield">tuples_total</code></td><td><code class="type">bigint</code></td><td>
  32. Total number of tuples to be processed in the current phase.
  33. </td></tr><tr><td><code class="structfield">tuples_done</code></td><td><code class="type">bigint</code></td><td>
  34. Number of tuples already processed in the current phase.
  35. </td></tr><tr><td><code class="structfield">partitions_total</code></td><td><code class="type">bigint</code></td><td>
  36. When creating an index on a partitioned table, this column is set to
  37. the total number of partitions on which the index is to be created.
  38. </td></tr><tr><td><code class="structfield">partitions_done</code></td><td><code class="type">bigint</code></td><td>
  39. When creating an index on a partitioned table, this column is set to
  40. the number of partitions on which the index has been completed.
  41. </td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="CREATE-INDEX-PHASES"><p class="title"><strong>Table 27.23. CREATE INDEX Phases</strong></p><div class="table-contents"><table class="table" summary="CREATE INDEX Phases" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Phase</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">initializing</code></td><td>
  42. <code class="command">CREATE INDEX</code> or <code class="command">REINDEX</code> is preparing to create the index. This
  43. phase is expected to be very brief.
  44. </td></tr><tr><td><code class="literal">waiting for writers before build</code></td><td>
  45. <code class="command">CREATE INDEX CONCURRENTLY</code> or <code class="command">REINDEX CONCURRENTLY</code> is waiting for transactions
  46. with write locks that can potentially see the table to finish.
  47. This phase is skipped when not in concurrent mode.
  48. Columns <code class="structname">lockers_total</code>, <code class="structname">lockers_done</code>
  49. and <code class="structname">current_locker_pid</code> contain the progress
  50. information for this phase.
  51. </td></tr><tr><td><code class="literal">building index</code></td><td>
  52. The index is being built by the access method-specific code. In this phase,
  53. access methods that support progress reporting fill in their own progress data,
  54. and the subphase is indicated in this column. Typically,
  55. <code class="structname">blocks_total</code> and <code class="structname">blocks_done</code>
  56. will contain progress data, as well as potentially
  57. <code class="structname">tuples_total</code> and <code class="structname">tuples_done</code>.
  58. </td></tr><tr><td><code class="literal">waiting for writers before validation</code></td><td>
  59. <code class="command">CREATE INDEX CONCURRENTLY</code> or <code class="command">REINDEX CONCURRENTLY</code> is waiting for transactions
  60. with write locks that can potentially write into the table to finish.
  61. This phase is skipped when not in concurrent mode.
  62. Columns <code class="structname">lockers_total</code>, <code class="structname">lockers_done</code>
  63. and <code class="structname">current_locker_pid</code> contain the progress
  64. information for this phase.
  65. </td></tr><tr><td><code class="literal">index validation: scanning index</code></td><td>
  66. <code class="command">CREATE INDEX CONCURRENTLY</code> is scanning the index searching
  67. for tuples that need to be validated.
  68. This phase is skipped when not in concurrent mode.
  69. Columns <code class="structname">blocks_total</code> (set to the total size of the index)
  70. and <code class="structname">blocks_done</code> contain the progress information for this phase.
  71. </td></tr><tr><td><code class="literal">index validation: sorting tuples</code></td><td>
  72. <code class="command">CREATE INDEX CONCURRENTLY</code> is sorting the output of the
  73. index scanning phase.
  74. </td></tr><tr><td><code class="literal">index validation: scanning table</code></td><td>
  75. <code class="command">CREATE INDEX CONCURRENTLY</code> is scanning the table
  76. to validate the index tuples collected in the previous two phases.
  77. This phase is skipped when not in concurrent mode.
  78. Columns <code class="structname">blocks_total</code> (set to the total size of the table)
  79. and <code class="structname">blocks_done</code> contain the progress information for this phase.
  80. </td></tr><tr><td><code class="literal">waiting for old snapshots</code></td><td>
  81. <code class="command">CREATE INDEX CONCURRENTLY</code> or <code class="command">REINDEX CONCURRENTLY</code> is waiting for transactions
  82. that can potentially see the table to release their snapshots. This
  83. phase is skipped when not in concurrent mode.
  84. Columns <code class="structname">lockers_total</code>, <code class="structname">lockers_done</code>
  85. and <code class="structname">current_locker_pid</code> contain the progress
  86. information for this phase.
  87. </td></tr><tr><td><code class="literal">waiting for readers before marking dead</code></td><td>
  88. <code class="command">REINDEX CONCURRENTLY</code> is waiting for transactions
  89. with read locks on the table to finish, before marking the old index dead.
  90. This phase is skipped when not in concurrent mode.
  91. Columns <code class="structname">lockers_total</code>, <code class="structname">lockers_done</code>
  92. and <code class="structname">current_locker_pid</code> contain the progress
  93. information for this phase.
  94. </td></tr><tr><td><code class="literal">waiting for readers before dropping</code></td><td>
  95. <code class="command">REINDEX CONCURRENTLY</code> is waiting for transactions
  96. with read locks on the table to finish, before dropping the old index.
  97. This phase is skipped when not in concurrent mode.
  98. Columns <code class="structname">lockers_total</code>, <code class="structname">lockers_done</code>
  99. and <code class="structname">current_locker_pid</code> contain the progress
  100. information for this phase.
  101. </td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="VACUUM-PROGRESS-REPORTING"><div class="titlepage"><div><div><h3 class="title">27.4.2. VACUUM Progress Reporting</h3></div></div></div><p>
  102. Whenever <code class="command">VACUUM</code> is running, the
  103. <code class="structname">pg_stat_progress_vacuum</code> view will contain
  104. one row for each backend (including autovacuum worker processes) that is
  105. currently vacuuming. The tables below describe the information
  106. that will be reported and provide information about how to interpret it.
  107. Progress for <code class="command">VACUUM FULL</code> commands is reported via
  108. <code class="structname">pg_stat_progress_cluster</code>
  109. because both <code class="command">VACUUM FULL</code> and <code class="command">CLUSTER</code>
  110. rewrite the table, while regular <code class="command">VACUUM</code> only modifies it
  111. in place. See <a class="xref" href="progress-reporting.html#CLUSTER-PROGRESS-REPORTING" title="27.4.3. CLUSTER Progress Reporting">Section 27.4.3</a>.
  112. </p><div class="table" id="PG-STAT-PROGRESS-VACUUM-VIEW"><p class="title"><strong>Table 27.24. <code class="structname">pg_stat_progress_vacuum</code> View</strong></p><div class="table-contents"><table class="table" summary="pg_stat_progress_vacuum View" border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Column</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="structfield">pid</code></td><td><code class="type">integer</code></td><td>Process ID of backend.</td></tr><tr><td><code class="structfield">datid</code></td><td><code class="type">oid</code></td><td>OID of the database to which this backend is connected.</td></tr><tr><td><code class="structfield">datname</code></td><td><code class="type">name</code></td><td>Name of the database to which this backend is connected.</td></tr><tr><td><code class="structfield">relid</code></td><td><code class="type">oid</code></td><td>OID of the table being vacuumed.</td></tr><tr><td><code class="structfield">phase</code></td><td><code class="type">text</code></td><td>
  113. Current processing phase of vacuum. See <a class="xref" href="progress-reporting.html#VACUUM-PHASES" title="Table 27.25. VACUUM Phases">Table 27.25</a>.
  114. </td></tr><tr><td><code class="structfield">heap_blks_total</code></td><td><code class="type">bigint</code></td><td>
  115. Total number of heap blocks in the table. This number is reported
  116. as of the beginning of the scan; blocks added later will not be (and
  117. need not be) visited by this <code class="command">VACUUM</code>.
  118. </td></tr><tr><td><code class="structfield">heap_blks_scanned</code></td><td><code class="type">bigint</code></td><td>
  119. Number of heap blocks scanned. Because the
  120. <a class="link" href="storage-vm.html" title="68.4. Visibility Map">visibility map</a> is used to optimize scans,
  121. some blocks will be skipped without inspection; skipped blocks are
  122. included in this total, so that this number will eventually become
  123. equal to <code class="structfield">heap_blks_total</code> when the vacuum is complete.
  124. This counter only advances when the phase is <code class="literal">scanning heap</code>.
  125. </td></tr><tr><td><code class="structfield">heap_blks_vacuumed</code></td><td><code class="type">bigint</code></td><td>
  126. Number of heap blocks vacuumed. Unless the table has no indexes, this
  127. counter only advances when the phase is <code class="literal">vacuuming heap</code>.
  128. Blocks that contain no dead tuples are skipped, so the counter may
  129. sometimes skip forward in large increments.
  130. </td></tr><tr><td><code class="structfield">index_vacuum_count</code></td><td><code class="type">bigint</code></td><td>
  131. Number of completed index vacuum cycles.
  132. </td></tr><tr><td><code class="structfield">max_dead_tuples</code></td><td><code class="type">bigint</code></td><td>
  133. Number of dead tuples that we can store before needing to perform
  134. an index vacuum cycle, based on
  135. <a class="xref" href="runtime-config-resource.html#GUC-MAINTENANCE-WORK-MEM">maintenance_work_mem</a>.
  136. </td></tr><tr><td><code class="structfield">num_dead_tuples</code></td><td><code class="type">bigint</code></td><td>
  137. Number of dead tuples collected since the last index vacuum cycle.
  138. </td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="VACUUM-PHASES"><p class="title"><strong>Table 27.25. VACUUM Phases</strong></p><div class="table-contents"><table class="table" summary="VACUUM Phases" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Phase</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">initializing</code></td><td>
  139. <code class="command">VACUUM</code> is preparing to begin scanning the heap. This
  140. phase is expected to be very brief.
  141. </td></tr><tr><td><code class="literal">scanning heap</code></td><td>
  142. <code class="command">VACUUM</code> is currently scanning the heap. It will prune and
  143. defragment each page if required, and possibly perform freezing
  144. activity. The <code class="structfield">heap_blks_scanned</code> column can be used
  145. to monitor the progress of the scan.
  146. </td></tr><tr><td><code class="literal">vacuuming indexes</code></td><td>
  147. <code class="command">VACUUM</code> is currently vacuuming the indexes. If a table has
  148. any indexes, this will happen at least once per vacuum, after the heap
  149. has been completely scanned. It may happen multiple times per vacuum
  150. if <a class="xref" href="runtime-config-resource.html#GUC-MAINTENANCE-WORK-MEM">maintenance_work_mem</a> is insufficient to
  151. store the number of dead tuples found.
  152. </td></tr><tr><td><code class="literal">vacuuming heap</code></td><td>
  153. <code class="command">VACUUM</code> is currently vacuuming the heap. Vacuuming the heap
  154. is distinct from scanning the heap, and occurs after each instance of
  155. vacuuming indexes. If <code class="structfield">heap_blks_scanned</code> is less than
  156. <code class="structfield">heap_blks_total</code>, the system will return to scanning
  157. the heap after this phase is completed; otherwise, it will begin
  158. cleaning up indexes after this phase is completed.
  159. </td></tr><tr><td><code class="literal">cleaning up indexes</code></td><td>
  160. <code class="command">VACUUM</code> is currently cleaning up indexes. This occurs after
  161. the heap has been completely scanned and all vacuuming of the indexes
  162. and the heap has been completed.
  163. </td></tr><tr><td><code class="literal">truncating heap</code></td><td>
  164. <code class="command">VACUUM</code> is currently truncating the heap so as to return
  165. empty pages at the end of the relation to the operating system. This
  166. occurs after cleaning up indexes.
  167. </td></tr><tr><td><code class="literal">performing final cleanup</code></td><td>
  168. <code class="command">VACUUM</code> is performing final cleanup. During this phase,
  169. <code class="command">VACUUM</code> will vacuum the free space map, update statistics
  170. in <code class="literal">pg_class</code>, and report statistics to the statistics
  171. collector. When this phase is completed, <code class="command">VACUUM</code> will end.
  172. </td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="CLUSTER-PROGRESS-REPORTING"><div class="titlepage"><div><div><h3 class="title">27.4.3. CLUSTER Progress Reporting</h3></div></div></div><p>
  173. Whenever <code class="command">CLUSTER</code> or <code class="command">VACUUM FULL</code> is
  174. running, the <code class="structname">pg_stat_progress_cluster</code> view will
  175. contain a row for each backend that is currently running either command.
  176. The tables below describe the information that will be reported and
  177. provide information about how to interpret it.
  178. </p><div class="table" id="PG-STAT-PROGRESS-CLUSTER-VIEW"><p class="title"><strong>Table 27.26. <code class="structname">pg_stat_progress_cluster</code> View</strong></p><div class="table-contents"><table class="table" summary="pg_stat_progress_cluster View" border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Column</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="structfield">pid</code></td><td><code class="type">integer</code></td><td>Process ID of backend.</td></tr><tr><td><code class="structfield">datid</code></td><td><code class="type">oid</code></td><td>OID of the database to which this backend is connected.</td></tr><tr><td><code class="structfield">datname</code></td><td><code class="type">name</code></td><td>Name of the database to which this backend is connected.</td></tr><tr><td><code class="structfield">relid</code></td><td><code class="type">oid</code></td><td>OID of the table being clustered.</td></tr><tr><td><code class="structfield">command</code></td><td><code class="type">text</code></td><td>
  179. The command that is running. Either <code class="literal">CLUSTER</code> or <code class="literal">VACUUM FULL</code>.
  180. </td></tr><tr><td><code class="structfield">phase</code></td><td><code class="type">text</code></td><td>
  181. Current processing phase. See <a class="xref" href="progress-reporting.html#CLUSTER-PHASES" title="Table 27.27. CLUSTER and VACUUM FULL Phases">Table 27.27</a>.
  182. </td></tr><tr><td><code class="structfield">cluster_index_relid</code></td><td><code class="type">oid</code></td><td>
  183. If the table is being scanned using an index, this is the OID of the
  184. index being used; otherwise, it is zero.
  185. </td></tr><tr><td><code class="structfield">heap_tuples_scanned</code></td><td><code class="type">bigint</code></td><td>
  186. Number of heap tuples scanned.
  187. This counter only advances when the phase is
  188. <code class="literal">seq scanning heap</code>,
  189. <code class="literal">index scanning heap</code>
  190. or <code class="literal">writing new heap</code>.
  191. </td></tr><tr><td><code class="structfield">heap_tuples_written</code></td><td><code class="type">bigint</code></td><td>
  192. Number of heap tuples written.
  193. This counter only advances when the phase is
  194. <code class="literal">seq scanning heap</code>,
  195. <code class="literal">index scanning heap</code>
  196. or <code class="literal">writing new heap</code>.
  197. </td></tr><tr><td><code class="structfield">heap_blks_total</code></td><td><code class="type">bigint</code></td><td>
  198. Total number of heap blocks in the table. This number is reported
  199. as of the beginning of <code class="literal">seq scanning heap</code>.
  200. </td></tr><tr><td><code class="structfield">heap_blks_scanned</code></td><td><code class="type">bigint</code></td><td>
  201. Number of heap blocks scanned. This counter only advances when the
  202. phase is <code class="literal">seq scanning heap</code>.
  203. </td></tr><tr><td><code class="structfield">index_rebuild_count</code></td><td><code class="type">bigint</code></td><td>
  204. Number of indexes rebuilt. This counter only advances when the phase
  205. is <code class="literal">rebuilding index</code>.
  206. </td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="CLUSTER-PHASES"><p class="title"><strong>Table 27.27. CLUSTER and VACUUM FULL Phases</strong></p><div class="table-contents"><table class="table" summary="CLUSTER and VACUUM FULL Phases" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Phase</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">initializing</code></td><td>
  207. The command is preparing to begin scanning the heap. This phase is
  208. expected to be very brief.
  209. </td></tr><tr><td><code class="literal">seq scanning heap</code></td><td>
  210. The command is currently scanning the table using a sequential scan.
  211. </td></tr><tr><td><code class="literal">index scanning heap</code></td><td>
  212. <code class="command">CLUSTER</code> is currently scanning the table using an index scan.
  213. </td></tr><tr><td><code class="literal">sorting tuples</code></td><td>
  214. <code class="command">CLUSTER</code> is currently sorting tuples.
  215. </td></tr><tr><td><code class="literal">writing new heap</code></td><td>
  216. <code class="command">CLUSTER</code> is currently writing the new heap.
  217. </td></tr><tr><td><code class="literal">swapping relation files</code></td><td>
  218. The command is currently swapping newly-built files into place.
  219. </td></tr><tr><td><code class="literal">rebuilding index</code></td><td>
  220. The command is currently rebuilding an index.
  221. </td></tr><tr><td><code class="literal">performing final cleanup</code></td><td>
  222. The command is performing final cleanup. When this phase is
  223. completed, <code class="command">CLUSTER</code>
  224. or <code class="command">VACUUM FULL</code> will end.
  225. </td></tr></tbody></table></div></div><br class="table-break" /></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="monitoring-locks.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="monitoring.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="dynamic-trace.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">27.3. Viewing Locks </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 27.5. Dynamic Tracing</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1