1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!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>20.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 Vsnapshot" /><link rel="prev" href="runtime-config-statistics.html" title="20.9. Run-time Statistics" /><link rel="next" href="runtime-config-client.html" title="20.11. Client Connection Defaults" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">20.10. Automatic Vacuuming</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="runtime-config-statistics.html" title="20.9. Run-time Statistics">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="runtime-config.html" title="Chapter 20. Server Configuration">Up</a></td><th width="60%" align="center">Chapter 20. Server Configuration</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.7 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="runtime-config-client.html" title="20.11. Client Connection Defaults">Next</a></td></tr></table><hr /></div><div class="sect1" id="RUNTIME-CONFIG-AUTOVACUUM"><div class="titlepage"><div><div><h2 class="title" style="clear: both">20.10. Automatic Vacuuming</h2></div></div></div><a id="id-1.6.7.13.2" class="indexterm"></a><p>
These settings control the behavior of the <em class="firstterm">autovacuum</em>
feature. Refer to <a class="xref" href="routine-vacuuming.html#AUTOVACUUM" title="25.1.6. The Autovacuum Daemon">Section 25.1.6</a> for more information.
Note that many of these settings can be overridden on a per-table
basis; see <a class="xref" href="sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS" title="Storage Parameters">Storage Parameters</a>.
</p><div class="variablelist"><dl class="variablelist"><dt id="GUC-AUTOVACUUM"><span class="term"><code class="varname">autovacuum</code> (<code class="type">boolean</code>)
<a id="id-1.6.7.13.4.1.1.3" class="indexterm"></a>
</span></dt><dd><p>
Controls whether the server should run the
autovacuum launcher daemon. This is on by default; however,
<a class="xref" href="runtime-config-statistics.html#GUC-TRACK-COUNTS">track_counts</a> must also be enabled for
autovacuum to work.
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line; however, autovacuuming can be
disabled for individual tables by changing table storage parameters.
</p><p>
Note that even when this parameter is disabled, the system
will launch autovacuum processes if necessary to
prevent transaction ID wraparound. See <a class="xref" href="routine-vacuuming.html#VACUUM-FOR-WRAPAROUND" title="25.1.5. Preventing Transaction ID Wraparound Failures">Section 25.1.5</a> for more information.
</p></dd><dt id="GUC-AUTOVACUUM-MAX-WORKERS"><span class="term"><code class="varname">autovacuum_max_workers</code> (<code class="type">integer</code>)
<a id="id-1.6.7.13.4.2.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies the maximum number of autovacuum processes (other than the
autovacuum launcher) that may be running at any one time. The default
is three. This parameter can only be set at server start.
</p></dd><dt id="GUC-AUTOVACUUM-NAPTIME"><span class="term"><code class="varname">autovacuum_naptime</code> (<code class="type">integer</code>)
<a id="id-1.6.7.13.4.3.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies the minimum delay between autovacuum runs on any given
database. In each round the daemon examines the
database and issues <code class="command">VACUUM</code> and <code class="command">ANALYZE</code> commands
as needed for tables in that database.
If this value is specified without units, it is taken as seconds.
The default is one minute (<code class="literal">1min</code>).
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line.
</p></dd><dt id="GUC-AUTOVACUUM-VACUUM-THRESHOLD"><span class="term"><code class="varname">autovacuum_vacuum_threshold</code> (<code class="type">integer</code>)
<a id="id-1.6.7.13.4.4.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies the minimum number of updated or deleted tuples needed
to trigger a <code class="command">VACUUM</code> in any one table.
The default is 50 tuples.
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
</p></dd><dt id="GUC-AUTOVACUUM-VACUUM-INSERT-THRESHOLD"><span class="term"><code class="varname">autovacuum_vacuum_insert_threshold</code> (<code class="type">integer</code>)
<a id="id-1.6.7.13.4.5.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies the number of inserted tuples needed to trigger a
<code class="command">VACUUM</code> in any one table.
The default is 1000 tuples. If -1 is specified, autovacuum will not
trigger a <code class="command">VACUUM</code> operation on any tables based on
the number of inserts.
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
</p></dd><dt id="GUC-AUTOVACUUM-ANALYZE-THRESHOLD"><span class="term"><code class="varname">autovacuum_analyze_threshold</code> (<code class="type">integer</code>)
<a id="id-1.6.7.13.4.6.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies the minimum number of inserted, updated or deleted tuples
needed to trigger an <code class="command">ANALYZE</code> in any one table.
The default is 50 tuples.
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
</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>)
<a id="id-1.6.7.13.4.7.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies a fraction of the table size to add to
<code class="varname">autovacuum_vacuum_threshold</code>
when deciding whether to trigger a <code class="command">VACUUM</code>.
The default is 0.2 (20% of table size).
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
</p></dd><dt id="GUC-AUTOVACUUM-VACUUM-INSERT-SCALE-FACTOR"><span class="term"><code class="varname">autovacuum_vacuum_insert_scale_factor</code> (<code class="type">floating point</code>)
<a id="id-1.6.7.13.4.8.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies a fraction of the table size to add to
<code class="varname">autovacuum_vacuum_insert_threshold</code>
when deciding whether to trigger a <code class="command">VACUUM</code>.
The default is 0.2 (20% of table size).
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
</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>)
<a id="id-1.6.7.13.4.9.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies a fraction of the table size to add to
<code class="varname">autovacuum_analyze_threshold</code>
when deciding whether to trigger an <code class="command">ANALYZE</code>.
The default is 0.1 (10% of table size).
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
</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>)
<a id="id-1.6.7.13.4.10.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies the maximum age (in transactions) that a table's
<code class="structname">pg_class</code>.<code class="structfield">relfrozenxid</code> field can
attain before a <code class="command">VACUUM</code> operation is forced
to prevent transaction ID wraparound within the table.
Note that the system will launch autovacuum processes to
prevent wraparound even when autovacuum is otherwise disabled.
</p><p>
Vacuum also allows removal of old files from the
<code class="filename">pg_xact</code> subdirectory, which is why the default
is a relatively low 200 million transactions.
This parameter can only be set at server start, but the setting
can be reduced for individual tables by
changing table storage parameters.
For more information see <a class="xref" href="routine-vacuuming.html#VACUUM-FOR-WRAPAROUND" title="25.1.5. Preventing Transaction ID Wraparound Failures">Section 25.1.5</a>.
</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>)
<a id="id-1.6.7.13.4.11.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies the maximum age (in multixacts) that a table's
<code class="structname">pg_class</code>.<code class="structfield">relminmxid</code> field can
attain before a <code class="command">VACUUM</code> operation is forced to
prevent multixact ID wraparound within the table.
Note that the system will launch autovacuum processes to
prevent wraparound even when autovacuum is otherwise disabled.
</p><p>
Vacuuming multixacts also allows removal of old files from the
<code class="filename">pg_multixact/members</code> and <code class="filename">pg_multixact/offsets</code>
subdirectories, which is why the default is a relatively low
400 million multixacts.
This parameter can only be set at server start, but the setting can
be reduced for individual tables by changing table storage parameters.
For more information see <a class="xref" href="routine-vacuuming.html#VACUUM-FOR-MULTIXACT-WRAPAROUND" title="25.1.5.1. Multixacts and Wraparound">Section 25.1.5.1</a>.
</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>)
<a id="id-1.6.7.13.4.12.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies the cost delay value that will be used in automatic
<code class="command">VACUUM</code> operations. If -1 is specified, the regular
<a class="xref" href="runtime-config-resource.html#GUC-VACUUM-COST-DELAY">vacuum_cost_delay</a> value will be used.
If this value is specified without units, it is taken as milliseconds.
The default value is 2 milliseconds.
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
</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>)
<a id="id-1.6.7.13.4.13.1.3" class="indexterm"></a>
</span></dt><dd><p>
Specifies the cost limit value that will be used in automatic
<code class="command">VACUUM</code> operations. If -1 is specified (which is the
default), the regular
<a class="xref" href="runtime-config-resource.html#GUC-VACUUM-COST-LIMIT">vacuum_cost_limit</a> value will be used. Note that
the value is distributed proportionally among the running autovacuum
workers, if there is more than one, so that the sum of the limits for
each worker does not exceed the value of this variable.
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
</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" title="20.9. Run-time Statistics">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="runtime-config.html" title="Chapter 20. Server Configuration">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="runtime-config-client.html" title="20.11. Client Connection Defaults">Next</a></td></tr><tr><td width="40%" align="left" valign="top">20.9. Run-time Statistics </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.7 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 20.11. Client Connection Defaults</td></tr></table></div></body></html>
|