summaryrefslogtreecommitdiff
path: root/portal/files/documentation/books/aw_pgsql/node110.html
blob: bc2bc94fe93d0db43c76be9707b1d22dc324d9c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.1p1 release (March 2nd, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>VACUUM</TITLE>
<META NAME="description" CONTENT="VACUUM">
<META NAME="keywords" CONTENT="15467">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="15467.css">
<LINK REL="next" HREF="node111.html">
<LINK REL="previous" HREF="node109.html">
<LINK REL="up" HREF="node106.html">
<LINK REL="next" HREF="node111.html">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#A00000" ALINK="#0000FF">
<!--Navigation Panel-->
<A NAME="tex2html3105"
 HREF="node111.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
 SRC="next_motif.gif"></A> 
<A NAME="tex2html3101"
 HREF="node106.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
 SRC="up_motif.gif"></A> 
<A NAME="tex2html3095"
 HREF="node109.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
 SRC="previous_motif.gif"></A> 
<A NAME="tex2html3103"
 HREF="node3.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
 SRC="contents_motif.gif"></A> 
<A NAME="tex2html3104"
 HREF="node288.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
 SRC="index_motif.gif"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html3106"
 HREF="node111.html">VACUUM ANALYZE</A>
<B> Up:</B> <A NAME="tex2html3102"
 HREF="node106.html">Performance</A>
<B> Previous:</B> <A NAME="tex2html3096"
 HREF="node109.html">CLUSTER</A>
<BR>
<BR>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION001940000000000000000">&#160;</A><A NAME="23462">&#160;</A>
<BR>
V<SMALL>ACUUM</SMALL>
</H1>

<P>
<A NAME="vacuum_section">&#160;</A>When P<SMALL>OSTGRE</SMALL>SQL updates a row, it
keeps the original copy of the row in the table file and writes a
new one. The original row, marked as expired, is used by other transactions
still viewing the database in its prior state. Deletions are similarly
marked as expired, but not removed from the table file.

<P>
The <SMALL>VACUUM</SMALL> command removes expired rows from the file. In
the process, it moves rows from the end of the table into the expired
spots, thereby compacting the table file. 

<P>
You should run <SMALL>VACUUM</SMALL> periodically to clean out expired rows.
For tables that are heavily modified, it is useful to run <SMALL>VACUUM</SMALL>
every night in an automated manner. For tables with few modifications,
<SMALL>VACUUM</SMALL> should be run less frequently. The command exclusively
locks the table while processing.

<P>
You can run <SMALL>VACUUM</SMALL> in two ways. Using <SMALL>VACUUM</SMALL>
alone vacuums all tables in the database. Using <SMALL>VACUUM</SMALL> <EM>tablename</EM>
vacuums a single table.

<P>
<BR>
<ADDRESS>
<I>Bruce Momjian</I>
<BR><I>2002-01-08</I>
</ADDRESS>
</BODY>
</HTML>