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

Commit2909419

Browse files
committed
Integrate autovacuum functionality into the backend. There's still a
few loose ends to be dealt with, but it seems to work. Alvaro Herrera,based on the contrib code by Matthew O'Connor.
1 parentf2bf2d2 commit2909419

File tree

25 files changed

+1678
-90
lines changed

25 files changed

+1678
-90
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 104 additions & 1 deletion
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.107 2005/07/07 20:39:56 tgl Exp $
3+
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.108 2005/07/14 05:13:38 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -88,6 +88,11 @@
8888
<entry>authorization identifier membership relationships</entry>
8989
</row>
9090

91+
<row>
92+
<entry><link linkend="catalog-pg-autovacuum"><structname>pg_autovacuum</structname></link></entry>
93+
<entry>per-relation autovacuum configuration parameters</entry>
94+
</row>
95+
9196
<row>
9297
<entry><link linkend="catalog-pg-cast"><structname>pg_cast</structname></link></entry>
9398
<entry>casts (data type conversions)</entry>
@@ -1102,6 +1107,104 @@
11021107
</sect1>
11031108

11041109

1110+
<sect1 id="catalog-pg-autovacuum">
1111+
<title><structname>pg_autovacuum</structname></title>
1112+
1113+
<indexterm zone="catalog-pg-autovacuum">
1114+
<primary>pg_autovacuum</primary>
1115+
</indexterm>
1116+
1117+
<para>
1118+
The catalog <structname>pg_autovacuum</structname> stores optional
1119+
per-relation configuration parameters for <quote>autovacuum</>.
1120+
If there is an entry here for a particular relation, the given
1121+
parameters will be used for autovacuuming that table. If no entry
1122+
is present, the system-wide defaults will be used.
1123+
</para>
1124+
1125+
<table>
1126+
<title><structname>pg_autovacuum</> Columns</title>
1127+
1128+
<tgroup cols=4>
1129+
<thead>
1130+
<row>
1131+
<entry>Name</entry>
1132+
<entry>Type</entry>
1133+
<entry>References</entry>
1134+
<entry>Description</entry>
1135+
</row>
1136+
</thead>
1137+
1138+
<tbody>
1139+
<row>
1140+
<entry><structfield>vacrelid</structfield></entry>
1141+
<entry><type>oid</type></entry>
1142+
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
1143+
<entry>The table this entry is for</entry>
1144+
</row>
1145+
1146+
<row>
1147+
<entry><structfield>enabled</structfield></entry>
1148+
<entry><type>bool</type></entry>
1149+
<entry></entry>
1150+
<entry>If false, this table is never autovacuumed</entry>
1151+
</row>
1152+
1153+
<row>
1154+
<entry><structfield>vac_base_thresh</structfield></entry>
1155+
<entry><type>integer</type></entry>
1156+
<entry></entry>
1157+
<entry>Minimum number of modified tuples before vacuum</entry>
1158+
</row>
1159+
1160+
<row>
1161+
<entry><structfield>vac_scale_factor</structfield></entry>
1162+
<entry><type>float4</type></entry>
1163+
<entry></entry>
1164+
<entry>Multiplier for reltuples to add to
1165+
<structfield>vac_base_thresh</></entry>
1166+
</row>
1167+
1168+
<row>
1169+
<entry><structfield>anl_base_thresh</structfield></entry>
1170+
<entry><type>integer</type></entry>
1171+
<entry></entry>
1172+
<entry>Minimum number of modified tuples before analyze</entry>
1173+
</row>
1174+
1175+
<row>
1176+
<entry><structfield>anl_scale_factor</structfield></entry>
1177+
<entry><type>float4</type></entry>
1178+
<entry></entry>
1179+
<entry>Multiplier for reltuples to add to
1180+
<structfield>anl_base_thresh</></entry>
1181+
</row>
1182+
</tbody>
1183+
</tgroup>
1184+
</table>
1185+
1186+
<para>
1187+
The autovacuum daemon will initiate a <command>VACUUM</> operation
1188+
on a particular table when the number of updated or deleted tuples
1189+
exceeds <structfield>vac_base_thresh</structfield> plus
1190+
<structfield>vac_scale_factor</structfield> times the number of
1191+
live tuples currently estimated to be in the relation.
1192+
Similarly, it will initiate an <command>ANALYZE</> operation
1193+
when the number of inserted, updated or deleted tuples
1194+
exceeds <structfield>anl_base_thresh</structfield> plus
1195+
<structfield>anl_scale_factor</structfield> times the number of
1196+
live tuples currently estimated to be in the relation.
1197+
</para>
1198+
1199+
<para>
1200+
Any of the numerical fields can contain <literal>-1</> (or indeed
1201+
any negative value) to indicate that the system-wide default should
1202+
be used for this particular value.
1203+
</para>
1204+
1205+
</sect1>
1206+
1207+
11051208
<sect1 id="catalog-pg-cast">
11061209
<title><structname>pg_cast</structname></title>
11071210

