Significant improvements to the documentation for the new cost-based

vacuum delay feature, including updating the docs for Tom's recent
improvements. There is still more work to be done here: for example,
adding some more information on the practical use of cost-based
vacuum delay to the "maintenance" section would probably be a good
idea.
This commit is contained in:
Neil Conway 2004-02-17 06:28:05 +00:00
parent 11acc1ffd6
commit ee33fe889e
1 changed files with 95 additions and 71 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.239 2004/02/17 05:45:17 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.240 2004/02/17 06:28:05 neilc Exp $
--> -->
<Chapter Id="runtime"> <Chapter Id="runtime">
@ -992,27 +992,47 @@ SET ENABLE_SEQSCAN TO OFF;
</sect3> </sect3>
<sect3 id="runtime-config-resource-vacuum-cost"> <sect3 id="runtime-config-resource-vacuum-cost">
<title>Cost Based Vacuum Delay</title> <title>Cost-Based Vacuum Delay</title>
<para>
During the execution of <command>VACUUM</command>,
<command>VACUUM FULL</command> and <command>ANALYZE</command>,
the system mantains an internal counter that keeps track of the
cost of the various I/O operations that are performed. When the
accumulated cost reaches a limit
(specified by <varname>vacuum_cost_limit</varname>), the backend performing
the operation will sleep for a while (specified by
<varname>vacuum_cost_naptime</varname>). Then it will reset the
counter and continue execution.
</para>
<para>
The intent of this feature is to allow administrators the reduce
the I/O impact of these commands on concurrent database
activity. There are some situations in which it is not very
important that maintainence commands like
<command>VACUUM</command> and <command>ANALYZE</command> finish
quickly; however, it is usually very important these these
commands do not significantly interfere with the ability of the
system to perform other database operations. Cost-based vacuum
delay provides a way for administrators to achieve this.
</para>
<para>
This feature is disabled by default. To enable it, set the
<varname>vacuum_cost_naptime</varname> variable to a reasonable
value.
</para>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><varname>vacuum_cost_page_hit</varname> (<type>integer</type>)</term> <term><varname>vacuum_cost_page_hit</varname> (<type>integer</type>)</term>
<listitem> <listitem>
<para> <para>
During a default <command>VACUUM</command> (not The cost for vacuuming a buffer found in the shared buffer
<command>FULL</command>) the system maintains and internal counter cache. It represents the cost to lock the buffer pool, lookup
accumulating the cost of various operations performed. When the the shared hash table and scan the content of the page. The
accumulated cost reaches a limit, the backend performing the default value is 1.
<command>VACUUM</command> will sleep for a while, reset the
accumulator and continue. The intention is to lower the IO impact
of <command>VACUUM</command>.
</para>
<para>
The variable <varname>vacuum_cost_page_hit</varname> is the cost
for vacuuming a buffer found inside the shared buffer cache.
It represents the cost to lock the buffer pool, lookup the
shared hash table and to actually scan the block content.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -1021,10 +1041,10 @@ SET ENABLE_SEQSCAN TO OFF;
<term><varname>vacuum_cost_page_miss</varname> (<type>integer</type>)</term> <term><varname>vacuum_cost_page_miss</varname> (<type>integer</type>)</term>
<listitem> <listitem>
<para> <para>
The cost for vacuuming a buffer that has to be read from disk. The cost for vacuuming a buffer that has to be read from
This represents the effort to lock the buffer pool, lookup the disk. This represents the effort to lock the buffer pool,
cache directory, reading the block from disk and scanning the lookup the shared hash table, read the desired block in from
content. the disk and scan its content. The default value is 10.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -1033,9 +1053,10 @@ SET ENABLE_SEQSCAN TO OFF;
<term><varname>vacuum_cost_page_dirty</varname> (<type>integer</type>)</term> <term><varname>vacuum_cost_page_dirty</varname> (<type>integer</type>)</term>
<listitem> <listitem>
<para> <para>
This extra cost is added when vacuum modifies a block that was The extra cost added when vacuum modifies a block that was
clean before. It represents the extra IO required to flush the previously clean. It represents the extra I/O required to
dirty block out to disk again. flush the dirty block out to disk again. The default value is
20.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -1044,8 +1065,8 @@ SET ENABLE_SEQSCAN TO OFF;
<term><varname>vacuum_cost_limit</varname> (<type>integer</type>)</term> <term><varname>vacuum_cost_limit</varname> (<type>integer</type>)</term>
<listitem> <listitem>
<para> <para>
This is the cost limit that must be reached or exceeded before The accumulated cost that will cause the backend to briefly
the <command>VACUUM</command> will nap. nap. The default value is 200.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -1054,21 +1075,24 @@ SET ENABLE_SEQSCAN TO OFF;
<term><varname>vacuum_cost_naptime</varname> (<type>integer</type>)</term> <term><varname>vacuum_cost_naptime</varname> (<type>integer</type>)</term>
<listitem> <listitem>
<para> <para>
The time im milliseconds the <command>VACUUM</command> will The length of time in milliseconds that a backend will nap
nap when the cost limit has been reached or exceeded. when the cost limit has been exceeded. There are certain bulk
There are certain bulk operations that hold critical operations that hold critical locks and should therefore
locks and should therefore perform complete as quickly as possible. Because of that it is
as quickly as possible. Because of that it is possible that the possible that the cost actually accumulates far higher than
cost actually accumulates far higher than this limit. To compensate this limit. To compensate for this, the final naptime is
for this, the final naptime is calculated as calculated as <varname>vacuum_cost_naptime</varname> *
<varname>vacuum_cost_naptime</varname> *
<varname>accumulated_balance</varname> / <varname>accumulated_balance</varname> /
<varname>vacuum_cost_limit</varname> with a maximum of <varname>vacuum_cost_limit</varname> with a maximum of
<varname>vacuum_cost_naptime</varname> * 4. <varname>vacuum_cost_naptime</varname> * 4.
</para> </para>
<para>
The default value is 0, which disables the cost-based vacuum
delay feature.
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</sect3> </sect3>
</sect2> </sect2>