Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc93912b

Browse files
committed
Document the new autovacuum daemon.
1 parent2a11a49 commitc93912b

File tree

3 files changed

+123
-22
lines changed

3 files changed

+123
-22
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.113 2005/09/08 20:07:41 tgl Exp $
3+
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.114 2005/09/13 01:51:18 alvherre Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -1137,9 +1137,14 @@
11371137
<primary>pg_autovacuum</primary>
11381138
</indexterm>
11391139

1140+
<indexterm zone="catalog-pg-autovacuum">
1141+
<primary>autovacuum</primary>
1142+
<secondary>table-specific configuration</secondary>
1143+
</indexterm>
1144+
11401145
<para>
11411146
The catalog <structname>pg_autovacuum</structname> stores optional
1142-
per-relation configuration parameters for <quote>autovacuum</>.
1147+
per-relation configuration parameters for <xref linkend="autovacuum" endterm="autovacuum-title">.
11431148
If there is an entry here for a particular relation, the given
11441149
parameters will be used for autovacuuming that table. If no entry
11451150
is present, the system-wide defaults will be used.

‎doc/src/sgml/config.sgml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.15 2005/09/12 23:09:05 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.16 2005/09/13 01:51:18 alvherre Exp $
33
-->
44
<chapter Id="runtime-config">
55
<title>Run-time Configuration</title>
@@ -2897,18 +2897,15 @@ SELECT * FROM parent WHERE key = 2400;
28972897
<sect1 id="runtime-config-autovacuum">
28982898
<title>Automatic Vacuuming</title>
28992899

2900+
<indexterm>
2901+
<primary>autovacuum</primary>
2902+
<secondary>global configuration parameters</secondary>
2903+
</indexterm>
2904+
29002905
<para>
2901-
Beginning in <productname>PostgreSQL</> 8.1, there is an optional server
2902-
process called the <firstterm>autovacuum daemon</>, whose purpose is
2903-
to automate the issuance of periodic <command>VACUUM</> and
2904-
<command>ANALYZE</> commands. When enabled, the autovacuum daemon
2905-
runs periodically and checks for tables that have had a large number
2906-
of updated or deleted tuples. This check uses the row-level statistics
2907-
collection facility; therefore, the autovacuum daemon cannot be used
2908-
unless <xref linkend="guc-stats-start-collector"> and
2909-
<xref linkend="guc-stats-row-level"> are set TRUE. Also, it's
2910-
important to allow a slot for the autovacuum process when choosing
2911-
the value of <xref linkend="guc-superuser-reserved-connections">.
2906+
These settings control the default behavior for the <firstterm>autovacuum
2907+
daemon</firstterm>. Please refer to <xref linkend="autovacuum"> for
2908+
more information.
29122909
</para>
29132910

29142911
<variablelist>
@@ -2958,6 +2955,8 @@ SELECT * FROM parent WHERE key = 2400;
29582955
The default is 1000.
29592956
This option can only be set at server start or in the
29602957
<filename>postgresql.conf</filename> file.
2958+
This setting can be overridden for individual tables by entries in
2959+
<structname>pg_autovacuum</>.
29612960
</para>
29622961
</listitem>
29632962
</varlistentry>
@@ -2974,6 +2973,8 @@ SELECT * FROM parent WHERE key = 2400;
29742973
The default is 500.
29752974
This option can only be set at server start or in the
29762975
<filename>postgresql.conf</filename> file.
2976+
This setting can be overridden for individual tables by entries in
2977+
<structname>pg_autovacuum</>.
29772978
</para>
29782979
</listitem>
29792980
</varlistentry>
@@ -2991,6 +2992,8 @@ SELECT * FROM parent WHERE key = 2400;
29912992
The default is 0.4.
29922993
This option can only be set at server start or in the
29932994
<filename>postgresql.conf</filename> file.
2995+
This setting can be overridden for individual tables by entries in
2996+
<structname>pg_autovacuum</>.
29942997
</para>
29952998
</listitem>
29962999
</varlistentry>
@@ -3008,6 +3011,8 @@ SELECT * FROM parent WHERE key = 2400;
30083011
The default is 0.2.
30093012
This option can only be set at server start or in the
30103013
<filename>postgresql.conf</filename> file.
3014+
This setting can be overridden for individual tables by entries in
3015+
<structname>pg_autovacuum</>.
30113016
</para>
30123017
</listitem>
30133018
</varlistentry>

‎doc/src/sgml/maintenance.sgml

Lines changed: 99 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.45 2005/06/22 21:14:28 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.46 2005/09/13 01:51:18 alvherre Exp $
33
-->
44

55
<chapter id="maintenance">
@@ -99,6 +99,12 @@ $PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.45 2005/06/22 21:14:28 tgl
9999
<xref linkend="runtime-config-resource-vacuum-cost">.
100100
</para>
101101

102+
<para>
103+
An automated mechanism for performing the necessary <command>VACUUM</>
104+
operations has been added in <productname>PostgreSQL</productname> 8.1.
105+
See <xref linkend="autovacuum">.
106+
</para>
107+
102108
<sect2 id="vacuum-for-space-recovery">
103109
<title>Recovering disk space</title>
104110

@@ -177,13 +183,6 @@ $PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.45 2005/06/22 21:14:28 tgl
177183
the program <filename>vacuumdb</> may be helpful.
178184
</para>
179185

