File: runtime-config-wal.html

package info (click to toggle)
pgadmin3 1.4.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,796 kB
  • ctags: 10,758
  • sloc: cpp: 55,356; sh: 6,164; ansic: 1,520; makefile: 576; sql: 482; xml: 100; perl: 18
file content (211 lines) | stat: -rw-r--r-- 11,746 bytes parent folder | download
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>17.5.Write Ahead Log</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="runtime-config.html" title="Chapter17.Server Configuration">
<link rel="prev" href="runtime-config-resource.html" title="17.4.Resource Consumption">
<link rel="next" href="runtime-config-query.html" title="17.6.Query Planning">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="runtime-config-wal"></a>17.5.Write Ahead Log</h2></div></div></div>
<p>    See also <a href="wal-configuration.html" title="26.3.WAL Configuration">Section26.3, &#8220;<acronym class="acronym">WAL</acronym> Configuration&#8221;</a> for details on WAL
    tuning.
   </p>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="runtime-config-wal-settings"></a>17.5.1.Settings</h3></div></div></div>
<div class="variablelist"><dl>
<dt>
<a name="guc-fsync"></a><span class="term"><code class="varname">fsync</code> (<code class="type">boolean</code>)</span>
</dt>
<dd>
<p>        If this option is on, the <span class="productname">PostgreSQL</span> server
        will try to make sure that updates are physically written to
        disk, by issuing <code class="function">fsync()</code> system calls or various
        equivalent methods (see <a href="runtime-config-wal.html#guc-wal-sync-method">wal_sync_method</a>).
        This ensures that the database cluster can recover to a
        consistent state after an operating system or hardware crash.
       </p>
<p>        However, using <code class="varname">fsync</code> results in a
        performance penalty: when a transaction is committed,
        <span class="productname">PostgreSQL</span> must wait for the
        operating system to flush the write-ahead log to disk.  When
        <code class="varname">fsync</code> is disabled, the operating system is
        allowed to do its best in buffering, ordering, and delaying
        writes. This can result in significantly improved performance.
        However, if the system crashes, the results of the last few
        committed transactions may be lost in part or whole. In the
        worst case, unrecoverable data corruption may occur.
        (Crashes of the database software itself are <span class="emphasis"><em>not</em></span>
        a risk factor here.  Only an operating-system-level crash
        creates a risk of corruption.)
       </p>
<p>        Due to the risks involved, there is no universally correct
        setting for <code class="varname">fsync</code>. Some administrators
        always disable <code class="varname">fsync</code>, while others only
        turn it off during initial bulk data loads, where there is a clear
        restart point if something goes wrong.  Others
        always leave <code class="varname">fsync</code> enabled. The default is
        to enable <code class="varname">fsync</code>, for maximum reliability.
        If you trust your operating system, your hardware, and your
        utility company (or your battery backup), you can consider
        disabling <code class="varname">fsync</code>.
       </p>
<p>        This option can be set at server start or in the
        <code class="filename">postgresql.conf</code> file.  If you turn
        this option off, also consider turning off 
        <a href="runtime-config-wal.html#guc-full-page-writes">full_page_writes</a>.
       </p>
</dd>
<dt>
<a name="guc-wal-sync-method"></a><span class="term"><code class="varname">wal_sync_method</code> (<code class="type">string</code>)</span>
</dt>
<dd>
<p>        Method used for forcing WAL updates out to disk.
        If <code class="varname">fsync</code> is off then this setting is irrelevant,
        since updates will not be forced out at all.
        Possible values are:
       </p>
<div class="itemizedlist"><ul type="disc">
<li><p>         <code class="literal">open_datasync</code> (write WAL files with <code class="function">open()</code> option <code class="symbol">O_DSYNC</code>)
        </p></li>
<li><p>         <code class="literal">fdatasync</code> (call <code class="function">fdatasync()</code> at each commit)
        </p></li>
<li><p>         <code class="literal">fsync_writethrough</code> (call <code class="function">fsync()</code> at each commit, forcing write-through of any disk write cache)
        </p></li>
<li><p>         <code class="literal">fsync</code> (call <code class="function">fsync()</code> at each commit)
        </p></li>
<li><p>         <code class="literal">open_sync</code> (write WAL files with <code class="function">open()</code> option <code class="symbol">O_SYNC</code>)
        </p></li>
</ul></div>
<p>        Not all of these choices are available on all platforms.
        The default is the first method in the above list that is supported.
        This option can be set at server start or in the
        <code class="filename">postgresql.conf</code> file.
       </p>
</dd>
<dt>
<a name="guc-full-page-writes"></a><span class="term"><code class="varname">full_page_writes</code> (<code class="type">boolean</code>)</span>
</dt>
<dd>
<p>        When this option is on, the <span class="productname">PostgreSQL</span> server
        writes the entire content of each disk page to WAL during the
        first modification of that page after a checkpoint.
       </p>