‎doc/src/sgml/runtime.sgml

Lines changed: 123 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.337 2005/07/06 14:45:12 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.338 2005/07/14 05:13:38 tgl Exp $
33
-->
44

55
<chapter Id="runtime">
@@ -3173,7 +3173,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
31733173
If on, collected statistics are zeroed out whenever the server
31743174
is restarted. If off, statistics are accumulated across server
31753175
restarts. The default is <literal>on</>. This option can only
3176-
be set at server start.
3176+
be set at server start.
31773177
</para>
31783178
</listitem>
31793179
</varlistentry>
@@ -3182,6 +3182,127 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
31823182
</sect3>
31833183
</sect2>
31843184

3185+
<sect2 id="runtime-config-autovacuum">
3186+
<title>Automatic Vacuuming</title>
3187+
3188+
<para>
3189+
Beginning in <productname>PostgreSQL</> 8.1, there is an optional server
3190+
process called the <firstterm>autovacuum daemon</>, whose purpose is
3191+
to automate the issuance of periodic <command>VACUUM</> and
3192+
<command>ANALYZE</> commands. When enabled, the autovacuum daemon
3193+
runs periodically and checks for tables that have had a large number
3194+
of updated or deleted tuples. This check uses the row-level statistics
3195+
collection facility; therefore, the autovacuum daemon cannot be used
3196+
unless <xref linkend="guc-stats-start-collector"> and
3197+
<xref linkend="guc-stats-row-level"> are set TRUE. Also, it's
3198+
important to allow a slot for the autovacuum process when choosing
3199+
the value of <xref linkend="guc-superuser-reserved-connections">.
3200+
</para>
3201+
3202+
<variablelist>
3203+
3204+
<varlistentry id="guc-autovacuum" xreflabel="autovacuum">
3205+
<term><varname>autovacuum</varname> (<type>boolean</type>)</term>
3206+
<indexterm>
3207+
<primary><varname>autovacuum</> configuration parameter</primary>
3208+
</indexterm>
3209+
<listitem>
3210+
<para>
3211+
Controls whether the server should start the
3212+
autovacuum subprocess. This is off by default.
3213+
This option can only be set at server start or in the
3214+
<filename>postgresql.conf</filename> file.
3215+
</para>
3216+
</listitem>
3217+
</varlistentry>
3218+
3219+
<varlistentry id="guc-autovacuum-naptime" xreflabel="autovacuum_naptime">
3220+
<term><varname>autovacuum_naptime</varname> (<type>integer</type>)</term>
3221+
<indexterm>
3222+
<primary><varname>autovacuum_naptime</> configuration parameter</primary>
3223+
</indexterm>
3224+
<listitem>
3225+
<para>
3226+
Specifies the delay between activity rounds for the autovacuum
3227+
subprocess. In each round the subprocess examines one database
3228+
and issues <command>VACUUM</> and <command>ANALYZE</> commands
3229+
as needed for tables in that database. The delay is measured
3230+
in seconds, and the default is 60.
3231+
This option can only be set at server start or in the
3232+
<filename>postgresql.conf</filename> file.
3233+
</para>
3234+
</listitem>
3235+
</varlistentry>
3236+
3237+
<varlistentry id="guc-autovacuum-vacuum-threshold" xreflabel="autovacuum_vacuum_threshold">
3238+
<term><varname>autovacuum_vacuum_threshold</varname> (<type>integer</type>)</term>
3239+
<indexterm>
3240+
<primary><varname>autovacuum_vacuum_threshold</> configuration parameter</primary>
3241+
</indexterm>
3242+
<listitem>
3243+
<para>
3244+
Specifies the minimum number of updated or deleted tuples needed
3245+
to trigger a <command>VACUUM</> in any one table.
3246+
The default is 1000.
3247+
This option can only be set at server start or in the
3248+
<filename>postgresql.conf</filename> file.
3249+
</para>
3250+
</listitem>
3251+
</varlistentry>
3252+
3253+
<varlistentry id="guc-autovacuum-analyze-threshold" xreflabel="autovacuum_analyze_threshold">
3254+
<term><varname>autovacuum_analyze_threshold</varname> (<type>integer</type>)</term>
3255+
<indexterm>
3256+
<primary><varname>autovacuum_analyze_threshold</> configuration parameter</primary>
3257+
</indexterm>
3258+
<listitem>
3259+
<para>
3260+
Specifies the minimum number of inserted, updated or deleted tuples
3261+
needed to trigger an <command>ANALYZE</> in any one table.
3262+
The default is 500.
3263+
This option can only be set at server start or in the
3264+
<filename>postgresql.conf</filename> file.
3265+
</para>
3266+
</listitem>
3267+
</varlistentry>
3268+
3269+
<varlistentry id="guc-autovacuum-vacuum-scale-factor" xreflabel="autovacuum_vacuum_scale_factor">
3270+
<term><varname>autovacuum_vacuum_scale_factor</varname> (<type>floating point</type>)</term>
3271+
<indexterm>
3272+
<primary><varname>autovacuum_vacuum_scale_factor</> configuration parameter</primary>
3273+
</indexterm>
3274+
<listitem>
3275+
<para>
3276+
Specifies a fraction of the table size to add to
3277+
<varname>autovacuum_vacuum_threshold</varname>
3278+
when deciding whether to trigger a <command>VACUUM</>.
3279+
The default is 0.4.
3280+
This option can only be set at server start or in the
3281+
<filename>postgresql.conf</filename> file.
3282+
</para>
3283+
</listitem>
3284+
</varlistentry>
3285+
3286+
<varlistentry id="guc-autovacuum-analyze-scale-factor" xreflabel="autovacuum_analyze_scale_factor">
3287+
<term><varname>autovacuum_analyze_scale_factor</varname> (<type>floating point</type>)</term>
3288+
<indexterm>
3289+
<primary><varname>autovacuum_analyze_scale_factor</> configuration parameter</primary>
3290+
</indexterm>
3291+
<listitem>
3292+
<para>
3293+
Specifies a fraction of the table size to add to
3294+
<varname>autovacuum_analyze_threshold</varname>
3295+
when deciding whether to trigger an <command>ANALYZE</>.
3296+
The default is 0.2.
3297+
This option can only be set at server start or in the
3298+
<filename>postgresql.conf</filename> file.
3299+
</para>
3300+
</listitem>
3301+
</varlistentry>
3302+
3303+
</variablelist>
3304+
</sect2>
3305+
31853306
<sect2 id="runtime-config-client">
31863307
<title>Client Connection Defaults</title>
31873308

‎src/backend/catalog/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for backend/catalog
44
#
5-
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.55 2005/07/07 20:39:57 tgl Exp $
5+
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.56 2005/07/14 05:13:39 tgl Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -27,7 +27,7 @@ SUBSYS.o: $(OBJS)
2727
# indexing.h had better be last.
2828

2929
POSTGRES_BKI_SRCS :=$(addprefix$(top_srcdir)/src/include/catalog/,\
30-
pg_proc.h pg_type.h pg_attribute.h pg_class.h \
30+
pg_proc.h pg_type.h pg_attribute.h pg_class.hpg_autovacuum.h\
3131
pg_attrdef.h pg_constraint.h pg_inherits.h pg_index.h \
3232
pg_operator.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \
3333
pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp