]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/vacuum.sgml
Add proofreader's changes to docs.
[postgresql] / doc / src / sgml / ref / vacuum.sgml
1 <!--
2 $Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuum.sgml,v 1.11 2000/10/05 19:48:19 momjian Exp $
3 Postgres documentation
4 -->
5
6 <refentry id="SQL-VACUUM">
7  <refmeta>
8   <refentrytitle id="sql-vacuum-title">
9    VACUUM
10   </refentrytitle>
11   <refmiscinfo>SQL - Language Statements</refmiscinfo>
12  </refmeta>
13  <refnamediv>
14   <refname>
15    VACUUM
16   </refname>
17   <refpurpose>
18    Clean and analyze a <productname>Postgres</productname> database
19   </refpurpose>
20  </refnamediv>
21  <refsynopsisdiv>
22   <refsynopsisdivinfo>
23    <date>1999-07-20</date>
24   </refsynopsisdivinfo>
25   <synopsis>
26 VACUUM [ VERBOSE ] [ ANALYZE ] [ <replaceable class="PARAMETER">table</replaceable> ]
27 VACUUM [ VERBOSE ] ANALYZE [ <replaceable class="PARAMETER">table</replaceable> [ (<replaceable class="PARAMETER">column</replaceable> [, ...] ) ] ]
28   </synopsis>
29
30   <refsect2 id="R2-SQL-VACUUM-1">
31    <refsect2info>
32     <date>1998-10-04</date>
33    </refsect2info>
34    <title>
35     Inputs
36    </title>
37
38    <para>
39     <variablelist>
40      <varlistentry>
41       <term>VERBOSE</term>
42       <listitem>
43        <para>
44         Prints a detailed vacuum activity report for each table.
45        </para>
46       </listitem>
47      </varlistentry>
48      <varlistentry>
49       <term>ANALYZE</term>
50       <listitem>
51        <para>
52         Updates column statistics used by the optimizer to
53         determine the most efficient way to execute a query.
54        </para>
55       </listitem>
56      </varlistentry>
57      <varlistentry>
58       <term><replaceable class="PARAMETER">table</replaceable></term>
59       <listitem>
60        <para>
61         The name of a specific table to vacuum. Defaults to all tables.
62        </para>
63       </listitem>
64      </varlistentry>
65      <varlistentry>
66       <term><replaceable class="PARAMETER">column</replaceable></term>
67       <listitem>
68        <para>
69         The name of a specific column to analyze. Defaults to all columns.
70        </para>
71       </listitem>
72      </varlistentry>
73     </variablelist>
74    </para>
75   </refsect2>
76
77   <refsect2 id="R2-SQL-VACUUM-2">
78    <refsect2info>
79     <date>1998-10-04</date>
80    </refsect2info>
81    <title>
82     Outputs
83    </title>
84    <para>
85
86     <variablelist>
87      <varlistentry>
88       <term><computeroutput>
89 <returnvalue>VACUUM</returnvalue>
90        </computeroutput></term>
91       <listitem>
92        <para>
93         The command has been accepted and the database is being cleaned.
94        </para>
95       </listitem>
96      </varlistentry>
97
98      <varlistentry>
99       <term><computeroutput>
100 NOTICE:  --Relation <replaceable class="PARAMETER">table</replaceable>--
101        </computeroutput></term>
102       <listitem>
103        <para>
104         The report header for <replaceable class="PARAMETER">table</replaceable>.
105        </para>
106       </listitem>
107      </varlistentry>
108
109      <varlistentry>
110       <term><computeroutput>
111 NOTICE:  Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
112          Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188;
113          Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74.
114          Elapsed 0/0 sec.
115        </computeroutput></term>
116       <listitem>
117        <para>
118         The analysis for <replaceable class="PARAMETER">table</replaceable> itself.
119        </para>
120       </listitem>
121      </varlistentry>
122
123      <varlistentry>
124       <term><computeroutput>
125 NOTICE:  Index <replaceable class="PARAMETER">index</replaceable>: Pages 28;
126          Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
127        </computeroutput></term>
128       <listitem>
129        <para>
130         The analysis for an index on the target table.
131        </para>
132       </listitem>
133      </varlistentry>
134     </variablelist>
135    </para>
136   </refsect2>
137  </refsynopsisdiv>
138
139  <refsect1 id="R1-SQL-VACUUM-1">
140   <refsect1info>
141    <date>1998-10-04</date>
142   </refsect1info>
143   <title>
144    Description
145   </title>
146   <para>
147    <command>VACUUM</command> serves two purposes in 
148    <productname>Postgres</productname> as both a means to reclaim storage and
149    also a means to collect information for the optimizer.
150   </para>
151
152   <para>
153    <command>VACUUM</command> opens every class in the database,
154    cleans out records from rolled back transactions, and updates statistics in the
155    system catalogs.  The statistics maintained include the number of
156    tuples and number of pages stored in all classes.
157   </para>
158
159
160   <para>
161    <command>VACUUM ANALYZE</command> collects statistics representing the
162    dispersion of the data in each column.
163    This information is valuable when several query execution paths are possible.
164   </para>
165
166   <para>
167    Running <command>VACUUM</command>
168    periodically will increase the speed of the database in processing user queries.
169   </para>
170
171   <refsect2 id="R2-SQL-VACUUM-3">
172    <refsect2info>
173     <date>1998-10-04</date>
174    </refsect2info>
175    <title>
176     Notes
177    </title>
178    <para>
179     The open database is the target for <command>VACUUM</command>.
180    </para>
181    <para>
182     We recommend that active production databases be
183     <command>VACUUM</command>-ed nightly, in order to keep remove
184     expired rows. After copying a large class into
185     <productname>Postgres</productname> or after deleting a large number
186     of records, it may be a good idea to issue a <command>VACUUM
187     ANALYZE</command> query. This will update the system catalogs with
188     the results of all recent changes, and allow the
189     <productname>Postgres</productname> query optimizer to make better
190     choices in planning user queries.
191    </para>
192
193   </refsect2>
194  </refsect1>
195
196  <refsect1 id="R1-SQL-VACUUM-2">
197   <title>
198    Usage
199   </title>
200   <para>
201    The following is an example from running <command>VACUUM</command> on a table
202    in the regression database:
203
204    <programlisting>
205 regression=> vacuum verbose analyze onek;
206 NOTICE:  --Relation onek--
207 NOTICE:  Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
208          Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188;
209          Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74.
210          Elapsed 0/0 sec.
211 NOTICE:  Index onek_stringu1: Pages 28; Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
212 NOTICE:  Index onek_hundred: Pages 12; Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
213 NOTICE:  Index onek_unique2: Pages 19; Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
214 NOTICE:  Index onek_unique1: Pages 17; Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
215 NOTICE:  Rel onek: Pages: 98 --> 25; Tuple(s) moved: 1000. Elapsed 0/1 sec.
216 NOTICE:  Index onek_stringu1: Pages 28; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
217 NOTICE:  Index onek_hundred: Pages 12; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
218 NOTICE:  Index onek_unique2: Pages 19; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
219 NOTICE:  Index onek_unique1: Pages 17; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
220 VACUUM
221    </programlisting>
222   </para>
223  </refsect1>
224
225  <refsect1 id="R1-SQL-VACUUM-3">
226   <title>
227    Compatibility
228   </title>
229
230   <refsect2 id="R2-SQL-VACUUM-4">
231    <refsect2info>
232     <date>1998-10-04</date>
233    </refsect2info>
234    <title>
235     SQL92
236    </title>
237    <para>
238     There is no <command>VACUUM</command> statement in <acronym>SQL92</acronym>.
239    </para>
240   </refsect2>
241  </refsect1>
242 </refentry>
243
244 <!-- Keep this comment at the end of the file
245 Local variables:
246 mode: sgml
247 sgml-omittag:nil
248 sgml-shorttag:t
249 sgml-minimize-attributes:nil
250 sgml-always-quote-attributes:t
251 sgml-indent-step:1
252 sgml-indent-data:t
253 sgml-parent-document:nil
254 sgml-default-dtd-file:"../reference.ced"
255 sgml-exposed-tags:nil
256 sgml-local-catalogs:"/usr/lib/sgml/catalog"
257 sgml-local-ecat-files:nil
258 End:
259 -->