<p>        This parameter is currently ignored (treated as always <code class="literal">on</code>)
        because turning it off can cause failure to recover from crashes
        even when no hardware or OS-level error occurred.  This will be
        fixed in some future release, or else the parameter will be removed
        entirely.
       </p>
</dd>
<dt>
<a name="guc-wal-buffers"></a><span class="term"><code class="varname">wal_buffers</code> (<code class="type">integer</code>)</span>
</dt>
<dd>
<p>        Number of disk-page buffers allocated in shared memory for WAL data.
        The default is 8.  The setting need only be large enough to hold
        the amount of WAL data generated by one typical transaction, since
        the data is written out to disk at every transaction commit.
        This option can only be set at server start.
       </p>
<p>        Increasing this parameter may cause <span class="productname">PostgreSQL</span>
        to request more <span class="systemitem">System V</span> shared
        memory than your operating system's default configuration
        allows. See <a href="kernel-resources.html#sysvipc" title="16.4.1.Shared Memory and Semaphores">Section16.4.1, &#8220;Shared Memory and Semaphores&#8221;</a> for information on how to
        adjust those parameters, if necessary.
       </p>
</dd>
<dt>
<a name="guc-commit-delay"></a><span class="term"><code class="varname">commit_delay</code> (<code class="type">integer</code>)</span>
</dt>
<dd><p>        Time delay between writing a commit record to the WAL buffer
        and flushing the buffer out to disk, in microseconds. A
        nonzero delay can allow multiple transactions to be committed
        with only one <code class="function">fsync()</code> system call, if
        system load is high enough that additional transactions become
        ready to commit within the given interval. But the delay is
        just wasted if no other transactions become ready to
        commit. Therefore, the delay is only performed if at least
        <code class="varname">commit_siblings</code> other transactions are
        active at the instant that a server process has written its
        commit record. The default is zero (no delay).
       </p></dd>
<dt>
<a name="guc-commit-siblings"></a><span class="term"><code class="varname">commit_siblings</code> (<code class="type">integer</code>)</span>
</dt>
<dd><p>        Minimum number of concurrent open transactions to require
        before performing the <code class="varname">commit_delay</code> delay. A larger
        value makes it more probable that at least one other
        transaction will become ready to commit during the delay
        interval. The default is five.
       </p></dd>
</dl></div>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="runtime-config-wal-checkpoints"></a>17.5.2.Checkpoints</h3></div></div></div>
<div class="variablelist"><dl>
<dt>
<a name="guc-checkpoint-segments"></a><span class="term"><code class="varname">checkpoint_segments</code> (<code class="type">integer</code>)</span>
</dt>
<dd><p>        Maximum distance between automatic WAL checkpoints, in log
        file segments (each segment is normally 16 megabytes). The
        default is three.  This option can only be set at server start
        or in the <code class="filename">postgresql.conf</code> file.
       </p></dd>
<dt>
<a name="guc-checkpoint-timeout"></a><span class="term"><code class="varname">checkpoint_timeout</code> (<code class="type">integer</code>)</span>
</dt>
<dd><p>        Maximum time between automatic WAL checkpoints, in
        seconds. The default is 300 seconds.  This option can only be
        set at server start or in the <code class="filename">postgresql.conf</code>
        file.
       </p></dd>
<dt>
<a name="guc-checkpoint-warning"></a><span class="term"><code class="varname">checkpoint_warning</code> (<code class="type">integer</code>)</span>
</dt>
<dd><p>        Write a message to the server log if checkpoints caused by
        the filling of checkpoint segment files happen closer together
        than this many seconds (which suggests that
        <code class="varname">checkpoint_segments</code> ought to be raised).  The default is
        30 seconds.  Zero disables the warning.
       </p></dd>
</dl></div>
</div>
<div class="sect2" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="runtime-config-wal-archiving"></a>17.5.3.Archiving</h3></div></div></div>
<div class="variablelist"><dl>
<dt>
<a name="guc-archive-command"></a><span class="term"><code class="varname">archive_command</code> (<code class="type">string</code>)</span>
</dt>
<dd>
<p>        The shell command to execute to archive a completed segment of
        the WAL file series. If this is an empty string (the default),
        WAL archiving is disabled. Any <code class="literal">%p</code> in the string is
        replaced by the absolute path of the file to archive, and any
        <code class="literal">%f</code> is replaced by the file name only. Use
        <code class="literal">%%</code> to embed an actual <code class="literal">%</code> character in the
        command. For more information see <a href="backup-online.html#backup-archiving-wal" title="23.3.1.Setting up WAL archiving">Section23.3.1, &#8220;Setting up WAL archiving&#8221;</a>. This option can only be set at
        server start or in the <code class="filename">postgresql.conf</code>
        file.
       </p>
<p>        It is important for the command to return a zero exit status if
        and only if it succeeds.  Examples:
</p>
<pre class="programlisting">archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
archive_command = 'copy "%p" /mnt/server/archivedir/"%f"'  # Windows</pre>
<p>
       </p>
</dd>
</dl></div>
</div>
</div></body>
</html>