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

Commit335904b

Browse files
committed
Improve the documentation on 8.4 visibility map related VACUUM changes.
Explain how vacuum_freeze_table_age should be tuned, and how it relatesto the other settings. Mention that vacuum_freeze_table_age also affectswhen autovacuum scans the whole table.
1 parent283939a commit335904b

File tree

1 file changed

+51
-29
lines changed

1 file changed

+51
-29
lines changed

‎doc/src/sgml/maintenance.sgml

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.92 2009/04/06 17:56:31 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.93 2009/04/23 10:09:11 heikki Exp $ -->
22

33
<chapter id="maintenance">
44
<title>Routine Database Maintenance Tasks</title>
@@ -375,14 +375,21 @@
375375
</para>
376376

377377
<para>
378-
<command>VACUUM</>'s behavior is controlled by the two configuration
379-
parameters: <xref linkend="guc-vacuum-freeze-min-age"> and
380-
<xref linkend="guc-vacuum-freeze-table-age">.
381-
<varname>vacuum_freeze_table_age</> controls when <command>VACUUM</>
382-
performs a full sweep of the table, in order to replace old XID values
383-
with <literal>FrozenXID</>. <varname>vacuum_freeze_min_age</>
378+
<command>VACUUM</> normally skips pages that don't have any dead row
379+
versions, but those pages might still have tuples with old XID values.
380+
To replace them too, a scan of the whole table is needed.
381+
<xref linkend="guc-vacuum-freeze-table-age"> controls when
382+
<command>VACUUM</> does that: a whole table sweep is forced if
383+
the table hasn't been fully scanned for <varname>vacuum_freeze_table_age</>
384+
- <varname>vacuum_freeze_min_age</> transactions. Setting it to 0
385+
makes <command>VACUUM</> to ignore the visibility map and always scan all
386+
pages.
387+
</para>
388+
389+
<para>
390+
<xref linkend="guc-vacuum-freeze-min-age">
384391
controls how old an XID value has to be before it's replaced with
385-
<literal>FrozenXID</>. Larger values ofthese settings
392+
<literal>FrozenXID</>. Larger values ofthis setting
386393
preserve transactional information longer, while smaller values increase
387394
the number of transactions that can elapse before the table must be
388395
vacuumed again.
@@ -416,18 +423,34 @@
416423
</para>
417424

418425
<para>
419-
The sole disadvantage of increasing <varname>vacuum_freeze_table_age</>
420-
and <varname>autovacuum_freeze_max_age</>
426+
The effective maximum for <varname>vacuum_table_age</> is 0.95 *
427+
<varname>autovacuum_freeze_max_age</>; a setting higher than that will be
428+
capped to that maximum. A value higher than
429+
<varname>autovacuum_freeze_max_age</> wouldn't make sense because an
430+
anti-wraparound autovacuum would be triggered at that point anyway, and
431+
the 0.95 multiplier leaves some breathing room to run a manual
432+
<command>VACUUM</> before that happens. As a rule of thumb,
433+
<command>vacuum_freeze_table_age</> should be set to a value somewhat
434+
below <varname>autovacuum_freeze_max_age</>, leaving enough gap so that
435+
a regularly scheduled <command>VACUUM</> or an autovacuum triggered by
436+
normal delete and update activity is run in that window. Setting it too
437+
close could lead to anti-wraparound autovacuums, even though the table
438+
was recently vacuumed to reclaim space, whereas lower values lead to more
439+
frequent whole-table scans.
440+
</para>
441+
442+
<para>
443+
The sole disadvantage of increasing <varname>autovacuum_freeze_max_age</>
444+
(and <varname>vacuum_freeze_table_age</> along with it)
421445
is that the <filename>pg_clog</> subdirectory of the database cluster
422446
will take more space, because it must store the commit status for all
423447
transactions back to the <varname>autovacuum_freeze_max_age</> horizon.
424448
The commit status uses two bits per transaction, so if
425449
<varname>autovacuum_freeze_max_age</> has its maximum allowed value of
426450
a little less than two billion, <filename>pg_clog</> can be expected to
427451
grow to about half a gigabyte. If this is trivial compared to your
428-
total database size, setting <varname>autovacuum_freeze_max_age</> and
429-
<varname>vacuum_freeze_table_age</varname> to their maximum allowed values
430-
is recommended. Otherwise, set them depending
452+
total database size, setting <varname>autovacuum_freeze_max_age</> to
453+
its maximum allowed value is recommended. Otherwise, set it depending
431454
on what you are willing to allow for <filename>pg_clog</> storage.
432455
(The default, 200 million transactions, translates to about 50MB of
433456
<filename>pg_clog</> storage.)
@@ -470,24 +493,19 @@ SELECT datname, age(datfrozenxid) FROM pg_database;
470493
</programlisting>
471494

472495
The <literal>age</> column measures the number of transactions from the
473-
cutoff XID to the current transaction's XID. When <command>VACUUM</>
496+
cutoff XID to the current transaction's XID. <command>VACUUM</> normally
497+
only scans pages that have been modified since last vacuum, but
498+
<structfield>relfrozenxid</> can only be advanced when the whole table is
499+
scanned. The whole table is scanned when <structfield>relfrozenxid</> is
500+
more than <varname>vacuum_freeze_table_age</> transactions old, if
501+
<command>VACUUM FREEZE</> command is used, or if all pages happen to
502+
require vacuuming to remove dead row versions. When <command>VACUUM</>
474503
scans the whole table, after it's finished <literal>age(relfrozenxid)</>
475504
should be a little more than the <varname>vacuum_freeze_min_age</> setting
476505
that was used (more by the number of transactions started since the
477-
<command>VACUUM</> started).
478-
</para>
479-
480-
<para>
481-
<command>VACUUM</> normally only scans pages that have been modified
482-
since last vacuum, but <structfield>relfrozenxid</> can only be advanced
483-
when the whole table is scanned. The whole table is scanned when
484-
<structfield>relfrozenxid</> is more than
485-
<varname>vacuum_freeze_table_age</> transactions old, if
486-
<command>VACUUM FREEZE</> command is used, or if all pages happen to
487-
require vacuuming to remove dead row versions. If no whole-table-scanning
488-
<command>VACUUM</> is issued on the table until
489-
<varname>autovacuum_freeze_max_age</> is reached, an autovacuum will soon
490-
be forced for the table.
506+
<command>VACUUM</> started). If no whole-table-scanning <command>VACUUM</>
507+
is issued on the table until <varname>autovacuum_freeze_max_age</> is
508+
reached, an autovacuum will soon be forced for the table.
491509
</para>
492510

493511
<para>
@@ -599,7 +617,11 @@ vacuum threshold = vacuum base threshold + vacuum scale factor * number of tuple
599617
collector; it is a semi-accurate count updated by each
600618
<command>UPDATE</command> and <command>DELETE</command> operation. (It
601619
is only semi-accurate because some information might be lost under heavy
602-
load.)
620+
load.) If the <structfield>relfrozenxid</> value of the table is more
621+
than <varname>vacuum_freeze_table_age</> transactions old, the whole
622+
table is scanned to freeze old tuples and advance
623+
<structfield>relfrozenxid</>, otherwise only pages that have been modified
624+
since last vacuum are vacuumed.
603625
</para>
604626

605627
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp