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.

158 lines
14KB

  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>19.10. Automatic Vacuuming</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="runtime-config-statistics.html" title="19.9. Run-time Statistics" /><link rel="next" href="runtime-config-client.html" title="19.11. Client Connection Defaults" /></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">19.10. Automatic Vacuuming</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="runtime-config-statistics.html" title="19.9. Run-time Statistics">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="runtime-config.html" title="Chapter 19. Server Configuration">Up</a></td><th width="60%" align="center">Chapter 19. Server Configuration</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="runtime-config-client.html" title="19.11. Client Connection Defaults">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="RUNTIME-CONFIG-AUTOVACUUM"><div class="titlepage"><div><div><h2 class="title" style="clear: both">19.10. Automatic Vacuuming</h2></div></div></div><a id="id-1.6.6.13.2" class="indexterm"></a><p>
  3. These settings control the behavior of the <em class="firstterm">autovacuum</em>
  4. feature. Refer to <a class="xref" href="routine-vacuuming.html#AUTOVACUUM" title="24.1.6. The Autovacuum Daemon">Section 24.1.6</a> for more information.
  5. Note that many of these settings can be overridden on a per-table
  6. basis; see <a class="xref" href="sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS" title="Storage Parameters">Storage Parameters</a>.
  7. </p><div class="variablelist"><dl class="variablelist"><dt id="GUC-AUTOVACUUM"><span class="term"><code class="varname">autovacuum</code> (<code class="type">boolean</code>)
  8. <a id="id-1.6.6.13.4.1.1.3" class="indexterm"></a>
  9. </span></dt><dd><p>
  10. Controls whether the server should run the
  11. autovacuum launcher daemon. This is on by default; however,
  12. <a class="xref" href="runtime-config-statistics.html#GUC-TRACK-COUNTS">track_counts</a> must also be enabled for
  13. autovacuum to work.
  14. This parameter can only be set in the <code class="filename">postgresql.conf</code>
  15. file or on the server command line; however, autovacuuming can be
  16. disabled for individual tables by changing table storage parameters.
  17. </p><p>
  18. Note that even when this parameter is disabled, the system
  19. will launch autovacuum processes if necessary to
  20. prevent transaction ID wraparound. See <a class="xref" href="routine-vacuuming.html#VACUUM-FOR-WRAPAROUND" title="24.1.5. Preventing Transaction ID Wraparound Failures">Section 24.1.5</a> for more information.
  21. </p></dd><dt id="GUC-LOG-AUTOVACUUM-MIN-DURATION"><span class="term"><code class="varname">log_autovacuum_min_duration</code> (<code class="type">integer</code>)
  22. <a id="id-1.6.6.13.4.2.1.3" class="indexterm"></a>
  23. </span></dt><dd><p>
  24. Causes each action executed by autovacuum to be logged if it ran for at
  25. least the specified amount of time. Setting this to zero logs
  26. all autovacuum actions. <code class="literal">-1</code> (the default) disables
  27. logging autovacuum actions.
  28. If this value is specified without units, it is taken as milliseconds.
  29. For example, if you set this to
  30. <code class="literal">250ms</code> then all automatic vacuums and analyzes that run
  31. 250ms or longer will be logged. In addition, when this parameter is
  32. set to any value other than <code class="literal">-1</code>, a message will be
  33. logged if an autovacuum action is skipped due to a conflicting lock or a
  34. concurrently dropped relation. Enabling this parameter can be helpful
  35. in tracking autovacuum activity. This parameter can only be set in
  36. the <code class="filename">postgresql.conf</code> file or on the server command line;
  37. but the setting can be overridden for individual tables by
  38. changing table storage parameters.
  39. </p></dd><dt id="GUC-AUTOVACUUM-MAX-WORKERS"><span class="term"><code class="varname">autovacuum_max_workers</code> (<code class="type">integer</code>)
  40. <a id="id-1.6.6.13.4.3.1.3" class="indexterm"></a>
  41. </span></dt><dd><p>
  42. Specifies the maximum number of autovacuum processes (other than the
  43. autovacuum launcher) that may be running at any one time. The default
  44. is three. This parameter can only be set at server start.
  45. </p></dd><dt id="GUC-AUTOVACUUM-NAPTIME"><span class="term"><code class="varname">autovacuum_naptime</code> (<code class="type">integer</code>)
  46. <a id="id-1.6.6.13.4.4.1.3" class="indexterm"></a>
  47. </span></dt><dd><p>
  48. Specifies the minimum delay between autovacuum runs on any given
  49. database. In each round the daemon examines the
  50. database and issues <code class="command">VACUUM</code> and <code class="command">ANALYZE</code> commands
  51. as needed for tables in that database.
  52. If this value is specified without units, it is taken as seconds.
  53. The default is one minute (<code class="literal">1min</code>).
  54. This parameter can only be set in the <code class="filename">postgresql.conf</code>
  55. file or on the server command line.
  56. </p></dd><dt id="GUC-AUTOVACUUM-VACUUM-THRESHOLD"><span class="term"><code class="varname">autovacuum_vacuum_threshold</code> (<code class="type">integer</code>)
  57. <a id="id-1.6.6.13.4.5.1.3" class="indexterm"></a>
  58. </span></dt><dd><p>
  59. Specifies the minimum number of updated or deleted tuples needed
  60. to trigger a <code class="command">VACUUM</code> in any one table.
  61. The default is 50 tuples.
  62. This parameter can only be set in the <code class="filename">postgresql.conf</code>
  63. file or on the server command line;
  64. but the setting can be overridden for individual tables by
  65. changing table storage parameters.
  66. </p></dd><dt id="GUC-AUTOVACUUM-ANALYZE-THRESHOLD"><span class="term"><code class="varname">autovacuum_analyze_threshold</code> (<code class="type">integer</code>)
  67. <a id="id-1.6.6.13.4.6.1.3" class="indexterm"></a>
  68. </span></dt><dd><p>
  69. Specifies the minimum number of inserted, updated or deleted tuples
  70. needed to trigger an <code class="command">ANALYZE</code> in any one table.
  71. The default is 50 tuples.
  72. This parameter can only be set in the <code class="filename">postgresql.conf</code>
  73. file or on the server command line;
  74. but the setting can be overridden for individual tables by
  75. changing table storage parameters.
  76. </p></dd><dt id="GUC-AUTOVACUUM-VACUUM-SCALE-FACTOR"><span class="term"><code class="varname">autovacuum_vacuum_scale_factor</code> (<code class="type">floating point</code>)
  77. <a id="id-1.6.6.13.4.7.1.3" class="indexterm"></a>
  78. </span></dt><dd><p>
  79. Specifies a fraction of the table size to add to
  80. <code class="varname">autovacuum_vacuum_threshold</code>
  81. when deciding whether to trigger a <code class="command">VACUUM</code>.
  82. The default is 0.2 (20% of table size).
  83. This parameter can only be set in the <code class="filename">postgresql.conf</code>
  84. file or on the server command line;
  85. but the setting can be overridden for individual tables by
  86. changing table storage parameters.
  87. </p></dd><dt id="GUC-AUTOVACUUM-ANALYZE-SCALE-FACTOR"><span class="term"><code class="varname">autovacuum_analyze_scale_factor</code> (<code class="type">floating point</code>)
  88. <a id="id-1.6.6.13.4.8.1.3" class="indexterm"></a>
  89. </span></dt><dd><p>
  90. Specifies a fraction of the table size to add to
  91. <code class="varname">autovacuum_analyze_threshold</code>
  92. when deciding whether to trigger an <code class="command">ANALYZE</code>.
  93. The default is 0.1 (10% of table size).
  94. This parameter can only be set in the <code class="filename">postgresql.conf</code>
  95. file or on the server command line;
  96. but the setting can be overridden for individual tables by
  97. changing table storage parameters.
  98. </p></dd><dt id="GUC-AUTOVACUUM-FREEZE-MAX-AGE"><span class="term"><code class="varname">autovacuum_freeze_max_age</code> (<code class="type">integer</code>)
  99. <a id="id-1.6.6.13.4.9.1.3" class="indexterm"></a>
  100. </span></dt><dd><p>
  101. Specifies the maximum age (in transactions) that a table's
  102. <code class="structname">pg_class</code>.<code class="structfield">relfrozenxid</code> field can
  103. attain before a <code class="command">VACUUM</code> operation is forced
  104. to prevent transaction ID wraparound within the table.
  105. Note that the system will launch autovacuum processes to
  106. prevent wraparound even when autovacuum is otherwise disabled.
  107. </p><p>
  108. Vacuum also allows removal of old files from the
  109. <code class="filename">pg_xact</code> subdirectory, which is why the default
  110. is a relatively low 200 million transactions.
  111. This parameter can only be set at server start, but the setting
  112. can be reduced for individual tables by
  113. changing table storage parameters.
  114. For more information see <a class="xref" href="routine-vacuuming.html#VACUUM-FOR-WRAPAROUND" title="24.1.5. Preventing Transaction ID Wraparound Failures">Section 24.1.5</a>.
  115. </p></dd><dt id="GUC-AUTOVACUUM-MULTIXACT-FREEZE-MAX-AGE"><span class="term"><code class="varname">autovacuum_multixact_freeze_max_age</code> (<code class="type">integer</code>)
  116. <a id="id-1.6.6.13.4.10.1.3" class="indexterm"></a>
  117. </span></dt><dd><p>
  118. Specifies the maximum age (in multixacts) that a table's
  119. <code class="structname">pg_class</code>.<code class="structfield">relminmxid</code> field can
  120. attain before a <code class="command">VACUUM</code> operation is forced to
  121. prevent multixact ID wraparound within the table.
  122. Note that the system will launch autovacuum processes to
  123. prevent wraparound even when autovacuum is otherwise disabled.
  124. </p><p>
  125. Vacuuming multixacts also allows removal of old files from the
  126. <code class="filename">pg_multixact/members</code> and <code class="filename">pg_multixact/offsets</code>
  127. subdirectories, which is why the default is a relatively low
  128. 400 million multixacts.
  129. This parameter can only be set at server start, but the setting can
  130. be reduced for individual tables by changing table storage parameters.
  131. For more information see <a class="xref" href="routine-vacuuming.html#VACUUM-FOR-MULTIXACT-WRAPAROUND" title="24.1.5.1. Multixacts and Wraparound">Section 24.1.5.1</a>.
  132. </p></dd><dt id="GUC-AUTOVACUUM-VACUUM-COST-DELAY"><span class="term"><code class="varname">autovacuum_vacuum_cost_delay</code> (<code class="type">floating point</code>)
  133. <a id="id-1.6.6.13.4.11.1.3" class="indexterm"></a>
  134. </span></dt><dd><p>
  135. Specifies the cost delay value that will be used in automatic
  136. <code class="command">VACUUM</code> operations. If -1 is specified, the regular
  137. <a class="xref" href="runtime-config-resource.html#GUC-VACUUM-COST-DELAY">vacuum_cost_delay</a> value will be used.
  138. If this value is specified without units, it is taken as milliseconds.
  139. The default value is 2 milliseconds.
  140. This parameter can only be set in the <code class="filename">postgresql.conf</code>
  141. file or on the server command line;
  142. but the setting can be overridden for individual tables by
  143. changing table storage parameters.
  144. </p></dd><dt id="GUC-AUTOVACUUM-VACUUM-COST-LIMIT"><span class="term"><code class="varname">autovacuum_vacuum_cost_limit</code> (<code class="type">integer</code>)
  145. <a id="id-1.6.6.13.4.12.1.3" class="indexterm"></a>
  146. </span></dt><dd><p>
  147. Specifies the cost limit value that will be used in automatic
  148. <code class="command">VACUUM</code> operations. If -1 is specified (which is the
  149. default), the regular
  150. <a class="xref" href="runtime-config-resource.html#GUC-VACUUM-COST-LIMIT">vacuum_cost_limit</a> value will be used. Note that
  151. the value is distributed proportionally among the running autovacuum
  152. workers, if there is more than one, so that the sum of the limits for
  153. each worker does not exceed the value of this variable.
  154. This parameter can only be set in the <code class="filename">postgresql.conf</code>
  155. file or on the server command line;
  156. but the setting can be overridden for individual tables by
  157. changing table storage parameters.
  158. </p></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="runtime-config-statistics.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="runtime-config.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="runtime-config-client.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">19.9. Run-time Statistics </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 19.11. Client Connection Defaults</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1