180-
<tip>
181-
<para>
182-
The <filename>contrib/pg_autovacuum</> program can be useful for
183-
automating high-frequency vacuuming operations.
184-
</para>
185-
</tip>
186-
187186
<para>
188187
<command>VACUUM FULL</> is recommended for cases where you know
189188
you have deleted the majority of rows in a table, so that the
@@ -456,6 +455,98 @@ HINT: Stop the postmaster and use a standalone backend to VACUUM in "mydb".
456455
</para>
457456
</warning>
458457
</sect2>
458+
459+
<sect2 id="autovacuum">
460+
<title id="autovacuum-title">The auto-vacuum daemon</title>
461+
462+
<indexterm>
463+
<primary>autovacuum</primary>
464+
<secondary>general information</secondary>
465+
</indexterm>
466+
<para>
467+
Beginning in <productname>PostgreSQL </productname> 8.1, there is a
468+
separate optional server process called the <firstterm>autovacuum
469+
daemon</firstterm>, whose purpose is to automate the issuance of
470+
<command>VACUUM</command> and <command>ANALYZE </command> commands.
471+
When enabled, the autovacuum daemon runs periodically and checks for
472+
tables that have had a large number of inserted, updated or deleted
473+
tuples. These checks use the row-level statistics collection facility;
474+
therefore, the autovacuum daemon cannot be used unless <xref
475+
linkend="guc-stats-start-collector"> and <xref
476+
linkend="guc-stats-row-level"> are set <literal>true</literal>. Also, it's
477+
important to allow a slot for the autovacuum process when choosing the
478+
value of <xref linkend="guc-superuser-reserved-connections">.
479+
</para>
480+
481+
<para>
482+
The autovacuum daemon, when enabled, runs every <xref
483+
linkend="guc-autovacuum-naptime"> seconds and determines which database
484+
to process. Any database which is close to transaction ID wraparound
485+
is immediately processed. In this case, autovacuum issues a
486+
database-wide <command>VACUUM</command> call, or <command>VACUUM
487+
FREEZE</command> if it's a template database, and then terminates. If
488+
no database fulfills this criterion, the one that was least recently
489+
processed by autovacuum itself is chosen. In this mode, each table in
490+
the database is checked for new and obsolete tuples, according to the
491+
applicable autovacuum parameters. If a <link linkend="catalog-pg-autovacuum">
492+
<structname>pg_autovacuum</structname></link> tuple is found for this
493+
table, these settings are applied; otherwise the global values in
494+
<filename>postgresql.conf</filename> are used. See <xref linkend="runtime-config-autovacuum">
495+
for more details on the global settings.
496+
</para>
497+
498+
<para>
499+
For each table, two conditions are used to determine which operation to
500+
apply. If the number of obsolete tuples since the last
501+
<command>VACUUM</command> exceeds the <quote>vacuum threshold</quote>, the
502+
table is vacuumed and analyzed. The vacuum threshold is defined as:
503+
<programlisting>
504+
vacuum threshold = vacuum base threshold + vacuum scale factor * number of tuples
505+
</programlisting>
506+
where the vacuum base threshold is
507+
<structname>pg_autovacuum</structname>.<structfield>vac_base_thresh</structfield>,
508+
the vacuum scale factor is
509+
<structname>pg_autovacuum</structname>.<structfield>vac_scale_factor</structfield>
510+
and the number of tuples is
511+
<structname>pg_class</structname>.<structfield>reltuples</structfield>.
512+
The number of obsolete tuples is taken from the statistics
513+
collector, which is a semi-accurate count updated by each
514+
<command>UPDATE</command> and <command>DELETE</command> operation. (It
515+
is only semi-accurate because some information may be lost under heavy
516+
load.) For analyze, a similar condition is used: the threshold, calculated
517+
by an equivalent equation to that above, is compared to the number of
518+
new tuples, that is, those created by the <command>INSERT</command> and
519+
<command>COPY</command> commands.
520+
</para>
521+
522+
<para>
523+
Note that if any of the values in <structname>pg_autovacuum</structname>
524+
is set to a negative number, or if a tuple is not present at all in
525+
<structname>pg_autovacuum</structname> for any particular table, the
526+
equivalent value from <filename>postgresql.conf</filename> is used.
527+
</para>
528+
529+
<para>
530+
Besides the base threshold values and scale factors, there are three
531+
parameters that can be set for each table in <structname>pg_autovacuum</structname>:
532+
the vacuum cost delay
533+
(<structname>pg_autovacuum</structname>.<structfield>vac_cost_delay</structfield>)
534+
and the vacuum cost limit
535+
(<structname>pg_autovacuum</structname>.<structfield>vac_cost_limit</structfield>).
536+
They are used to set table-specific values for the
537+
<xref linkend="runtime-config-resource-vacuum-cost" endterm="runtime-config-resource-vacuum-cost-title">
538+
feature. The above note about negative values also applies here, but
539+
also note that if the <filename>postgresql.conf</filename> variables
540+
<varname>autovacuum_vacuum_cost_limit</varname> and
541+
<varname>autovacuum_vacuum_cost_delay</varname> are also set to negative
542+
values, the <varname>vacuum_cost_limit</varname> and
543+
<varname>vacuum_cost_delay</varname> values will be used instead.
544+
The other parameter, <structname>pg_autovacuum</>.<structfield>enabled</>,
545+
can be used to instruct the autovacuum daemon to skip any particular table
546+
by setting it to <literal>false</literal>.
547+
</para>
548+
549+
</sect2>
459550
</sect1>
460551

461552

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp