]> granicus.if.org Git - postgresql/blob - doc/src/sgml/config.sgml
Increase the default value of default_statistics_target from 10 to 100,
[postgresql] / doc / src / sgml / config.sgml
1 <!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.200 2008/12/13 19:13:43 tgl Exp $ -->
2
3 <chapter Id="runtime-config">
4   <title>Server Configuration</title>
5
6   <indexterm>
7    <primary>configuration</primary>
8    <secondary>of the server</secondary>
9   </indexterm>
10
11   <para>
12    There are many configuration parameters that affect the behavior of
13    the database system. In the first section of this chapter, we
14    describe how to set configuration parameters. The subsequent sections
15    discuss each parameter in detail.
16   </para>
17
18   <sect1 id="config-setting">
19    <title>Setting Parameters</title>
20
21    <para>
22     All parameter names are case-insensitive. Every parameter takes a
23     value of one of five types: Boolean, integer, floating point,
24     string or enum. Boolean values can be written as <literal>ON</literal>,
25     <literal>OFF</literal>, <literal>TRUE</literal>,
26     <literal>FALSE</literal>, <literal>YES</literal>,
27     <literal>NO</literal>, <literal>1</literal>, <literal>0</literal>
28     (all case-insensitive) or any unambiguous prefix of these.
29    </para>
30
31    <para>
32     Some settings specify a memory or time value.  Each of these has an
33     implicit unit, which is either kilobytes, blocks (typically eight
34     kilobytes), milliseconds, seconds, or minutes.  Default units can be
35     found by referencing <structname>pg_settings</>.<structfield>unit</>.
36     For convenience,
37     a different unit can also be specified explicitly.  Valid memory units
38     are <literal>kB</literal> (kilobytes), <literal>MB</literal>
39     (megabytes), and <literal>GB</literal> (gigabytes); valid time units
40     are <literal>ms</literal> (milliseconds), <literal>s</literal>
41     (seconds), <literal>min</literal> (minutes), <literal>h</literal>
42     (hours), and <literal>d</literal> (days).  Note that the multiplier
43     for memory units is 1024, not 1000.
44    </para>
45
46    <para>
47     Parameters of type <quote>enum</> are specified in the same way as string
48     parameters, but are restricted to a limited set of values.  The allowed
49     values can be found
50     from <structname>pg_settings</>.<structfield>enumvals</>.
51     Enum parameter values are case-insensitive.
52    </para>
53
54    <para>
55     One way to set these parameters is to edit the file
56     <filename>postgresql.conf</><indexterm><primary>postgresql.conf</></>,
57     which is normally kept in the data directory. (<application>initdb</>
58     installs a default copy there.) An example of what this file might look
59     like is:
60 <programlisting>
61 # This is a comment
62 log_connections = yes
63 log_destination = 'syslog'
64 search_path = '"$user", public'
65 shared_buffers = 128MB
66 </programlisting>
67     One parameter is specified per line. The equal sign between name and
68     value is optional. Whitespace is insignificant and blank lines are
69     ignored. Hash marks (<literal>#</literal>) introduce comments
70     anywhere.  Parameter values that are not simple identifiers or
71     numbers must be single-quoted.  To embed a single quote in a parameter
72     value, write either two quotes (preferred) or backslash-quote.
73    </para>
74
75    <para>
76     <indexterm>
77      <primary><literal>include</></primary>
78      <secondary>in configuration file</secondary>
79     </indexterm>
80     In addition to parameter settings, the <filename>postgresql.conf</>
81     file can contain <firstterm>include directives</>, which specify
82     another file to read and process as if it were inserted into the
83     configuration file at this point.  Include directives simply look like:
84 <programlisting>
85 include 'filename'
86 </programlisting>
87     If the file name is not an absolute path, it is taken as relative to
88     the directory containing the referencing configuration file.
89     Inclusions can be nested.
90    </para>
91
92    <para>
93     <indexterm>
94      <primary>SIGHUP</primary>
95     </indexterm>
96     The configuration file is reread whenever the main server process receives a
97     <systemitem>SIGHUP</> signal (which is most easily sent by means
98     of <literal>pg_ctl reload</>). The main server process
99     also propagates this signal to all currently running server
100     processes so that existing sessions also get the new
101     value. Alternatively, you can send the signal to a single server
102     process directly.  Some parameters can only be set at server start;
103     any changes to their entries in the configuration file will be ignored
104     until the server is restarted.
105    </para>
106
107    <para>
108     A second way to set these configuration parameters is to give them
109     as a command-line option to the <command>postgres</command> command, such as:
110 <programlisting>
111 postgres -c log_connections=yes -c log_destination='syslog'
112 </programlisting>
113     Command-line options override any conflicting settings in
114     <filename>postgresql.conf</filename>.  Note that this means you won't
115     be able to change the value on-the-fly by editing
116     <filename>postgresql.conf</filename>, so while the command-line
117     method might be convenient, it can cost you flexibility later.
118    </para>
119
120    <para>
121     Occasionally it is useful to give a command line option to
122     one particular session only. The environment variable
123     <envar>PGOPTIONS</envar> can be used for this purpose on the
124     client side:
125 <programlisting>
126 env PGOPTIONS='-c geqo=off' psql
127 </programlisting>
128     (This works for any <application>libpq</>-based client application, not
129     just <application>psql</application>.) Note that this won't work for
130     parameters that are fixed when the server is started or that must be
131     specified in <filename>postgresql.conf</filename>.
132    </para>
133
134    <para>
135     Furthermore, it is possible to assign a set of parameter settings to
136     a user or a database.  Whenever a session is started, the default
137     settings for the user and database involved are loaded.  The
138     commands <xref linkend="sql-alteruser" endterm="sql-alteruser-title">
139     and <xref linkend="sql-alterdatabase" endterm="sql-alterdatabase-title">,
140     respectively, are used to configure these settings.  Per-database
141     settings override anything received from the
142     <command>postgres</command> command-line or the configuration
143     file, and in turn are overridden by per-user settings; both are
144     overridden by per-session settings.
145    </para>
146
147    <para>
148     Some parameters can be changed in individual <acronym>SQL</acronym>
149     sessions with the <xref linkend="SQL-SET" endterm="SQL-SET-title">
150     command, for example:
151 <screen>
152 SET ENABLE_SEQSCAN TO OFF;
153 </screen>
154     If <command>SET</> is allowed, it overrides all other sources of
155     values for the parameter. Some parameters cannot be changed via
156     <command>SET</command>: for example, if they control behavior that
157     cannot be changed without restarting the entire
158     <productname>PostgreSQL</productname> server.  Also, some parameters can
159     be modified via <command>SET</command> or <command>ALTER</> by superusers,
160     but not by ordinary users.
161    </para>
162
163    <para>
164     The <xref linkend="SQL-SHOW" endterm="SQL-SHOW-title">
165     command allows inspection of the current values of all parameters.
166    </para>
167
168    <para>
169     The virtual table <structname>pg_settings</structname>
170     (described in <xref linkend="view-pg-settings">) also allows
171     displaying and updating session run-time parameters.  It is equivalent
172     to <command>SHOW</> and <command>SET</>, but can be more convenient
173     to use because it can be joined with other tables, or selected from using
174     any desired selection condition. It also contains more information about
175     what values are allowed for the parameters.
176    </para>
177   </sect1>
178
179    <sect1 id="runtime-config-file-locations">
180     <title>File Locations</title>
181
182      <para>
183       In addition to the <filename>postgresql.conf</filename> file
184       already mentioned, <productname>PostgreSQL</productname> uses
185       two other manually-edited configuration files, which control
186       client authentication (their use is discussed in <xref
187       linkend="client-authentication">).  By default, all three
188       configuration files are stored in the database cluster's data
189       directory.  The parameters described in this section allow the
190       configuration files to be placed elsewhere.  (Doing so can ease
191       administration.  In particular it is often easier to ensure that
192       the configuration files are properly backed-up when they are
193       kept separate.)
194      </para>
195
196      <variablelist>
197      <varlistentry id="guc-data-directory" xreflabel="data_directory">
198       <term><varname>data_directory</varname> (<type>string</type>)</term>
199       <indexterm>
200        <primary><varname>data_directory</> configuration parameter</primary>
201       </indexterm>
202       <listitem>
203        <para>
204          Specifies the directory to use for data storage.
205          This parameter can only be set at server start.
206        </para>
207       </listitem>
208      </varlistentry>
209
210      <varlistentry id="guc-config-file" xreflabel="config_file">
211       <term><varname>config_file</varname> (<type>string</type>)</term>
212       <indexterm>
213        <primary><varname>config_file</> configuration parameter</primary>
214       </indexterm>
215       <listitem>
216        <para>
217          Specifies the main server configuration file
218          (customarily called <filename>postgresql.conf</>).
219          This parameter can only be set on the <command>postgres</command> command line.
220        </para>
221       </listitem>
222      </varlistentry>
223
224      <varlistentry id="guc-hba-file" xreflabel="hba_file">
225       <term><varname>hba_file</varname> (<type>string</type>)</term>
226       <indexterm>
227        <primary><varname>hba_file</> configuration parameter</primary>
228       </indexterm>
229       <listitem>
230        <para>
231          Specifies the configuration file for host-based authentication
232          (customarily called <filename>pg_hba.conf</>).
233          This parameter can only be set at server start.
234        </para>
235       </listitem>
236      </varlistentry>
237
238      <varlistentry id="guc-ident-file" xreflabel="ident_file">
239       <term><varname>ident_file</varname> (<type>string</type>)</term>
240       <indexterm>
241        <primary><varname>ident_file</> configuration parameter</primary>
242       </indexterm>
243       <listitem>
244        <para>
245          Specifies the configuration file for
246          <application>ident</> authentication
247          (customarily called <filename>pg_ident.conf</>).
248          This parameter can only be set at server start.
249        </para>
250       </listitem>
251      </varlistentry>
252
253      <varlistentry id="guc-external-pid-file" xreflabel="external_pid_file">
254       <term><varname>external_pid_file</varname> (<type>string</type>)</term>
255       <indexterm>
256        <primary><varname>external_pid_file</> configuration parameter</primary>
257       </indexterm>
258       <listitem>
259        <para>
260         Specifies the name of an additional process-id (PID) file that the
261         server should create for use by server administration programs.
262         This parameter can only be set at server start.
263        </para>
264       </listitem>
265      </varlistentry>
266      </variablelist>
267
268      <para>
269       In a default installation, none of the above parameters are set
270       explicitly.  Instead, the
271       data directory is specified by the <option>-D</option> command-line
272       option or the <envar>PGDATA</envar> environment variable, and the
273       configuration files are all found within the data directory.
274      </para>
275
276      <para>
277       If you wish to keep the configuration files elsewhere than the
278       data directory, the <command>postgres</command> <option>-D</option>
279       command-line option or <envar>PGDATA</envar> environment variable
280       must point to the directory containing the configuration files,
281       and the <varname>data_directory</> parameter must be set in
282       <filename>postgresql.conf</filename> (or on the command line) to show
283       where the data directory is actually located.  Notice that
284       <varname>data_directory</> overrides <option>-D</option> and
285       <envar>PGDATA</envar> for the location
286       of the data directory, but not for the location of the configuration
287       files.
288      </para>
289
290      <para>
291       If you wish, you can specify the configuration file names and locations
292       individually using the parameters <varname>config_file</>,
293       <varname>hba_file</> and/or <varname>ident_file</>.
294       <varname>config_file</> can only be specified on the
295       <command>postgres</command> command line, but the others can be
296       set within the main configuration file.  If all three parameters plus
297       <varname>data_directory</> are explicitly set, then it is not necessary
298       to specify <option>-D</option> or <envar>PGDATA</envar>.
299      </para>
300
301      <para>
302       When setting any of these parameters, a relative path will be interpreted
303       with respect to the directory in which <command>postgres</command>
304       is started.
305      </para>
306    </sect1>
307
308    <sect1 id="runtime-config-connection">
309     <title>Connections and Authentication</title>
310
311     <sect2 id="runtime-config-connection-settings">
312      <title>Connection Settings</title>
313
314      <variablelist>
315
316      <varlistentry id="guc-listen-addresses" xreflabel="listen_addresses">
317       <term><varname>listen_addresses</varname> (<type>string</type>)</term>
318       <indexterm>
319        <primary><varname>listen_addresses</> configuration parameter</primary>
320       </indexterm>
321       <listitem>
322        <para>
323          Specifies the TCP/IP address(es) on which the server is
324          to listen for connections from client applications.
325          The value takes the form of a comma-separated list of host names
326          and/or numeric IP addresses.  The special entry <literal>*</>
327          corresponds to all available IP interfaces.
328          If the list is empty, the server does not listen on any IP interface
329          at all, in which case only Unix-domain sockets can be used to connect
330          to it.
331          The default value is <systemitem class="systemname">localhost</>,
332          which allows only local <quote>loopback</> connections to be made.
333          This parameter can only be set at server start.
334        </para>
335       </listitem>
336      </varlistentry>
337
338      <varlistentry id="guc-port" xreflabel="port">
339       <term><varname>port</varname> (<type>integer</type>)</term>
340       <indexterm>
341        <primary><varname>port</> configuration parameter</primary>
342       </indexterm>
343       <listitem>
344        <para>
345         The TCP port the server listens on; 5432 by default.  Note that the
346         same port number is used for all IP addresses the server listens on.
347         This parameter can only be set at server start.
348        </para>
349       </listitem>
350      </varlistentry>
351
352      <varlistentry id="guc-max-connections" xreflabel="max_connections">
353       <term><varname>max_connections</varname> (<type>integer</type>)</term>
354       <indexterm>
355        <primary><varname>max_connections</> configuration parameter</primary>
356       </indexterm>
357       <listitem>
358        <para>
359         Determines the maximum number of concurrent connections to the
360         database server. The default is typically 100 connections, but
361         might be less if your kernel settings will not support it (as
362         determined during <application>initdb</>).  This parameter can
363         only be set at server start.
364        </para>
365
366        <para>
367         Increasing this parameter might cause <productname>PostgreSQL</>
368         to request more <systemitem class="osname">System V</> shared
369         memory or semaphores than your operating system's default configuration
370         allows. See <xref linkend="sysvipc"> for information on how to
371         adjust those parameters, if necessary.
372        </para>
373       </listitem>
374      </varlistentry>
375
376      <varlistentry id="guc-superuser-reserved-connections"
377      xreflabel="superuser_reserved_connections">
378       <term><varname>superuser_reserved_connections</varname>
379       (<type>integer</type>)</term>
380       <indexterm>
381        <primary><varname>superuser_reserved_connections</> configuration parameter</primary>
382       </indexterm>
383       <listitem>
384        <para>
385         Determines the number of connection <quote>slots</quote> that
386         are reserved for connections by <productname>PostgreSQL</>
387         superusers.  At most <xref linkend="guc-max-connections">
388         connections can ever be active simultaneously.  Whenever the
389         number of active concurrent connections is at least
390         <varname>max_connections</> minus
391         <varname>superuser_reserved_connections</varname>, new
392         connections will be accepted only for superusers.
393        </para>
394
395        <para>
396         The default value is three connections. The value must be less
397         than the value of <varname>max_connections</varname>. This
398         parameter can only be set at server start.
399        </para>
400       </listitem>
401      </varlistentry>
402
403      <varlistentry id="guc-unix-socket-directory" xreflabel="unix_socket_directory">
404       <term><varname>unix_socket_directory</varname> (<type>string</type>)</term>
405       <indexterm>
406        <primary><varname>unix_socket_directory</> configuration parameter</primary>
407       </indexterm>
408       <listitem>
409        <para>
410         Specifies the directory of the Unix-domain socket on which the
411         server is to listen for
412         connections from client applications.  The default is normally
413         <filename>/tmp</filename>, but can be changed at build time.
414         This parameter can only be set at server start.
415        </para>
416       </listitem>
417      </varlistentry>
418
419      <varlistentry id="guc-unix-socket-group" xreflabel="unix_socket_group">
420       <term><varname>unix_socket_group</varname> (<type>string</type>)</term>
421       <indexterm>
422        <primary><varname>unix_socket_group</> configuration parameter</primary>
423       </indexterm>
424       <listitem>
425        <para>
426         Sets the owning group of the Unix-domain socket.  (The owning
427         user of the socket is always the user that starts the
428         server.)  In combination with the parameter
429         <varname>unix_socket_permissions</varname> this can be used as
430         an additional access control mechanism for Unix-domain connections.
431         By default this is the empty string, which selects the default
432         group for the current user.  This parameter can only be set at
433         server start.
434        </para>
435       </listitem>
436      </varlistentry>
437
438      <varlistentry id="guc-unix-socket-permissions" xreflabel="unix_socket_permissions">
439       <term><varname>unix_socket_permissions</varname> (<type>integer</type>)</term>
440       <indexterm>
441        <primary><varname>unix_socket_permissions</> configuration parameter</primary>
442       </indexterm>
443       <listitem>
444        <para>
445         Sets the access permissions of the Unix-domain socket.  Unix-domain
446         sockets use the usual Unix file system permission set.
447         The parameter value is expected to be a numeric mode
448         specification in the form accepted by the
449         <function>chmod</function> and <function>umask</function>
450         system calls.  (To use the customary octal format the number
451         must start with a <literal>0</literal> (zero).)
452        </para>
453
454        <para>
455         The default permissions are <literal>0777</literal>, meaning
456         anyone can connect. Reasonable alternatives are
457         <literal>0770</literal> (only user and group, see also
458         <varname>unix_socket_group</varname>) and <literal>0700</literal>
459         (only user). (Note that for a Unix-domain socket, only write
460         permission matters and so there is no point in setting or revoking
461         read or execute permissions.)
462        </para>
463
464        <para>
465         This access control mechanism is independent of the one
466         described in <xref linkend="client-authentication">.
467        </para>
468
469        <para>
470         This parameter can only be set at server start.
471        </para>
472       </listitem>
473      </varlistentry>
474
475      <varlistentry id="guc-bonjour-name" xreflabel="bonjour_name">
476       <term><varname>bonjour_name</varname> (<type>string</type>)</term>
477       <indexterm>
478        <primary><varname>bonjour_name</> configuration parameter</primary>
479       </indexterm>
480       <listitem>
481        <para>
482         Specifies the <productname>Bonjour</productname> broadcast
483         name.  The computer name is used if this parameter is set to the
484         empty string <literal>''</> (which is the default).  This parameter is
485         ignored if the server was not compiled with
486         <productname>Bonjour</productname> support.
487         This parameter can only be set at server start.
488        </para>
489       </listitem>
490      </varlistentry>
491
492      <varlistentry id="guc-tcp-keepalives-idle" xreflabel="tcp_keepalives_idle">
493       <term><varname>tcp_keepalives_idle</varname> (<type>integer</type>)</term>
494       <indexterm>
495        <primary><varname>tcp_keepalives_idle</> configuration parameter</primary>
496       </indexterm>
497       <listitem>
498        <para>
499         On systems that support the <symbol>TCP_KEEPIDLE</symbol> socket option, specifies the
500         number of seconds between sending keepalives on an otherwise idle
501         connection. A value of zero uses the system default. If <symbol>TCP_KEEPIDLE</symbol> is
502         not supported, this parameter must be zero. This parameter is ignored for
503         connections made via a Unix-domain socket.
504        </para>
505       </listitem>
506      </varlistentry>
507
508      <varlistentry id="guc-tcp-keepalives-interval" xreflabel="tcp_keepalives_interval">
509       <term><varname>tcp_keepalives_interval</varname> (<type>integer</type>)</term>
510       <indexterm>
511        <primary><varname>tcp_keepalives_interval</> configuration parameter</primary>
512       </indexterm>
513       <listitem>
514        <para>
515         On systems that support the <symbol>TCP_KEEPINTVL</symbol> socket option, specifies how
516         long, in seconds, to wait for a response to a keepalive before
517         retransmitting. A value of zero uses the system default. If <symbol>TCP_KEEPINTVL</symbol>
518         is not supported, this parameter must be zero. This parameter is ignored
519         for connections made via a Unix-domain socket.
520        </para>
521       </listitem>
522      </varlistentry>
523
524      <varlistentry id="guc-tcp-keepalives-count" xreflabel="tcp_keepalives_count">
525       <term><varname>tcp_keepalives_count</varname> (<type>integer</type>)</term>
526       <indexterm>
527        <primary><varname>tcp_keepalives_count</> configuration parameter</primary>
528       </indexterm>
529       <listitem>
530        <para>
531         On systems that support the <symbol>TCP_KEEPCNT</symbol> socket option, specifies how
532         many keepalives can be lost before the connection is considered dead.
533         A value of zero uses the system default. If <symbol>TCP_KEEPCNT</symbol> is not
534         supported, this parameter must be zero. This parameter is ignored
535         for connections made via a Unix-domain socket.
536        </para>
537       </listitem>
538      </varlistentry>
539
540      </variablelist>
541      </sect2>
542      <sect2 id="runtime-config-connection-security">
543      <title>Security and Authentication</title>
544
545      <variablelist>
546      <varlistentry id="guc-authentication-timeout" xreflabel="authentication_timeout">
547       <term><varname>authentication_timeout</varname> (<type>integer</type>)</term>
548       <indexterm><primary>timeout</><secondary>client authentication</></indexterm>
549       <indexterm><primary>client authentication</><secondary>timeout during</></indexterm>
550       <indexterm>
551        <primary><varname>authentication_timeout</> configuration parameter</primary>
552       </indexterm>
553
554       <listitem>
555        <para>
556         Maximum time to complete client authentication, in seconds. If a
557         would-be client has not completed the authentication protocol in
558         this much time, the server breaks the connection. This prevents
559         hung clients from occupying a connection indefinitely.
560         The default is one minute (<literal>1m</>).
561         This parameter can only be set in the <filename>postgresql.conf</>
562         file or on the server command line.
563        </para>
564       </listitem>
565      </varlistentry>
566      
567      <varlistentry id="guc-ssl" xreflabel="ssl">
568       <term><varname>ssl</varname> (<type>boolean</type>)</term>
569       <indexterm>
570        <primary><varname>ssl</> configuration parameter</primary>
571       </indexterm>
572       <listitem>
573        <para>
574         Enables <acronym>SSL</> connections. Please read
575         <xref linkend="ssl-tcp"> before using this. The default
576         is <literal>off</>. This parameter can only be set at server
577         start.  <acronym>SSL</> communication is only possible with
578         TCP/IP connections.
579        </para>
580       </listitem>
581      </varlistentry>
582
583      <varlistentry id="guc-ssl-ciphers" xreflabel="ssl_ciphers">
584       <term><varname>ssl_ciphers</varname> (<type>string</type>)</term>
585       <indexterm>
586        <primary><varname>ssl_ciphers</> configuration parameter</primary>
587       </indexterm>
588       <listitem>
589        <para>
590         Specifies a list of <acronym>SSL</> ciphers that are allowed to be
591         used on secure connections. See the <application>openssl</>
592         manual page for a list of supported ciphers.
593        </para>
594       </listitem>
595      </varlistentry>
596
597      <varlistentry id="guc-password-encryption" xreflabel="password_encryption">
598       <term><varname>password_encryption</varname> (<type>boolean</type>)</term>
599       <indexterm>
600        <primary><varname>password_encryption</> configuration parameter</primary>
601       </indexterm>
602       <listitem>
603        <para>
604         When a password is specified in <xref
605         linkend="sql-createuser" endterm="sql-createuser-title"> or
606         <xref linkend="sql-alteruser" endterm="sql-alteruser-title">
607         without writing either <literal>ENCRYPTED</> or
608         <literal>UNENCRYPTED</>, this parameter determines whether the
609         password is to be encrypted. The default is <literal>on</>
610         (encrypt the password).
611        </para>
612       </listitem>
613      </varlistentry>
614
615      <varlistentry id="guc-krb-realm" xreflabel="krb_realm">
616       <term><varname>krb_realm</varname> (<type>string</type>)</term>
617       <indexterm>
618        <primary><varname>krb_realm</> configuration parameter</primary>
619       </indexterm>
620       <listitem>
621        <para>
622         Sets the realm to match Kerberos, GSSAPI and SSPI user names against.
623         See <xref linkend="kerberos-auth">, <xref linkend="gssapi-auth"> or
624         <xref linkend="sspi-auth"> for details. This parameter can only be
625         set at server start.
626        </para>
627       </listitem>
628      </varlistentry>
629
630      <varlistentry id="guc-krb-server-keyfile" xreflabel="krb_server_keyfile">
631       <term><varname>krb_server_keyfile</varname> (<type>string</type>)</term>
632       <indexterm>
633        <primary><varname>krb_server_keyfile</> configuration parameter</primary>
634       </indexterm>
635       <listitem>
636        <para>
637         Sets the location of the Kerberos server key file. See
638         <xref linkend="kerberos-auth"> or <xref linkend="gssapi-auth"> 
639         for details. This parameter can only be set at server start.
640        </para>
641       </listitem>
642      </varlistentry>
643
644      <varlistentry id="guc-krb-srvname" xreflabel="krb_srvname">
645       <term><varname>krb_srvname</varname> (<type>string</type>)</term>
646       <indexterm>
647        <primary><varname>krb_srvname</> configuration parameter</primary>
648       </indexterm>
649       <listitem>
650        <para>
651         Sets the Kerberos service name. See <xref linkend="kerberos-auth">
652         for details.  This parameter can only be set at server start.
653        </para>
654       </listitem>
655      </varlistentry>
656
657      <varlistentry id="guc-krb-server-hostname" xreflabel="krb_server_hostname">
658       <term><varname>krb_server_hostname</varname> (<type>string</type>)</term>
659       <indexterm>
660        <primary><varname>krb_server_hostname</> configuration parameter</primary>
661       </indexterm>
662       <listitem>
663        <para>
664         Sets the host name part of the service principal.
665         This, combined with <varname>krb_srvname</>, is used to generate
666         the complete service principal, that is
667         <varname>krb_srvname</><literal>/</><varname>krb_server_hostname</><literal>@</>REALM.
668         If not set, the default is the server host name.  See <xref linkend="kerberos-auth">
669         for details.  This parameter can only be set at server start.
670        </para>
671       </listitem>
672      </varlistentry>
673
674      <varlistentry id="guc-krb-caseins-users" xreflabel="krb_caseins_users">
675       <term><varname>krb_caseins_users</varname> (<type>boolean</type>)</term>
676       <indexterm>
677        <primary><varname>krb_caseins_users</varname> configuration parameter</primary>
678       </indexterm>
679       <listitem>
680        <para>
681         Sets whether Kerberos and GSSAPI user names should be treated
682         case-insensitively.
683         The default is <literal>off</> (case sensitive). This parameter
684         can only be set at server start.
685        </para>
686       </listitem>
687      </varlistentry>
688
689      <varlistentry id="guc-db-user-namespace" xreflabel="db_user_namespace">
690       <term><varname>db_user_namespace</varname> (<type>boolean</type>)</term>
691       <indexterm>
692        <primary><varname>db_user_namespace</> configuration parameter</primary>
693       </indexterm>
694       <listitem>
695        <para>
696         This parameter enables per-database user names.  It is off by default.
697         This parameter can only be set in the <filename>postgresql.conf</>
698         file or on the server command line.
699        </para>
700
701        <para>
702         If this is on, you should create users as <literal>username@dbname</>.
703         When <literal>username</> is passed by a connecting client,
704         <literal>@</> and the database name are appended to the user
705         name and that database-specific user name is looked up by the
706         server. Note that when you create users with names containing
707         <literal>@</> within the SQL environment, you will need to
708         quote the user name.
709        </para>
710
711        <para>
712         With this parameter enabled, you can still create ordinary global
713         users.  Simply append <literal>@</> when specifying the user
714         name in the client.  The <literal>@</> will be stripped off
715         before the user name is looked up by the server.
716        </para>
717
718        <para>
719         <varname>db_user_namespace</> causes the client's and
720         server's user name representation to differ.
721         Authentication checks are always done with the server's user name
722         so authentication methods must be configured for the
723         server's user name, not the client's.  Because
724         <literal>md5</> uses the user name as salt on both the
725         client and server, <literal>md5</> cannot be used with
726         <varname>db_user_namespace</>.
727        </para>
728
729        <note>
730         <para>
731          This feature is intended as a temporary measure until a
732          complete solution is found.  At that time, this option will
733          be removed.
734         </para>
735        </note>
736       </listitem>
737      </varlistentry>
738
739     </variablelist>
740     </sect2>
741    </sect1>
742
743    <sect1 id="runtime-config-resource">
744     <title>Resource Consumption</title>
745
746     <sect2 id="runtime-config-resource-memory">
747      <title>Memory</title>
748
749      <variablelist>
750      <varlistentry id="guc-shared-buffers" xreflabel="shared_buffers">
751       <term><varname>shared_buffers</varname> (<type>integer</type>)</term>
752       <indexterm>
753        <primary><varname>shared_buffers</> configuration parameter</primary>
754       </indexterm>
755       <listitem>
756        <para>
757         Sets the amount of memory the database server uses for shared
758         memory buffers.  The default is typically 32 megabytes
759         (<literal>32MB</>), but might be less if your kernel settings will
760         not support it (as determined during <application>initdb</>).
761         This setting must be at least 128 kilobytes.  (Non-default
762         values of <symbol>BLCKSZ</symbol> change the minimum.)  However,
763         settings significantly higher than the minimum are usually needed
764         for good performance.  Several tens of megabytes are recommended
765         for production installations.  This parameter can only be set at
766         server start.
767        </para>
768
769        <para>
770         Increasing this parameter might cause <productname>PostgreSQL</>
771         to request more <systemitem class="osname">System V</> shared
772         memory than your operating system's default configuration
773         allows. See <xref linkend="sysvipc"> for information on how to
774         adjust those parameters, if necessary.
775        </para>
776       </listitem>
777      </varlistentry>
778
779      <varlistentry id="guc-temp-buffers" xreflabel="temp_buffers">
780       <term><varname>temp_buffers</varname> (<type>integer</type>)</term>
781       <indexterm>
782        <primary><varname>temp_buffers</> configuration parameter</primary>
783       </indexterm>
784       <listitem>
785        <para>
786         Sets the maximum number of temporary buffers used by each database
787         session.  These are session-local buffers used only for access to
788         temporary tables.  The default is eight megabytes
789         (<literal>8MB</>).  The setting can be changed within individual
790         sessions, but only up until the first use of temporary tables
791         within a session; subsequent attempts to change the value will
792         have no effect on that session.
793        </para>
794
795        <para>
796         A session will allocate temporary buffers as needed up to the limit
797         given by <varname>temp_buffers</>.  The cost of setting a large
798         value in sessions that do not actually need a lot of temporary
799         buffers is only a buffer descriptor, or about 64 bytes, per
800         increment in <varname>temp_buffers</>.  However if a buffer is
801         actually used an additional 8192 bytes will be consumed for it
802         (or in general, <symbol>BLCKSZ</symbol> bytes).
803        </para>
804       </listitem>
805      </varlistentry>
806
807      <varlistentry id="guc-max-prepared-transactions" xreflabel="max_prepared_transactions">
808       <term><varname>max_prepared_transactions</varname> (<type>integer</type>)</term>
809       <indexterm>
810        <primary><varname>max_prepared_transactions</> configuration parameter</primary>
811       </indexterm>
812       <listitem>
813        <para>
814         Sets the maximum number of transactions that can be in the
815         <quote>prepared</> state simultaneously (see <xref
816         linkend="sql-prepare-transaction"
817         endterm="sql-prepare-transaction-title">).
818         Setting this parameter to zero disables the prepared-transaction
819         feature.
820         The default is five transactions.
821         This parameter can only be set at server start.
822        </para>
823
824        <para>
825         If you are not using prepared transactions, this parameter may as
826         well be set to zero.  If you are using them, you will probably
827         want <varname>max_prepared_transactions</varname> to be at least
828         as large as <xref linkend="guc-max-connections">, to avoid unwanted
829         failures at the prepare step.
830        </para>
831
832        <para>
833         Increasing this parameter might cause <productname>PostgreSQL</>
834         to request more <systemitem class="osname">System V</> shared
835         memory than your operating system's default configuration
836         allows. See <xref linkend="sysvipc"> for information on how to
837         adjust those parameters, if necessary.
838        </para>
839       </listitem>
840      </varlistentry>
841
842      <varlistentry id="guc-work-mem" xreflabel="work_mem">
843       <term><varname>work_mem</varname> (<type>integer</type>)</term>
844       <indexterm>
845        <primary><varname>work_mem</> configuration parameter</primary>
846       </indexterm>
847       <listitem>
848        <para>
849         Specifies the amount of memory to be used by internal sort operations
850         and hash tables before switching to temporary disk files. The value
851         defaults to one megabyte (<literal>1MB</>).
852         Note that for a complex query, several sort or hash operations might be
853         running in parallel; each one will be allowed to use as much memory
854         as this value specifies before it starts to put data into temporary
855         files. Also, several running sessions could be doing such operations
856         concurrently.  So the total memory used could be many
857         times the value of <varname>work_mem</varname>; it is necessary to
858         keep this fact in mind when choosing the value. Sort operations are
859         used for <literal>ORDER BY</>, <literal>DISTINCT</>, and
860         merge joins.
861         Hash tables are used in hash joins, hash-based aggregation, and
862         hash-based processing of <literal>IN</> subqueries.
863        </para>
864       </listitem>
865      </varlistentry>
866
867      <varlistentry id="guc-maintenance-work-mem" xreflabel="maintenance_work_mem">
868       <term><varname>maintenance_work_mem</varname> (<type>integer</type>)</term>
869       <indexterm>
870        <primary><varname>maintenance_work_mem</> configuration parameter</primary>
871       </indexterm>
872       <listitem>
873        <para>
874         Specifies the maximum amount of memory to be used in maintenance
875         operations, such as <command>VACUUM</command>, <command>CREATE
876         INDEX</>, and <command>ALTER TABLE ADD FOREIGN KEY</>.  It defaults
877         to 16 megabytes (<literal>16MB</>).  Since only one of these
878         operations can be executed at a time by a database session, and
879         an installation normally doesn't have many of them running
880         concurrently, it's safe to set this value significantly larger
881         than <varname>work_mem</varname>.  Larger settings might improve
882         performance for vacuuming and for restoring database dumps.
883        </para>
884        <para>
885         Note that when autovacuum runs, up to
886         <xref linkend="guc-autovacuum-max-workers"> times this memory may be
887         allocated, so be careful not to set the default value too high.
888        </para>
889       </listitem>
890      </varlistentry>
891
892      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
893       <term><varname>max_stack_depth</varname> (<type>integer</type>)</term>
894       <indexterm>
895        <primary><varname>max_stack_depth</> configuration parameter</primary>
896       </indexterm>
897       <listitem>
898        <para>
899         Specifies the maximum safe depth of the server's execution stack.
900         The ideal setting for this parameter is the actual stack size limit
901         enforced by the kernel (as set by <literal>ulimit -s</> or local
902         equivalent), less a safety margin of a megabyte or so.  The safety
903         margin is needed because the stack depth is not checked in every
904         routine in the server, but only in key potentially-recursive routines
905         such as expression evaluation.  The default setting is two
906         megabytes (<literal>2MB</>), which is conservatively small and
907         unlikely to risk crashes.  However, it might be too small to allow
908         execution of complex functions.  Only superusers can change this
909         setting.
910        </para>
911
912        <para>
913         Setting <varname>max_stack_depth</> higher than
914         the actual kernel limit will mean that a runaway recursive function
915         can crash an individual backend process.  On platforms where
916         <productname>PostgreSQL</productname> can determine the kernel limit,
917         it will not let you set this variable to an unsafe value.  However,
918         not all platforms provide the information, so caution is recommended
919         in selecting a value.
920        </para>
921       </listitem>
922      </varlistentry>
923
924      </variablelist>
925      </sect2>
926
927      <sect2 id="runtime-config-resource-kernel">
928      <title>Kernel Resource Usage</title>
929      <variablelist>
930
931      <varlistentry id="guc-max-files-per-process" xreflabel="max_files_per_process">
932       <term><varname>max_files_per_process</varname> (<type>integer</type>)</term>
933       <indexterm>
934        <primary><varname>max_files_per_process</> configuration parameter</primary>
935       </indexterm>
936       <listitem>
937        <para>
938         Sets the maximum number of simultaneously open files allowed to each
939         server subprocess. The default is one thousand files. If the kernel is enforcing
940         a safe per-process limit, you don't need to worry about this setting.
941         But on some platforms (notably, most BSD systems), the kernel will
942         allow individual processes to open many more files than the system
943         can really support when a large number of processes all try to open
944         that many files. If you find yourself seeing <quote>Too many open
945         files</> failures, try reducing this setting.
946         This parameter can only be set at server start.
947        </para>
948       </listitem>
949      </varlistentry>
950      
951      <varlistentry id="guc-shared-preload-libraries" xreflabel="shared_preload_libraries">
952       <term><varname>shared_preload_libraries</varname> (<type>string</type>)</term>
953       <indexterm>
954        <primary><varname>shared_preload_libraries</> configuration parameter</primary>
955       </indexterm>
956       <listitem>
957        <para>
958         This variable specifies one or more shared libraries that are
959         to be preloaded at server start. If more than one library is to be
960         loaded, separate their names with commas. For example,
961         <literal>'$libdir/mylib'</literal> would cause
962         <literal>mylib.so</> (or on some platforms,
963         <literal>mylib.sl</>) to be preloaded from the installation's
964         standard library directory.
965         This parameter can only be set at server start.
966        </para>
967
968        <para>
969         <productname>PostgreSQL</productname> procedural language
970         libraries can be preloaded in this way, typically by using the
971         syntax <literal>'$libdir/plXXX'</literal> where
972         <literal>XXX</literal> is <literal>pgsql</>, <literal>perl</>,
973         <literal>tcl</>, or <literal>python</>.
974        </para>
975
976        <para>
977         By preloading a shared library, the library startup time is avoided
978         when the library is first used.  However, the time to start each new
979         server process might increase slightly, even if that process never
980         uses the library.  So this parameter is recommended only for
981         libraries that will be used in most sessions. 
982        </para>
983
984      <note>
985       <para>
986         On Windows hosts, preloading a library at server start will not reduce
987         the time required to start each new server process; each server process
988         will re-load all preload libraries.  However, <varname>shared_preload_libraries
989         </varname> is still useful on Windows hosts because some shared libraries may 
990         need to perform certain operations that only take place at postmaster start
991         (for example, a shared library may need to reserve lightweight locks
992         or shared memory and you can't do that after the postmaster has started).
993        </para>
994       </note>
995        <para>
996         If a specified library is not found,
997         the server will fail to start.
998        </para>
999
1000        <para>
1001         Every  PostgreSQL-supported library has a <quote>magic
1002         block</> that is checked to guarantee compatibility.  
1003         For this reason, non-PostgreSQL libraries cannot be 
1004         loaded in this way.
1005        </para>
1006       </listitem>
1007      </varlistentry>
1008
1009      </variablelist>
1010     </sect2>
1011
1012     <sect2 id="runtime-config-resource-vacuum-cost">
1013      <title id="runtime-config-resource-vacuum-cost-title">
1014        Cost-Based Vacuum Delay
1015      </title>
1016
1017      <para>
1018       During the execution of <xref linkend="sql-vacuum"
1019       endterm="sql-vacuum-title"> and <xref linkend="sql-analyze"
1020       endterm="sql-analyze-title"> commands, the system maintains an
1021       internal counter that keeps track of the estimated cost of the
1022       various I/O operations that are performed.  When the accumulated
1023       cost reaches a limit (specified by
1024       <varname>vacuum_cost_limit</varname>), the process performing
1025       the operation will sleep for a while (specified by
1026       <varname>vacuum_cost_delay</varname>). Then it will reset the
1027       counter and continue execution.
1028      </para>
1029
1030      <para>
1031       The intent of this feature is to allow administrators to reduce
1032       the I/O impact of these commands on concurrent database
1033       activity. There are many situations in which it is not very
1034       important that maintenance commands like
1035       <command>VACUUM</command> and <command>ANALYZE</command> finish
1036       quickly; however, it is usually very important that these
1037       commands do not significantly interfere with the ability of the
1038       system to perform other database operations. Cost-based vacuum
1039       delay provides a way for administrators to achieve this.
1040      </para>
1041
1042      <para>
1043       This feature is disabled by default. To enable it, set the
1044       <varname>vacuum_cost_delay</varname> variable to a nonzero
1045       value.
1046      </para>
1047
1048      <variablelist>
1049       <varlistentry id="guc-vacuum-cost-delay" xreflabel="vacuum_cost_delay">
1050        <term><varname>vacuum_cost_delay</varname> (<type>integer</type>)</term>
1051        <indexterm>
1052         <primary><varname>vacuum_cost_delay</> configuration parameter</primary>
1053        </indexterm>
1054        <listitem>
1055         <para>
1056          The length of time, in milliseconds, that the process will sleep
1057          when the cost limit has been exceeded.
1058          The default value is zero, which disables the cost-based vacuum
1059          delay feature.  Positive values enable cost-based vacuuming.
1060          Note that on many systems, the effective resolution
1061          of sleep delays is 10 milliseconds; setting
1062          <varname>vacuum_cost_delay</varname> to a value that is
1063          not a multiple of 10 might have the same results as setting it
1064          to the next higher multiple of 10.
1065         </para>
1066        </listitem>
1067       </varlistentry>
1068
1069       <varlistentry id="guc-vacuum-cost-page-hit" xreflabel="vacuum_cost_page_hit">
1070        <term><varname>vacuum_cost_page_hit</varname> (<type>integer</type>)</term>
1071        <indexterm>
1072         <primary><varname>vacuum_cost_page_hit</> configuration parameter</primary>
1073        </indexterm>
1074        <listitem>
1075         <para>
1076          The estimated cost for vacuuming a buffer found in the shared buffer
1077          cache. It represents the cost to lock the buffer pool, lookup
1078          the shared hash table and scan the content of the page. The
1079          default value is one.
1080         </para>
1081        </listitem>
1082       </varlistentry>
1083
1084       <varlistentry id="guc-vacuum-cost-page-miss" xreflabel="vacuum_cost_page_miss">
1085        <term><varname>vacuum_cost_page_miss</varname> (<type>integer</type>)</term>
1086        <indexterm>
1087         <primary><varname>vacuum_cost_page_miss</> configuration parameter</primary>
1088        </indexterm>
1089        <listitem>
1090         <para>
1091          The estimated cost for vacuuming a buffer that has to be read from
1092          disk.  This represents the effort to lock the buffer pool,
1093          lookup the shared hash table, read the desired block in from
1094          the disk and scan its content. The default value is 10.
1095         </para>
1096        </listitem>
1097       </varlistentry>
1098
1099       <varlistentry id="guc-vacuum-cost-page-dirty" xreflabel="vacuum_cost_page_dirty">
1100        <term><varname>vacuum_cost_page_dirty</varname> (<type>integer</type>)</term>
1101        <indexterm>
1102         <primary><varname>vacuum_cost_page_dirty</> configuration parameter</primary>
1103        </indexterm>
1104        <listitem>
1105         <para>
1106          The estimated cost charged when vacuum modifies a block that was
1107          previously clean. It represents the extra I/O required to
1108          flush the dirty block out to disk again. The default value is
1109          20.
1110         </para>
1111        </listitem>
1112       </varlistentry>
1113
1114       <varlistentry id="guc-vacuum-cost-limit" xreflabel="vacuum_cost_limit">
1115        <term><varname>vacuum_cost_limit</varname> (<type>integer</type>)</term>
1116        <indexterm>
1117         <primary><varname>vacuum_cost_limit</> configuration parameter</primary>
1118        </indexterm>
1119        <listitem>
1120         <para>
1121          The accumulated cost that will cause the vacuuming process to sleep.
1122          The default value is 200.
1123         </para>
1124        </listitem>
1125       </varlistentry>
1126      </variablelist>
1127
1128      <note>
1129       <para>
1130        There are certain operations that hold critical locks and should
1131        therefore complete as quickly as possible.  Cost-based vacuum
1132        delays do not occur during such operations.  Therefore it is
1133        possible that the cost accumulates far higher than the specified
1134        limit.  To avoid uselessly long delays in such cases, the actual
1135        delay is calculated as <varname>vacuum_cost_delay</varname> *
1136        <varname>accumulated_balance</varname> /
1137        <varname>vacuum_cost_limit</varname> with a maximum of
1138        <varname>vacuum_cost_delay</varname> * 4.
1139       </para>
1140      </note>
1141     </sect2>
1142
1143     <sect2 id="runtime-config-resource-background-writer">
1144      <title>Background Writer</title>
1145
1146      <para>
1147       There is a separate server
1148       process called the <firstterm>background writer</>, whose function
1149       is to issue writes of <quote>dirty</> shared buffers.  The intent is
1150       that server processes handling user queries should seldom or never have
1151       to wait for a write to occur, because the background writer will do it.
1152       However there is a net overall
1153       increase in I/O load, because a repeatedly-dirtied page might
1154       otherwise be written only once per checkpoint interval, but the
1155       background writer might write it several times in the same interval.
1156       The parameters discussed in this subsection can be used to
1157       tune the behavior for local needs.
1158      </para>
1159
1160      <variablelist>
1161       <varlistentry id="guc-bgwriter-delay" xreflabel="bgwriter_delay">
1162        <term><varname>bgwriter_delay</varname> (<type>integer</type>)</term>
1163        <indexterm>
1164         <primary><varname>bgwriter_delay</> configuration parameter</primary>
1165        </indexterm>
1166        <listitem>
1167         <para>
1168          Specifies the delay between activity rounds for the
1169          background writer.  In each round the writer issues writes
1170          for some number of dirty buffers (controllable by the
1171          following parameters).  It then sleeps for <varname>bgwriter_delay</>
1172          milliseconds, and repeats.  The default value is 200 milliseconds
1173          (<literal>200ms</>). Note that on many systems, the effective
1174          resolution of sleep delays is 10 milliseconds; setting
1175          <varname>bgwriter_delay</> to a value that is not a multiple of
1176          10 might have the same results as setting it to the next higher
1177          multiple of 10.  This parameter can only be set in the
1178          <filename>postgresql.conf</> file or on the server command line.
1179         </para>
1180        </listitem>
1181       </varlistentry>
1182
1183       <varlistentry id="guc-bgwriter-lru-maxpages" xreflabel="bgwriter_lru_maxpages">
1184        <term><varname>bgwriter_lru_maxpages</varname> (<type>integer</type>)</term>
1185        <indexterm>
1186         <primary><varname>bgwriter_lru_maxpages</> configuration parameter</primary>
1187        </indexterm>
1188        <listitem>
1189         <para>
1190          In each round, no more than this many buffers will be written
1191          by the background writer.  Setting this to zero disables
1192          background writing (except for checkpoint activity).
1193          The default value is 100 buffers.
1194          This parameter can only be set in the <filename>postgresql.conf</>
1195          file or on the server command line.
1196         </para>
1197        </listitem>
1198       </varlistentry>
1199
1200       <varlistentry id="guc-bgwriter-lru-multiplier" xreflabel="bgwriter_lru_multiplier">
1201        <term><varname>bgwriter_lru_multiplier</varname> (<type>floating point</type>)</term>
1202        <indexterm>
1203         <primary><varname>bgwriter_lru_multiplier</> configuration parameter</primary>
1204        </indexterm>
1205        <listitem>
1206         <para>
1207          The number of dirty buffers written in each round is based on the
1208          number of new buffers that have been needed by server processes
1209          during recent rounds.  The average recent need is multiplied by
1210          <varname>bgwriter_lru_multiplier</> to arrive at an estimate of the
1211          number of buffers that will be needed during the next round.  Dirty
1212          buffers are written until there are that many clean, reusable buffers
1213          available.  (However, no more than <varname>bgwriter_lru_maxpages</>
1214          buffers will be written per round.)
1215          Thus, a setting of 1.0 represents a <quote>just in time</> policy
1216          of writing exactly the number of buffers predicted to be needed.
1217          Larger values provide some cushion against spikes in demand,
1218          while smaller values intentionally leave writes to be done by
1219          server processes.
1220          The default is 2.0.
1221          This parameter can only be set in the <filename>postgresql.conf</>
1222          file or on the server command line.
1223         </para>
1224        </listitem>
1225       </varlistentry>
1226      </variablelist>
1227
1228      <para>
1229       Smaller values of <varname>bgwriter_lru_maxpages</varname> and
1230       <varname>bgwriter_lru_multiplier</varname> reduce the extra I/O load
1231       caused by the background writer, but make it more likely that server
1232       processes will have to issue writes for themselves, delaying interactive
1233       queries.
1234      </para>
1235     </sect2>
1236    </sect1>
1237
1238    <sect1 id="runtime-config-wal">
1239     <title>Write Ahead Log</title>
1240
1241    <para>
1242     See also <xref linkend="wal-configuration"> for details on WAL
1243     and checkpoint tuning.
1244    </para>
1245
1246     <sect2 id="runtime-config-wal-settings">
1247      <title>Settings</title>
1248      <variablelist>
1249      
1250      <varlistentry id="guc-fsync" xreflabel="fsync">
1251       <indexterm>
1252        <primary><varname>fsync</> configuration parameter</primary>
1253       </indexterm>
1254       <term><varname>fsync</varname> (<type>boolean</type>)</term>
1255       <listitem>
1256        <para>
1257         If this parameter is on, the <productname>PostgreSQL</> server
1258         will try to make sure that updates are physically written to
1259         disk, by issuing <function>fsync()</> system calls or various
1260         equivalent methods (see <xref linkend="guc-wal-sync-method">).
1261         This ensures that the database cluster can recover to a
1262         consistent state after an operating system or hardware crash.
1263        </para>
1264
1265        <para>
1266         However, using <varname>fsync</varname> results in a
1267         performance penalty: when a transaction is committed,
1268         <productname>PostgreSQL</productname> must wait for the
1269         operating system to flush the write-ahead log to disk.  When
1270         <varname>fsync</varname> is disabled, the operating system is
1271         allowed to do its best in buffering, ordering, and delaying
1272         writes. This can result in significantly improved performance.
1273         However, if the system crashes, the results of the last few
1274         committed transactions might be lost in part or whole. In the
1275         worst case, unrecoverable data corruption might occur.
1276         (Crashes of the database software itself are <emphasis>not</>
1277         a risk factor here.  Only an operating-system-level crash
1278         creates a risk of corruption.)
1279        </para>
1280
1281        <para>
1282         Due to the risks involved, there is no universally correct
1283         setting for <varname>fsync</varname>. Some administrators
1284         always disable <varname>fsync</varname>, while others only
1285         turn it off during initial bulk data loads, where there is a clear
1286         restart point if something goes wrong.  Others
1287         always leave <varname>fsync</varname> enabled. The default is
1288         to enable <varname>fsync</varname>, for maximum reliability.
1289         If you trust your operating system, your hardware, and your
1290         utility company (or your battery backup), you can consider
1291         disabling <varname>fsync</varname>.
1292        </para>
1293
1294        <para>
1295         In many situations, turning off <xref linkend="guc-synchronous-commit">
1296         for noncritical transactions can provide much of the potential
1297         performance benefit of turning off <varname>fsync</varname>, without
1298         the attendant risks of data corruption.
1299        </para>
1300
1301        <para>
1302         This parameter can only be set in the <filename>postgresql.conf</>
1303         file or on the server command line.
1304         If you turn this parameter off, also consider turning off 
1305         <xref linkend="guc-full-page-writes">.
1306        </para>
1307       </listitem>
1308      </varlistentry>
1309
1310      <varlistentry id="guc-synchronous-commit" xreflabel="synchronous_commit">
1311       <term><varname>synchronous_commit</varname> (<type>boolean</type>)</term>
1312       <indexterm>
1313        <primary><varname>synchronous_commit</> configuration parameter</primary>
1314       </indexterm>
1315       <listitem>
1316        <para>
1317         Specifies whether transaction commit will wait for WAL records
1318         to be written to disk before the command returns a <quote>success</>
1319         indication to the client.  The default, and safe, setting is
1320         <literal>on</>.  When <literal>off</>, there can be a delay between
1321         when success is reported to the client and when the transaction is
1322         really guaranteed to be safe against a server crash.  (The maximum
1323         delay is three times <xref linkend="guc-wal-writer-delay">.)  Unlike
1324         <xref linkend="guc-fsync">, setting this parameter to <literal>off</>
1325         does not create any risk of database inconsistency: a crash might
1326         result in some recent allegedly-committed transactions being lost, but
1327         the database state will be just the same as if those transactions had
1328         been aborted cleanly.  So, turning <varname>synchronous_commit</> off
1329         can be a useful alternative when performance is more important than
1330         exact certainty about the durability of a transaction.  For more
1331         discussion see <xref linkend="wal-async-commit">.
1332        </para>
1333        <para>
1334         This parameter can be changed at any time; the behavior for any
1335         one transaction is determined by the setting in effect when it
1336         commits.  It is therefore possible, and useful, to have some
1337         transactions commit synchronously and others asynchronously.
1338         For example, to make a single multi-statement transaction commit
1339         asynchronously when the default is the opposite, issue <command>SET
1340         LOCAL synchronous_commit TO OFF</> within the transaction.
1341        </para>
1342       </listitem>
1343      </varlistentry>
1344      
1345      <varlistentry id="guc-wal-sync-method" xreflabel="wal_sync_method">
1346       <term><varname>wal_sync_method</varname> (<type>enum</type>)</term>
1347       <indexterm>
1348        <primary><varname>wal_sync_method</> configuration parameter</primary>
1349       </indexterm>
1350       <listitem>
1351        <para>
1352         Method used for forcing WAL updates out to disk.
1353         If <varname>fsync</varname> is off then this setting is irrelevant,
1354         since updates will not be forced out at all.
1355         Possible values are:
1356        </para>
1357        <itemizedlist>
1358         <listitem>
1359         <para>
1360          <literal>open_datasync</> (write WAL files with <function>open()</> option <symbol>O_DSYNC</>)
1361         </para>
1362         </listitem>
1363         <listitem>
1364         <para>
1365          <literal>fdatasync</> (call <function>fdatasync()</> at each commit)
1366         </para>
1367         </listitem>
1368         <listitem>
1369         <para>
1370          <literal>fsync_writethrough</> (call <function>fsync()</> at each commit, forcing write-through of any disk write cache)
1371         </para>
1372         </listitem>
1373         <listitem>
1374         <para>
1375          <literal>fsync</> (call <function>fsync()</> at each commit)
1376         </para>
1377         </listitem>
1378         <listitem>
1379         <para>
1380          <literal>open_sync</> (write WAL files with <function>open()</> option <symbol>O_SYNC</>)
1381         </para>
1382         </listitem>
1383        </itemizedlist>
1384        <para>
1385         Not all of these choices are available on all platforms.
1386         The default is the first method in the above list that is supported
1387         by the platform.
1388         The <literal>open_</>* options also use <literal>O_DIRECT</> if available.
1389         This parameter can only be set in the <filename>postgresql.conf</>
1390         file or on the server command line.
1391        </para>
1392       </listitem>
1393      </varlistentry>
1394      
1395      <varlistentry id="guc-full-page-writes" xreflabel="full_page_writes">
1396       <indexterm>
1397        <primary><varname>full_page_writes</> configuration parameter</primary>
1398       </indexterm>
1399       <term><varname>full_page_writes</varname> (<type>boolean</type>)</term>
1400       <listitem>
1401        <para>
1402         When this parameter is on, the <productname>PostgreSQL</> server
1403         writes the entire content of each disk page to WAL during the
1404         first modification of that page after a checkpoint.
1405         This is needed because
1406         a page write that is in process during an operating system crash might
1407         be only partially completed, leading to an on-disk page
1408         that contains a mix of old and new data.  The row-level change data
1409         normally stored in WAL will not be enough to completely restore
1410         such a page during post-crash recovery.  Storing the full page image
1411         guarantees that the page can be correctly restored, but at a price
1412         in increasing the amount of data that must be written to WAL.
1413         (Because WAL replay always starts from a checkpoint, it is sufficient
1414         to do this during the first change of each page after a checkpoint.
1415         Therefore, one way to reduce the cost of full-page writes is to
1416         increase the checkpoint interval parameters.)
1417        </para>
1418
1419        <para>
1420         Turning this parameter off speeds normal operation, but
1421         might lead to a corrupt database after an operating system crash
1422         or power failure. The risks are similar to turning off
1423         <varname>fsync</>, though smaller.  It might be safe to turn off
1424         this parameter if you have hardware (such as a battery-backed disk
1425         controller) or file-system software that reduces
1426         the risk of partial page writes to an acceptably low level (e.g., ReiserFS 4).
1427        </para>
1428
1429        <para>
1430         Turning off this parameter does not affect use of
1431         WAL archiving for point-in-time recovery (PITR)
1432         (see <xref linkend="continuous-archiving">).
1433        </para>
1434
1435        <para>
1436         This parameter can only be set in the <filename>postgresql.conf</>
1437         file or on the server command line.
1438         The default is <literal>on</>.
1439        </para>
1440       </listitem>
1441      </varlistentry>
1442
1443      <varlistentry id="guc-wal-buffers" xreflabel="wal_buffers">
1444       <term><varname>wal_buffers</varname> (<type>integer</type>)</term>
1445       <indexterm>
1446        <primary><varname>wal_buffers</> configuration parameter</primary>
1447       </indexterm>
1448       <listitem>
1449        <para>
1450         The amount of memory used in shared memory for WAL data.  The
1451         default is 64 kilobytes (<literal>64kB</>).  The setting need only
1452         be large enough to hold the amount of WAL data generated by one
1453         typical transaction, since the data is written out to disk at
1454         every transaction commit.  This parameter can only be set at server
1455         start.
1456        </para>
1457
1458        <para>
1459         Increasing this parameter might cause <productname>PostgreSQL</>
1460         to request more <systemitem class="osname">System V</> shared
1461         memory than your operating system's default configuration
1462         allows. See <xref linkend="sysvipc"> for information on how to
1463         adjust those parameters, if necessary.
1464        </para>
1465       </listitem>
1466      </varlistentry>
1467
1468      <varlistentry id="guc-wal-writer-delay" xreflabel="wal_writer_delay">
1469       <term><varname>wal_writer_delay</varname> (<type>integer</type>)</term>
1470       <indexterm>
1471        <primary><varname>wal_writer_delay</> configuration parameter</primary>
1472       </indexterm>
1473       <listitem>
1474        <para>
1475         Specifies the delay between activity rounds for the WAL writer.
1476         In each round the writer will flush WAL to disk. It then sleeps for
1477         <varname>wal_writer_delay</> milliseconds, and repeats.  The default
1478         value is 200 milliseconds (<literal>200ms</>).  Note that on many
1479         systems, the effective resolution of sleep delays is 10 milliseconds;
1480         setting <varname>wal_writer_delay</> to a value that is not a multiple
1481         of 10 might have the same results as setting it to the next higher
1482         multiple of 10. This parameter can only be set in the
1483         <filename>postgresql.conf</> file or on the server command line.
1484        </para>
1485       </listitem>
1486      </varlistentry>
1487
1488      <varlistentry id="guc-commit-delay" xreflabel="commit_delay">
1489       <term><varname>commit_delay</varname> (<type>integer</type>)</term>
1490       <indexterm>
1491        <primary><varname>commit_delay</> configuration parameter</primary>
1492       </indexterm>
1493       <listitem>
1494        <para>
1495         Time delay between writing a commit record to the WAL buffer
1496         and flushing the buffer out to disk, in microseconds. A
1497         nonzero delay can allow multiple transactions to be committed
1498         with only one <function>fsync()</function> system call, if
1499         system load is high enough that additional transactions become
1500         ready to commit within the given interval. But the delay is
1501         just wasted if no other transactions become ready to
1502         commit. Therefore, the delay is only performed if at least
1503         <varname>commit_siblings</varname> other transactions are
1504         active at the instant that a server process has written its
1505         commit record. The default is zero (no delay).
1506        </para>
1507       </listitem>
1508      </varlistentry>
1509
1510      <varlistentry id="guc-commit-siblings" xreflabel="commit_siblings">
1511       <term><varname>commit_siblings</varname> (<type>integer</type>)</term>
1512       <indexterm>
1513        <primary><varname>commit_siblings</> configuration parameter</primary>
1514       </indexterm>
1515       <listitem>
1516        <para>
1517         Minimum number of concurrent open transactions to require
1518         before performing the <varname>commit_delay</> delay. A larger
1519         value makes it more probable that at least one other
1520         transaction will become ready to commit during the delay
1521         interval. The default is five transactions.
1522        </para>
1523       </listitem>
1524      </varlistentry>
1525
1526      </variablelist>
1527      </sect2>
1528      <sect2 id="runtime-config-wal-checkpoints">
1529      <title>Checkpoints</title>
1530
1531     <variablelist>
1532      <varlistentry id="guc-checkpoint-segments" xreflabel="checkpoint_segments">
1533       <term><varname>checkpoint_segments</varname> (<type>integer</type>)</term>
1534       <indexterm>
1535        <primary><varname>checkpoint_segments</> configuration parameter</primary>
1536       </indexterm>
1537       <listitem>
1538        <para>
1539         Maximum number of log file segments between automatic WAL
1540         checkpoints (each segment is normally 16 megabytes). The default
1541         is three segments.  Increasing this parameter can increase the
1542         amount of time needed for crash recovery.
1543         This parameter can only be set in the <filename>postgresql.conf</>
1544         file or on the server command line.
1545        </para>
1546       </listitem>
1547      </varlistentry>
1548
1549      <varlistentry id="guc-checkpoint-timeout" xreflabel="checkpoint_timeout">
1550       <term><varname>checkpoint_timeout</varname> (<type>integer</type>)</term>
1551       <indexterm>
1552        <primary><varname>checkpoint_timeout</> configuration parameter</primary>
1553       </indexterm>
1554       <listitem>
1555        <para>
1556         Maximum time between automatic WAL checkpoints, in
1557         seconds. The default is five minutes (<literal>5min</>).
1558         Increasing this parameter can increase the amount of time needed
1559         for crash recovery.
1560         This parameter can only be set in the <filename>postgresql.conf</>
1561         file or on the server command line.
1562        </para>
1563       </listitem>
1564      </varlistentry>
1565
1566      <varlistentry id="guc-checkpoint-completion-target" xreflabel="checkpoint_completion_target">
1567       <term><varname>checkpoint_completion_target</varname> (<type>floating point</type>)</term>
1568       <indexterm>
1569        <primary><varname>checkpoint_completion_target</> configuration parameter</primary>
1570       </indexterm>
1571       <listitem>
1572        <para>
1573         Specifies the target length of checkpoints, as a fraction of
1574         the checkpoint interval. The default is 0.5.
1575
1576         This parameter can only be set in the <filename>postgresql.conf</>
1577         file or on the server command line.
1578        </para>
1579       </listitem>
1580      </varlistentry>
1581
1582      <varlistentry id="guc-checkpoint-warning" xreflabel="checkpoint_warning">
1583       <term><varname>checkpoint_warning</varname> (<type>integer</type>)</term>
1584       <indexterm>
1585        <primary><varname>checkpoint_warning</> configuration parameter</primary>
1586       </indexterm>
1587       <listitem>
1588        <para>
1589         Write a message to the server log if checkpoints caused by
1590         the filling of checkpoint segment files happen closer together
1591         than this many seconds (which suggests that
1592         <varname>checkpoint_segments</> ought to be raised).  The default is
1593         30 seconds (<literal>30s</>).  Zero disables the warning.
1594         This parameter can only be set in the <filename>postgresql.conf</>
1595         file or on the server command line.
1596        </para>
1597       </listitem>
1598      </varlistentry>
1599
1600      </variablelist>
1601      </sect2>
1602      <sect2 id="runtime-config-wal-archiving">
1603      <title>Archiving</title>
1604
1605     <variablelist>
1606      <varlistentry id="guc-archive-mode" xreflabel="archive_mode">
1607       <term><varname>archive_mode</varname> (<type>boolean</type>)</term>
1608       <indexterm>
1609        <primary><varname>archive_mode</> configuration parameter</primary>
1610       </indexterm>
1611       <listitem>
1612        <para>
1613         When <varname>archive_mode</> is enabled, completed WAL segments
1614         can be sent to archive storage by setting
1615         <xref linkend="guc-archive-command">.
1616         <varname>archive_mode</> and <varname>archive_command</> are
1617         separate variables so that <varname>archive_command</> can be
1618         changed without leaving archiving mode.
1619         This parameter can only be set at server start.
1620        </para>
1621       </listitem>
1622      </varlistentry>
1623
1624      <varlistentry id="guc-archive-command" xreflabel="archive_command">
1625       <term><varname>archive_command</varname> (<type>string</type>)</term>
1626       <indexterm>
1627        <primary><varname>archive_command</> configuration parameter</primary>
1628       </indexterm>
1629       <listitem>
1630        <para>
1631         The shell command to execute to archive a completed segment of
1632         the WAL file series.  Any <literal>%p</> in the string is
1633         replaced by the path name of the file to archive, and any
1634         <literal>%f</> is replaced by the file name only.
1635         (The path name is relative to the working directory of the server,
1636         i.e., the cluster's data directory.)
1637         Use <literal>%%</> to embed an actual <literal>%</> character in the
1638         command. For more information see <xref
1639         linkend="backup-archiving-wal">.
1640         This parameter can only be set in the <filename>postgresql.conf</>
1641         file or on the server command line.  It is ignored unless
1642         <varname>archive_mode</> was enabled at server start.
1643         If <varname>archive_command</> is an empty string (the default) while
1644         <varname>archive_mode</> is enabled, then WAL archiving is temporarily
1645         disabled, but the server continues to accumulate WAL segment files in
1646         the expectation that a command will soon be provided.
1647        </para>
1648        <para>
1649         It is important for the command to return a zero exit status if
1650         and only if it succeeds.  Examples:
1651 <programlisting>
1652 archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
1653 archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"'  # Windows
1654 </programlisting>
1655        </para>
1656       </listitem>
1657      </varlistentry>
1658      
1659      <varlistentry id="guc-archive-timeout" xreflabel="archive_timeout">
1660       <term><varname>archive_timeout</varname> (<type>integer</type>)</term>
1661       <indexterm>
1662        <primary><varname>archive_timeout</> configuration parameter</primary>
1663       </indexterm>
1664       <listitem>
1665        <para>
1666         The <xref linkend="guc-archive-command"> is only invoked on
1667         completed WAL segments. Hence, if your server generates little WAL
1668         traffic (or has slack periods where it does so), there could be a
1669         long delay between the completion of a transaction and its safe
1670         recording in archive storage.  To put a limit on how old unarchived
1671         data can be, you can set <varname>archive_timeout</> to force the
1672         server to switch to a new WAL segment file periodically.  When this
1673         parameter is greater than zero, the server will switch to a new
1674         segment file whenever this many seconds have elapsed since the last
1675         segment file switch.  Note that archived files that are closed early
1676         due to a forced switch are still the same length as completely full
1677         files.  Therefore, it is unwise to use a very short
1678         <varname>archive_timeout</> &mdash; it will bloat your archive
1679         storage.  <varname>archive_timeout</> settings of a minute or so are
1680         usually reasonable.  This parameter can only be set in the
1681         <filename>postgresql.conf</> file or on the server command line.
1682        </para>
1683       </listitem>
1684      </varlistentry>
1685      
1686      </variablelist>
1687     </sect2>
1688    </sect1>
1689
1690    <sect1 id="runtime-config-query">
1691     <title>Query Planning</title>
1692
1693     <sect2 id="runtime-config-query-enable">
1694      <title>Planner Method Configuration</title>
1695
1696       <para>
1697        These configuration parameters provide a crude method of
1698        influencing the query plans chosen by the query optimizer. If
1699        the default plan chosen by the optimizer for a particular query
1700        is not optimal, a temporary solution can be found by using one
1701        of these configuration parameters to force the optimizer to
1702        choose a different plan.  Turning one of these settings off
1703        permanently is seldom a good idea, however.
1704        Better ways to improve the quality of the
1705        plans chosen by the optimizer include adjusting the <xref
1706        linkend="runtime-config-query-constants"
1707        endterm="runtime-config-query-constants-title">, running <xref
1708        linkend="sql-analyze" endterm="sql-analyze-title"> more
1709        frequently, increasing the value of the <xref
1710        linkend="guc-default-statistics-target"> configuration parameter,
1711        and increasing the amount of statistics collected for
1712        specific columns using <command>ALTER TABLE SET
1713        STATISTICS</command>.
1714       </para>
1715
1716      <variablelist>
1717      <varlistentry id="guc-enable-bitmapscan" xreflabel="enable_bitmapscan">
1718       <term><varname>enable_bitmapscan</varname> (<type>boolean</type>)</term>
1719       <indexterm>
1720        <primary>bitmap scan</primary>
1721       </indexterm>
1722       <indexterm>
1723        <primary><varname>enable_bitmapscan</> configuration parameter</primary>
1724       </indexterm>
1725       <listitem>
1726        <para>
1727         Enables or disables the query planner's use of bitmap-scan plan
1728         types. The default is <literal>on</>.
1729        </para>
1730       </listitem>
1731      </varlistentry>
1732
1733      <varlistentry id="guc-enable-hashagg" xreflabel="enable_hashagg">
1734       <term><varname>enable_hashagg</varname> (<type>boolean</type>)</term>
1735       <indexterm>
1736        <primary><varname>enable_hashagg</> configuration parameter</primary>
1737       </indexterm>
1738       <listitem>
1739        <para>
1740         Enables or disables the query planner's use of hashed
1741         aggregation plan types. The default is <literal>on</>.
1742        </para>
1743       </listitem>
1744      </varlistentry>
1745
1746      <varlistentry id="guc-enable-hashjoin" xreflabel="enable_hashjoin">
1747       <term><varname>enable_hashjoin</varname> (<type>boolean</type>)</term>
1748       <indexterm>
1749        <primary><varname>enable_hashjoin</> configuration parameter</primary>
1750       </indexterm>
1751       <listitem>
1752        <para>
1753         Enables or disables the query planner's use of hash-join plan
1754         types. The default is <literal>on</>.
1755        </para>
1756       </listitem>
1757      </varlistentry>
1758
1759      <varlistentry id="guc-enable-indexscan" xreflabel="enable_indexscan">
1760       <term><varname>enable_indexscan</varname> (<type>boolean</type>)</term>
1761       <indexterm>
1762        <primary>index scan</primary>
1763       </indexterm>
1764       <indexterm>
1765        <primary><varname>enable_indexscan</> configuration parameter</primary>
1766       </indexterm>
1767       <listitem>
1768        <para>
1769         Enables or disables the query planner's use of index-scan plan
1770         types. The default is <literal>on</>.
1771        </para>
1772       </listitem>
1773      </varlistentry>
1774
1775      <varlistentry id="guc-enable-mergejoin" xreflabel="enable_mergejoin">
1776       <term><varname>enable_mergejoin</varname> (<type>boolean</type>)</term>
1777       <indexterm>
1778        <primary><varname>enable_mergejoin</> configuration parameter</primary>
1779       </indexterm>
1780       <listitem>
1781        <para>
1782         Enables or disables the query planner's use of merge-join plan
1783         types. The default is <literal>on</>.
1784        </para>
1785       </listitem>
1786      </varlistentry>
1787
1788      <varlistentry id="guc-enable-nestloop" xreflabel="enable_nestloop">
1789       <term><varname>enable_nestloop</varname> (<type>boolean</type>)</term>
1790       <indexterm>
1791        <primary><varname>enable_nestloop</> configuration parameter</primary>
1792       </indexterm>
1793       <listitem>
1794        <para>
1795         Enables or disables the query planner's use of nested-loop join
1796         plans. It's not possible to suppress nested-loop joins entirely,
1797         but turning this variable off discourages the planner from using
1798         one if there are other methods available. The default is
1799         <literal>on</>.
1800        </para>
1801       </listitem>
1802      </varlistentry>
1803
1804      <varlistentry id="guc-enable-seqscan" xreflabel="enable_seqscan">
1805       <term><varname>enable_seqscan</varname> (<type>boolean</type>)</term>
1806       <indexterm>
1807        <primary>sequential scan</primary>
1808       </indexterm>
1809       <indexterm>
1810        <primary><varname>enable_seqscan</> configuration parameter</primary>
1811       </indexterm>
1812       <listitem>
1813        <para>
1814         Enables or disables the query planner's use of sequential scan
1815         plan types. It's not possible to suppress sequential scans
1816         entirely, but turning this variable off discourages the planner
1817         from using one if there are other methods available. The
1818         default is <literal>on</>.
1819        </para>
1820       </listitem>
1821      </varlistentry>
1822
1823      <varlistentry id="guc-enable-sort" xreflabel="enable_sort">
1824       <term><varname>enable_sort</varname> (<type>boolean</type>)</term>
1825       <indexterm>
1826        <primary><varname>enable_sort</> configuration parameter</primary>
1827       </indexterm>
1828       <listitem>
1829        <para>
1830         Enables or disables the query planner's use of explicit sort
1831         steps. It's not possible to suppress explicit sorts entirely,
1832         but turning this variable off discourages the planner from
1833         using one if there are other methods available. The default
1834         is <literal>on</>.
1835        </para>
1836       </listitem>
1837      </varlistentry>
1838
1839      <varlistentry id="guc-enable-tidscan" xreflabel="enable_tidscan">
1840       <term><varname>enable_tidscan</varname> (<type>boolean</type>)</term>
1841       <indexterm>
1842        <primary><varname>enable_tidscan</> configuration parameter</primary>
1843       </indexterm>
1844       <listitem>
1845        <para>
1846         Enables or disables the query planner's use of <acronym>TID</>
1847         scan plan types. The default is <literal>on</>.
1848        </para>
1849       </listitem>
1850      </varlistentry>
1851      
1852      </variablelist>
1853      </sect2>
1854      <sect2 id="runtime-config-query-constants">
1855      <title id="runtime-config-query-constants-title">
1856       Planner Cost Constants
1857      </title>
1858
1859     <para>
1860      The <firstterm>cost</> variables described in this section are measured
1861      on an arbitrary scale.  Only their relative values matter, hence
1862      scaling them all up or down by the same factor will result in no change
1863      in the planner's choices.  Traditionally, these variables have been
1864      referenced to sequential page fetches as the unit of cost; that is,
1865      <varname>seq_page_cost</> is conventionally set to <literal>1.0</>
1866      and the other cost variables are set with reference to that.  But
1867      you can use a different scale if you prefer, such as actual execution
1868      times in milliseconds on a particular machine.
1869     </para>
1870
1871    <note>
1872     <para>
1873      Unfortunately, there is no well-defined method for determining ideal
1874      values for the cost variables.  They are best treated as averages over
1875      the entire mix of queries that a particular installation will get.  This
1876      means that changing them on the basis of just a few experiments is very
1877      risky.
1878     </para>
1879    </note>
1880
1881      <variablelist>
1882
1883      <varlistentry id="guc-seq-page-cost" xreflabel="seq_page_cost">
1884       <term><varname>seq_page_cost</varname> (<type>floating point</type>)</term>
1885       <indexterm>
1886        <primary><varname>seq_page_cost</> configuration parameter</primary>
1887       </indexterm>
1888       <listitem>
1889        <para>
1890         Sets the planner's estimate of the cost of a disk page fetch
1891         that is part of a series of sequential fetches.  The default is 1.0.
1892        </para>
1893       </listitem>
1894      </varlistentry>
1895
1896      <varlistentry id="guc-random-page-cost" xreflabel="random_page_cost">
1897       <term><varname>random_page_cost</varname> (<type>floating point</type>)</term>
1898       <indexterm>
1899        <primary><varname>random_page_cost</> configuration parameter</primary>
1900       </indexterm>
1901       <listitem>
1902        <para>
1903         Sets the planner's estimate of the cost of a
1904         non-sequentially-fetched disk page.  The default is 4.0.
1905         Reducing this value relative to <varname>seq_page_cost</>
1906         will cause the system to prefer index scans; raising it will
1907         make index scans look relatively more expensive.  You can raise
1908         or lower both values together to change the importance of disk I/O
1909         costs relative to CPU costs, which are described by the following
1910         parameters.
1911        </para>
1912
1913        <tip>
1914         <para>
1915          Although the system will let you set <varname>random_page_cost</> to
1916          less than <varname>seq_page_cost</>, it is not physically sensible
1917          to do so.  However, setting them equal makes sense if the database
1918          is entirely cached in RAM, since in that case there is no penalty
1919          for touching pages out of sequence.  Also, in a heavily-cached
1920          database you should lower both values relative to the CPU parameters,
1921          since the cost of fetching a page already in RAM is much smaller
1922          than it would normally be.
1923         </para>
1924        </tip>
1925       </listitem>
1926      </varlistentry>
1927
1928      <varlistentry id="guc-cpu-tuple-cost" xreflabel="cpu_tuple_cost">
1929       <term><varname>cpu_tuple_cost</varname> (<type>floating point</type>)</term>
1930       <indexterm>
1931        <primary><varname>cpu_tuple_cost</> configuration parameter</primary>
1932       </indexterm>
1933       <listitem>
1934        <para>
1935         Sets the planner's estimate of the cost of processing
1936         each row during a query.
1937         The default is 0.01.
1938        </para>
1939       </listitem>
1940      </varlistentry>
1941
1942      <varlistentry id="guc-cpu-index-tuple-cost" xreflabel="cpu_index_tuple_cost">
1943       <term><varname>cpu_index_tuple_cost</varname> (<type>floating point</type>)</term>
1944       <indexterm>
1945        <primary><varname>cpu_index_tuple_cost</> configuration parameter</primary>
1946       </indexterm>
1947       <listitem>
1948        <para>
1949         Sets the planner's estimate of the cost of processing
1950         each index entry during an index scan.
1951         The default is 0.005.
1952        </para>
1953       </listitem>
1954      </varlistentry>
1955     
1956      <varlistentry id="guc-cpu-operator-cost" xreflabel="cpu_operator_cost">
1957       <term><varname>cpu_operator_cost</varname> (<type>floating point</type>)</term>
1958       <indexterm>
1959        <primary><varname>cpu_operator_cost</> configuration parameter</primary>
1960       </indexterm>
1961       <listitem>
1962        <para>
1963         Sets the planner's estimate of the cost of processing each
1964         operator or function executed during a query.
1965         The default is 0.0025.
1966        </para>
1967       </listitem>
1968      </varlistentry>
1969      
1970      <varlistentry id="guc-effective-cache-size" xreflabel="effective_cache_size">
1971       <term><varname>effective_cache_size</varname> (<type>integer</type>)</term>
1972       <indexterm>
1973        <primary><varname>effective_cache_size</> configuration parameter</primary>
1974       </indexterm>
1975       <listitem>
1976        <para>
1977         Sets the planner's assumption about the effective size of the
1978         disk cache that is available to a single query.  This is
1979         factored into estimates of the cost of using an index; a
1980         higher value makes it more likely index scans will be used, a
1981         lower value makes it more likely sequential scans will be
1982         used. When setting this parameter you should consider both
1983         <productname>PostgreSQL</productname>'s shared buffers and the
1984         portion of the kernel's disk cache that will be used for
1985         <productname>PostgreSQL</productname> data files.  Also, take
1986         into account the expected number of concurrent queries on different
1987         tables, since they will have to share the available
1988         space.  This parameter has no effect on the size of shared
1989         memory allocated by <productname>PostgreSQL</productname>, nor
1990         does it reserve kernel disk cache; it is used only for estimation
1991         purposes.  The default is 128 megabytes (<literal>128MB</>).
1992        </para>
1993       </listitem>
1994      </varlistentry>
1995
1996      </variablelist>
1997
1998     </sect2>
1999      <sect2 id="runtime-config-query-geqo">
2000      <title>Genetic Query Optimizer</title>
2001
2002      <variablelist>
2003
2004      <varlistentry id="guc-geqo" xreflabel="geqo">
2005       <indexterm>
2006        <primary>genetic query optimization</primary>
2007       </indexterm>
2008       <indexterm>
2009        <primary>GEQO</primary>
2010        <see>genetic query optimization</see>
2011       </indexterm>
2012       <indexterm>
2013        <primary><varname>geqo</> configuration parameter</primary>
2014       </indexterm>
2015       <term><varname>geqo</varname> (<type>boolean</type>)</term>
2016       <listitem>
2017        <para>
2018         Enables or disables genetic query optimization, which is an
2019         algorithm that attempts to do query planning without
2020         exhaustive searching. This is on by default. The
2021         <varname>geqo_threshold</varname> variable provides a more
2022         granular way to disable GEQO for certain classes of queries.
2023        </para>
2024       </listitem>
2025      </varlistentry>
2026
2027      <varlistentry id="guc-geqo-threshold" xreflabel="geqo_threshold">
2028       <term><varname>geqo_threshold</varname> (<type>integer</type>)</term>
2029       <indexterm>
2030        <primary><varname>geqo_threshold</> configuration parameter</primary>
2031       </indexterm>
2032       <listitem>
2033        <para>
2034         Use genetic query optimization to plan queries with at least
2035         this many <literal>FROM</> items involved. (Note that a
2036         <literal>FULL OUTER JOIN</> construct counts as only one <literal>FROM</>
2037         item.) The default is 12. For simpler queries it is usually best
2038         to use the deterministic, exhaustive planner, but for queries with
2039         many tables the deterministic planner takes too long.
2040        </para>
2041       </listitem>
2042      </varlistentry>
2043
2044      <varlistentry id="guc-geqo-effort" xreflabel="geqo_effort">
2045       <term><varname>geqo_effort</varname>
2046       (<type>integer</type>)</term>
2047       <indexterm>
2048        <primary><varname>geqo_effort</> configuration parameter</primary>
2049       </indexterm>
2050       <listitem>
2051        <para>
2052         Controls the trade off between planning time and query plan
2053         efficiency in GEQO. This variable must be an integer in the
2054         range from 1 to 10. The default value is five. Larger values
2055         increase the time spent doing query planning, but also
2056         increase the likelihood that an efficient query plan will be
2057         chosen.
2058        </para>
2059
2060        <para>
2061         <varname>geqo_effort</varname> doesn't actually do anything
2062         directly; it is only used to compute the default values for
2063         the other variables that influence GEQO behavior (described
2064         below). If you prefer, you can set the other parameters by
2065         hand instead.
2066        </para>
2067       </listitem>
2068      </varlistentry>
2069
2070      <varlistentry id="guc-geqo-pool-size" xreflabel="geqo_pool_size">
2071       <term><varname>geqo_pool_size</varname> (<type>integer</type>)</term>
2072       <indexterm>
2073        <primary><varname>geqo_pool_size</> configuration parameter</primary>
2074       </indexterm>
2075       <listitem>
2076        <para>
2077         Controls the pool size used by GEQO. The pool size is the
2078         number of individuals in the genetic population.  It must be
2079         at least two, and useful values are typically 100 to 1000.  If
2080         it is set to zero (the default setting) then a suitable
2081         default is chosen based on <varname>geqo_effort</varname> and
2082         the number of tables in the query.
2083        </para>
2084       </listitem>
2085      </varlistentry>
2086
2087      <varlistentry id="guc-geqo-generations" xreflabel="geqo_generations">
2088       <term><varname>geqo_generations</varname> (<type>integer</type>)</term>
2089       <indexterm>
2090        <primary><varname>geqo_generations</> configuration parameter</primary>
2091       </indexterm>
2092       <listitem>
2093        <para>
2094         Controls the number of generations used by GEQO.  Generations
2095         specifies the number of iterations of the algorithm.  It must
2096         be at least one, and useful values are in the same range as
2097         the pool size.  If it is set to zero (the default setting)
2098         then a suitable default is chosen based on
2099         <varname>geqo_pool_size</varname>.
2100        </para>
2101       </listitem>
2102      </varlistentry>
2103
2104      <varlistentry id="guc-geqo-selection-bias" xreflabel="geqo_selection_bias">
2105       <term><varname>geqo_selection_bias</varname> (<type>floating point</type>)</term>
2106       <indexterm>
2107        <primary><varname>geqo_selection_bias</> configuration parameter</primary>
2108       </indexterm>
2109       <listitem>
2110        <para>
2111         Controls the selection bias used by GEQO. The selection bias
2112         is the selective pressure within the population. Values can be
2113         from 1.50 to 2.00; the latter is the default.
2114        </para>
2115       </listitem>
2116      </varlistentry>
2117      
2118      </variablelist>
2119     </sect2>
2120      <sect2 id="runtime-config-query-other">
2121      <title>Other Planner Options</title>
2122
2123      <variablelist>
2124
2125      <varlistentry id="guc-default-statistics-target" xreflabel="default_statistics_target">
2126       <term><varname>default_statistics_target</varname> (<type>integer</type>)</term>
2127       <indexterm>
2128        <primary><varname>default_statistics_target</> configuration parameter</primary>
2129       </indexterm>
2130       <listitem>
2131        <para>
2132         Sets the default statistics target for table columns that have
2133         not had a column-specific target set via <command>ALTER TABLE
2134         SET STATISTICS</>.  Larger values increase the time needed to
2135         do <command>ANALYZE</>, but might improve the quality of the
2136         planner's estimates. The default is 100. For more information
2137         on the use of statistics by the <productname>PostgreSQL</>
2138         query planner, refer to <xref linkend="planner-stats">.
2139        </para>
2140       </listitem>
2141      </varlistentry>
2142
2143      <varlistentry id="guc-constraint-exclusion" xreflabel="constraint_exclusion">
2144       <term><varname>constraint_exclusion</varname> (<type>boolean</type>)</term>
2145       <indexterm>
2146        <primary>constraint exclusion</primary>
2147       </indexterm>
2148       <indexterm>
2149        <primary><varname>constraint_exclusion</> configuration parameter</primary>
2150       </indexterm>
2151       <listitem>
2152        <para>
2153         Enables or disables the query planner's use of table constraints to
2154         optimize queries.  The default is <literal>off</>.
2155        </para>
2156
2157        <para>
2158         When this parameter is <literal>on</>, the planner compares
2159         query conditions with table <literal>CHECK</> constraints, and
2160         omits scanning tables for which the conditions contradict the
2161         constraints.  For example:
2162
2163 <programlisting>
2164 CREATE TABLE parent(key integer, ...);
2165 CREATE TABLE child1000(check (key between 1000 and 1999)) INHERITS(parent);
2166 CREATE TABLE child2000(check (key between 2000 and 2999)) INHERITS(parent);
2167 ...
2168 SELECT * FROM parent WHERE key = 2400;
2169 </programlisting>
2170
2171         With constraint exclusion enabled, this <command>SELECT</>
2172         will not scan <structname>child1000</> at all.  This can
2173         improve performance when inheritance is used to build
2174         partitioned tables.
2175        </para>
2176
2177        <para>
2178         Currently, <varname>constraint_exclusion</> is disabled by
2179         default because the constraint checks are relatively
2180         expensive, and in many circumstances will yield no savings.
2181         It is recommended to turn this on only if you are actually
2182         using partitioned tables designed to take advantage of the
2183         feature.
2184        </para>
2185
2186        <para>
2187         Refer to <xref linkend="ddl-partitioning"> for more information
2188         on using constraint exclusion and partitioning.
2189        </para>
2190       </listitem>
2191      </varlistentry>
2192
2193      <varlistentry id="guc-cursor-tuple-fraction" xreflabel="cursor_tuple_fraction">
2194       <term><varname>cursor_tuple_fraction</varname> (<type>floating point</type>)</term>
2195       <indexterm>
2196        <primary><varname>cursor_tuple_fraction</> configuration parameter</primary>
2197       </indexterm>
2198       <listitem>
2199        <para>
2200         Sets the planner's estimate of the fraction of a cursor's rows that
2201         will be retrieved.  The default is 0.1.  Smaller values of this
2202         setting bias the planner towards using <quote>fast start</> plans
2203         for cursors, which will retrieve the first few rows quickly while
2204         perhaps taking a long time to fetch all rows.  Larger values
2205         put more emphasis on the total estimated time.  At the maximum
2206         setting of 1.0, cursors are planned exactly like regular queries,
2207         considering only the total estimated time and not how soon the
2208         first rows might be delivered.
2209        </para>
2210       </listitem>
2211      </varlistentry>
2212
2213      <varlistentry id="guc-from-collapse-limit" xreflabel="from_collapse_limit">
2214       <term><varname>from_collapse_limit</varname> (<type>integer</type>)</term>
2215       <indexterm>
2216        <primary><varname>from_collapse_limit</> configuration parameter</primary>
2217       </indexterm>
2218       <listitem>
2219        <para>
2220         The planner will merge sub-queries into upper queries if the
2221         resulting <literal>FROM</literal> list would have no more than
2222         this many items.  Smaller values reduce planning time but might
2223         yield inferior query plans.  The default is eight.  It is usually
2224         wise to keep this less than <xref linkend="guc-geqo-threshold">.
2225         For more information see <xref linkend="explicit-joins">.
2226        </para>
2227       </listitem>
2228      </varlistentry>
2229
2230      <varlistentry id="guc-join-collapse-limit" xreflabel="join_collapse_limit">
2231       <term><varname>join_collapse_limit</varname> (<type>integer</type>)</term>
2232       <indexterm>
2233        <primary><varname>join_collapse_limit</> configuration parameter</primary>
2234       </indexterm>
2235       <listitem>
2236        <para>
2237         The planner will rewrite explicit <literal>JOIN</>
2238         constructs (except <literal>FULL JOIN</>s) into lists of
2239         <literal>FROM</> items whenever a list of no more than this many items
2240         would result.  Smaller values reduce planning time but might
2241         yield inferior query plans.
2242        </para>
2243
2244        <para>
2245         By default, this variable is set the same as
2246         <varname>from_collapse_limit</varname>, which is appropriate
2247         for most uses. Setting it to 1 prevents any reordering of
2248         explicit <literal>JOIN</>s. Thus, the explicit join order
2249         specified in the query will be the actual order in which the
2250         relations are joined. The query planner does not always choose
2251         the optimal join order; advanced users can elect to
2252         temporarily set this variable to 1, and then specify the join
2253         order they desire explicitly.
2254         For more information see <xref linkend="explicit-joins">.
2255        </para>
2256       </listitem>
2257      </varlistentry>
2258
2259      </variablelist>
2260     </sect2>
2261    </sect1>
2262
2263    <sect1 id="runtime-config-logging">
2264     <title>Error Reporting and Logging</title>
2265
2266     <indexterm zone="runtime-config-logging">
2267      <primary>server log</primary>
2268     </indexterm>
2269
2270     <sect2 id="runtime-config-logging-where">
2271      <title>Where To Log</title>
2272
2273      <indexterm zone="runtime-config-logging-where">
2274       <primary>where to log</primary>
2275      </indexterm>
2276
2277      <variablelist>
2278
2279      <varlistentry id="guc-log-destination" xreflabel="log_destination">
2280       <term><varname>log_destination</varname> (<type>string</type>)</term>
2281       <indexterm>
2282        <primary><varname>log_destination</> configuration parameter</primary>
2283       </indexterm>
2284       <listitem>
2285        <para>
2286         <productname>PostgreSQL</productname> supports several methods
2287          for logging server messages, including
2288          <systemitem>stderr</systemitem>, <systemitem>csvlog</systemitem> and
2289          <systemitem>syslog</systemitem>. On Windows, 
2290          <systemitem>eventlog</systemitem> is also supported. Set this
2291          parameter to a list of desired log destinations separated by
2292          commas. The default is to log to <systemitem>stderr</systemitem> 
2293          only.
2294          This parameter can only be set in the <filename>postgresql.conf</>
2295          file or on the server command line.
2296        </para>
2297        <para>
2298         If <systemitem>csvlog</> is included in <varname>log_destination</>,
2299         log entries are output in <quote>comma separated
2300         value</> format, which is convenient for loading them into programs.
2301         See <xref linkend="runtime-config-logging-csvlog"> for details.
2302         <varname>logging_collector</varname> must be enabled to generate 
2303         CSV-format log output.
2304        </para>
2305
2306        <note>
2307         <para>
2308          On most Unix systems, you will need to alter the configuration of
2309          your system's <application>syslog</application> daemon in order
2310          to make use of the <systemitem>syslog</systemitem> option for
2311          <varname>log_destination</>.  <productname>PostgreSQL</productname>
2312          can log to <application>syslog</application> facilities
2313          <literal>LOCAL0</> through <literal>LOCAL7</> (see <xref
2314          linkend="guc-syslog-facility">), but the default
2315          <application>syslog</application> configuration on most platforms
2316          will discard all such messages.  You will need to add something like
2317 <programlisting>
2318 local0.*    /var/log/postgresql
2319 </programlisting>
2320          to the  <application>syslog</application> daemon's configuration file
2321          to make it work.
2322         </para>
2323        </note>
2324       </listitem>
2325      </varlistentry>
2326
2327      <varlistentry id="guc-logging-collector" xreflabel="logging_collector">
2328       <term><varname>logging_collector</varname> (<type>boolean</type>)</term>
2329       <indexterm>
2330        <primary><varname>logging_collector</> configuration parameter</primary>
2331       </indexterm>
2332       <listitem>
2333        <para>
2334          This parameter allows messages sent to <application>stderr</>,
2335          and CSV-format log output, to be
2336          captured and redirected into log files.
2337          This approach is often more useful than
2338          logging to <application>syslog</>, since some types of messages
2339          might not appear in <application>syslog</> output (a common example
2340          is dynamic-linker failure messages).
2341          This parameter can only be set at server start.
2342        </para>
2343       </listitem>
2344      </varlistentry>
2345
2346      <varlistentry id="guc-log-directory" xreflabel="log_directory">
2347       <term><varname>log_directory</varname> (<type>string</type>)</term>
2348       <indexterm>
2349        <primary><varname>log_directory</> configuration parameter</primary>
2350       </indexterm>
2351       <listitem>
2352        <para>
2353         When <varname>logging_collector</> is enabled, 
2354         this parameter determines the directory in which log files will be created.
2355         It can be specified as an absolute path, or relative to the
2356         cluster data directory.
2357         This parameter can only be set in the <filename>postgresql.conf</>
2358         file or on the server command line.
2359        </para>
2360       </listitem>
2361      </varlistentry>
2362
2363      <varlistentry id="guc-log-filename" xreflabel="log_filename">
2364       <term><varname>log_filename</varname> (<type>string</type>)</term>
2365       <indexterm>
2366        <primary><varname>log_filename</> configuration parameter</primary>
2367       </indexterm>
2368       <listitem>
2369        <para>
2370         When <varname>logging_collector</varname> is enabled,
2371         this parameter sets the file names of the created log files.  The value
2372         is treated as a <systemitem>strftime</systemitem> pattern,
2373         so <literal>%</literal>-escapes can be used to specify time-varying
2374         file names.  (Note that if there are
2375         any time-zone-dependent <literal>%</literal>-escapes, the computation
2376         is done in the zone specified by <xref linkend="guc-log-timezone">.)
2377         If no <literal>%</literal>-escapes are present,
2378         <productname>PostgreSQL</productname> will append the epoch of the new
2379         log file's creation time.  For example, if
2380         <varname>log_filename</varname> were <literal>server_log</literal>,
2381         then the chosen file name would be <literal>server_log.1093827753</>
2382         for a log starting at Sun Aug 29 19:02:33 2004 MST.
2383         Note that the system's <systemitem>strftime</systemitem> is not used
2384         directly, so platform-specific (nonstandard) extensions do not work.
2385        </para>
2386        <para>
2387         If CSV-format output is enabled in <varname>log_destination</>,
2388         <literal>.csv</> will be appended to the timestamped 
2389         log file name to create the file name for CSV-format output.
2390         (If <varname>log_filename</> ends in <literal>.log</>, the suffix is
2391         replaced instead.)
2392         In the case of the example above, the CSV
2393         file name will be <literal>server_log.1093827753.csv</literal>.
2394        </para>
2395        <para>
2396         This parameter can only be set in the <filename>postgresql.conf</>
2397         file or on the server command line.
2398        </para>
2399       </listitem>
2400      </varlistentry>
2401
2402      <varlistentry id="guc-log-rotation-age" xreflabel="log_rotation_age">
2403       <term><varname>log_rotation_age</varname> (<type>integer</type>)</term>
2404       <indexterm>
2405        <primary><varname>log_rotation_age</> configuration parameter</primary>
2406       </indexterm>
2407       <listitem>
2408        <para>
2409         When <varname>logging_collector</varname> is enabled,
2410         this parameter determines the maximum lifetime of an individual log file.
2411         After this many minutes have elapsed, a new log file will
2412         be created.  Set to zero to disable time-based creation of
2413         new log files.
2414         This parameter can only be set in the <filename>postgresql.conf</>
2415         file or on the server command line.
2416        </para>
2417       </listitem>
2418      </varlistentry>
2419
2420      <varlistentry id="guc-log-rotation-size" xreflabel="log_rotation_size">
2421       <term><varname>log_rotation_size</varname> (<type>integer</type>)</term>
2422       <indexterm>
2423        <primary><varname>log_rotation_size</> configuration parameter</primary>
2424       </indexterm>
2425       <listitem>
2426        <para>
2427         When <varname>logging_collector</varname> is enabled,
2428         this parameter determines the maximum size of an individual log file.
2429         After this many kilobytes have been emitted into a log file,
2430         a new log file will be created.  Set to zero to disable size-based
2431         creation of new log files.
2432         This parameter can only be set in the <filename>postgresql.conf</>
2433         file or on the server command line.
2434        </para>
2435       </listitem>
2436      </varlistentry>
2437
2438      <varlistentry id="guc-log-truncate-on-rotation" xreflabel="log_truncate_on_rotation">
2439       <term><varname>log_truncate_on_rotation</varname> (<type>boolean</type>)</term>
2440       <indexterm>
2441        <primary><varname>log_truncate_on_rotation</> configuration parameter</primary>
2442       </indexterm>
2443       <listitem>
2444        <para>
2445         When <varname>logging_collector</varname> is enabled,
2446         this parameter will cause <productname>PostgreSQL</productname> to truncate (overwrite),
2447         rather than append to, any existing log file of the same name.
2448         However, truncation will occur only when a new file is being opened
2449         due to time-based rotation, not during server startup or size-based
2450         rotation.  When off, pre-existing files will be appended to in
2451         all cases.  For example, using this setting in combination with
2452         a <varname>log_filename</varname> like <literal>postgresql-%H.log</literal>
2453         would result in generating twenty-four hourly log files and then
2454         cyclically overwriting them.
2455         This parameter can only be set in the <filename>postgresql.conf</>
2456         file or on the server command line.
2457        </para>
2458        <para>
2459         Example:  To keep 7 days of logs, one log file per day named
2460         <literal>server_log.Mon</literal>, <literal>server_log.Tue</literal>, 
2461         etc, and automatically overwrite last week's log with this week's log,
2462         set <varname>log_filename</varname> to <literal>server_log.%a</literal>, 
2463         <varname>log_truncate_on_rotation</varname> to <literal>on</literal>, and 
2464         <varname>log_rotation_age</varname> to <literal>1440</literal>.
2465        </para>
2466        <para>
2467         Example: To keep 24 hours of logs, one log file per hour, but 
2468         also rotate sooner if the log file size exceeds 1GB, set 
2469         <varname>log_filename</varname> to <literal>server_log.%H%M</literal>, 
2470         <varname>log_truncate_on_rotation</varname> to <literal>on</literal>, 
2471         <varname>log_rotation_age</varname> to <literal>60</literal>, and 
2472         <varname>log_rotation_size</varname> to <literal>1000000</literal>.
2473         Including <literal>%M</> in <varname>log_filename</varname> allows
2474         any size-driven rotations that might occur to select a file name
2475         different from the hour's initial file name.
2476        </para>
2477       </listitem>
2478      </varlistentry>
2479
2480      <varlistentry id="guc-syslog-facility" xreflabel="syslog_facility">
2481       <term><varname>syslog_facility</varname> (<type>enum</type>)</term>
2482       <indexterm>
2483        <primary><varname>syslog_facility</> configuration parameter</primary>
2484       </indexterm>
2485       <listitem>
2486        <para>
2487         When logging to <application>syslog</> is enabled, this parameter
2488         determines the <application>syslog</application>
2489         <quote>facility</quote> to be used.  You can choose
2490         from <literal>LOCAL0</>, <literal>LOCAL1</>,
2491         <literal>LOCAL2</>, <literal>LOCAL3</>, <literal>LOCAL4</>,
2492         <literal>LOCAL5</>, <literal>LOCAL6</>, <literal>LOCAL7</>;
2493         the default is <literal>LOCAL0</>. See also the
2494         documentation of your system's
2495         <application>syslog</application> daemon.
2496         This parameter can only be set in the <filename>postgresql.conf</>
2497         file or on the server command line.
2498        </para>
2499       </listitem>
2500      </varlistentry>
2501      
2502      <varlistentry id="guc-syslog-ident" xreflabel="syslog_ident">
2503       <term><varname>syslog_ident</varname> (<type>string</type>)</term>
2504       <indexterm>
2505        <primary><varname>syslog_identity</> configuration parameter</primary>
2506       </indexterm>
2507        <listitem>
2508         <para>
2509          When logging to <application>syslog</> is enabled, this parameter
2510          determines the program name used to identify
2511          <productname>PostgreSQL</productname> messages in
2512          <application>syslog</application> logs. The default is
2513          <literal>postgres</literal>.
2514          This parameter can only be set in the <filename>postgresql.conf</>
2515          file or on the server command line.
2516         </para>
2517        </listitem>
2518       </varlistentry>
2519       
2520       </variablelist>
2521     </sect2>
2522      <sect2 id="runtime-config-logging-when">
2523      <title>When To Log</title>
2524
2525      <variablelist>
2526
2527      <varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
2528       <term><varname>client_min_messages</varname> (<type>enum</type>)</term>
2529       <indexterm>
2530        <primary><varname>client_min_messages</> configuration parameter</primary>
2531       </indexterm>
2532       <listitem>
2533        <para>
2534         Controls which message levels are sent to the client.
2535         Valid values are <literal>DEBUG5</>,
2536         <literal>DEBUG4</>, <literal>DEBUG3</>, <literal>DEBUG2</>,
2537         <literal>DEBUG1</>, <literal>LOG</>, <literal>NOTICE</>,
2538         <literal>WARNING</>, <literal>ERROR</>, <literal>FATAL</>,
2539         and <literal>PANIC</>.  Each level
2540         includes all the levels that follow it.  The later the level,
2541         the fewer messages are sent.  The default is
2542         <literal>NOTICE</>.  Note that <literal>LOG</> has a different
2543         rank here than in <varname>log_min_messages</>.
2544        </para>
2545       </listitem>
2546      </varlistentry>
2547
2548      <varlistentry id="guc-log-min-messages" xreflabel="log_min_messages">
2549       <term><varname>log_min_messages</varname> (<type>enum</type>)</term>
2550       <indexterm>
2551        <primary><varname>log_min_messages</> configuration parameter</primary>
2552       </indexterm>
2553       <listitem>
2554        <para>
2555         Controls which message levels are written to the server log.
2556         Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
2557         <literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>,
2558         <literal>INFO</>, <literal>NOTICE</>, <literal>WARNING</>,
2559         <literal>ERROR</>, <literal>LOG</>, <literal>FATAL</>, and
2560         <literal>PANIC</>.  Each level includes all the levels that
2561         follow it.  The later the level, the fewer messages are sent
2562         to the log.  The default is <literal>WARNING</>.  Note that
2563         <literal>LOG</> has a different rank here than in
2564         <varname>client_min_messages</>.
2565         Only superusers can change this setting.
2566        </para>
2567       </listitem>
2568      </varlistentry>
2569
2570      <varlistentry id="guc-log-error-verbosity" xreflabel="log_error_verbosity">
2571       <term><varname>log_error_verbosity</varname> (<type>enum</type>)</term>
2572       <indexterm>
2573        <primary><varname>log_error_verbosity</> configuration parameter</primary>
2574       </indexterm>
2575       <listitem>
2576        <para>
2577         Controls the amount of detail written in the server log for each
2578         message that is logged.  Valid values are <literal>TERSE</>,
2579         <literal>DEFAULT</>, and <literal>VERBOSE</>, each adding more
2580         fields to displayed messages.
2581         Only superusers can change this setting.
2582        </para>
2583       </listitem>
2584      </varlistentry>
2585
2586      <varlistentry id="guc-log-min-error-statement" xreflabel="log_min_error_statement">
2587       <term><varname>log_min_error_statement</varname> (<type>enum</type>)</term>
2588       <indexterm>
2589        <primary><varname>log_min_error_statement</> configuration parameter</primary>
2590       </indexterm>
2591       <listitem>
2592        <para>
2593         Controls whether or not the SQL statement that causes an error
2594         condition will be recorded in the server log.  The current
2595         SQL statement is included in the log entry for any message of
2596         the specified severity or higher.
2597         Valid values are <literal>DEBUG5</literal>,
2598         <literal>DEBUG4</literal>, <literal>DEBUG3</literal>,
2599         <literal>DEBUG2</literal>, <literal>DEBUG1</literal>,
2600         <literal>INFO</literal>, <literal>NOTICE</literal>,
2601         <literal>WARNING</literal>, <literal>ERROR</literal>,
2602         <literal>LOG</literal>,
2603         <literal>FATAL</literal>, and <literal>PANIC</literal>.
2604         The default is <literal>ERROR</literal>, which means statements
2605         causing errors, log messages, fatal errors, or panics will be logged.
2606         To effectively turn off logging of failing statements,
2607         set this parameter to <literal>PANIC</literal>.
2608         Only superusers can change this setting.
2609        </para>
2610       </listitem>
2611      </varlistentry>
2612      
2613      <varlistentry id="guc-log-min-duration-statement" xreflabel="log_min_duration_statement">
2614       <term><varname>log_min_duration_statement</varname> (<type>integer</type>)</term>
2615       <indexterm>
2616        <primary><varname>log_min_duration_statement</> configuration parameter</primary>
2617       </indexterm>
2618        <listitem>
2619         <para>
2620          Causes the duration of each completed statement to be logged
2621          if the statement ran for at least the specified number of
2622          milliseconds.  Setting this to zero prints all statement durations.
2623          Minus-one (the default) disables logging statement durations.
2624          For example, if you set it to <literal>250ms</literal>
2625          then all SQL statements that run 250ms or longer will be
2626          logged.  Enabling this parameter can be helpful in tracking down
2627          unoptimized queries in your applications.
2628          Only superusers can change this setting.
2629         </para>
2630
2631         <para>
2632          For clients using extended query protocol, durations of the Parse,
2633          Bind, and Execute steps are logged independently.
2634         </para>
2635
2636        <note>
2637         <para>
2638          When using this option together with
2639          <xref linkend="guc-log-statement">,
2640          the text of statements that are logged because of
2641          <varname>log_statement</> will not be repeated in the
2642          duration log message.
2643          If you are not using <application>syslog</>, it is recommended 
2644          that you log the PID or session ID using
2645          <xref linkend="guc-log-line-prefix">
2646          so that you can link the statement message to the later
2647          duration message using the process ID or session ID.
2648         </para>
2649        </note>
2650        </listitem>
2651       </varlistentry>
2652
2653      <varlistentry id="guc-silent-mode" xreflabel="silent_mode">
2654       <term><varname>silent_mode</varname> (<type>boolean</type>)</term>
2655       <indexterm>
2656        <primary><varname>silent_mode</> configuration parameter</primary>
2657       </indexterm>
2658       <listitem>
2659        <para>
2660         Runs the server silently. If this parameter is set, the server
2661         will automatically run in background and any controlling
2662         terminals are disassociated.
2663         The server's standard output and standard error are redirected
2664         to <literal>/dev/null</>, so any messages sent to them will be lost.
2665         Unless <application>syslog</> logging is selected or
2666         <varname>logging_collector</> is enabled, using this parameter
2667         is discouraged because it makes it impossible to see error messages.
2668         This parameter can only be set at server start.
2669        </para>
2670       </listitem>
2671      </varlistentry>
2672
2673      </variablelist>
2674
2675     <para>
2676      <xref linkend="runtime-config-severity-levels"> explains the message
2677      severity levels used by <productname>PostgreSQL</>.  If logging output
2678      is sent to <systemitem>syslog</systemitem> or Windows'
2679      <systemitem>eventlog</systemitem>, the severity levels are translated
2680      as shown in the table.
2681     </para>
2682
2683     <table id="runtime-config-severity-levels">
2684      <title>Message severity levels</title>
2685      <tgroup cols="4">
2686       <thead>
2687        <row>
2688         <entry>Severity</entry>
2689         <entry>Usage</entry>
2690         <entry><systemitem>syslog</></entry>
2691         <entry><systemitem>eventlog</></entry>
2692        </row>
2693       </thead>
2694
2695       <tbody>
2696        <row>
2697         <entry><literal>DEBUG1..DEBUG5</></entry>
2698         <entry>Provides successively-more-detailed information for use by
2699          developers.</entry>
2700         <entry><literal>DEBUG</></entry>
2701         <entry><literal>INFORMATION</></entry>
2702        </row>
2703
2704        <row>
2705         <entry><literal>INFO</></entry>
2706         <entry>Provides information implicitly requested by the user,
2707          e.g., output from <command>VACUUM VERBOSE</>.</entry>
2708         <entry><literal>INFO</></entry>
2709         <entry><literal>INFORMATION</></entry>
2710        </row>
2711
2712        <row>
2713         <entry><literal>NOTICE</></entry>
2714         <entry>Provides information that might be helpful to users, e.g.,
2715          notice of truncation of long identifiers.</entry>
2716         <entry><literal>NOTICE</></entry>
2717         <entry><literal>INFORMATION</></entry>
2718        </row>
2719
2720        <row>
2721         <entry><literal>WARNING</></entry>
2722         <entry>Provides warnings of likely problems, e.g., <command>COMMIT</>
2723          outside a transaction block.</entry>
2724         <entry><literal>NOTICE</></entry>
2725         <entry><literal>WARNING</></entry>
2726        </row>
2727
2728        <row>
2729         <entry><literal>ERROR</></entry>
2730         <entry>Reports an error that caused the current command to
2731          abort.</entry>
2732         <entry><literal>WARNING</></entry>
2733         <entry><literal>ERROR</></entry>
2734        </row>
2735
2736        <row>
2737         <entry><literal>LOG</></entry>
2738         <entry>Reports information of interest to administrators, e.g.,
2739          checkpoint activity.</entry>
2740         <entry><literal>INFO</></entry>
2741         <entry><literal>INFORMATION</></entry>
2742        </row>
2743
2744        <row>
2745         <entry><literal>FATAL</></entry>
2746         <entry>Reports an error that caused the current session to
2747          abort.</entry>
2748         <entry><literal>ERR</></entry>
2749         <entry><literal>ERROR</></entry>
2750        </row>
2751
2752        <row>
2753         <entry><literal>PANIC</></entry>
2754         <entry>Reports an error that caused all database sessions to abort.</entry>
2755         <entry><literal>CRIT</></entry>
2756         <entry><literal>ERROR</></entry>
2757        </row>
2758       </tbody>
2759      </tgroup>
2760     </table>
2761
2762     </sect2>
2763      <sect2 id="runtime-config-logging-what">
2764      <title>What To Log</title>
2765
2766      <variablelist>
2767
2768      <varlistentry>
2769       <term><varname>debug_print_parse</varname> (<type>boolean</type>)</term>
2770       <term><varname>debug_print_rewritten</varname> (<type>boolean</type>)</term>
2771       <term><varname>debug_print_plan</varname> (<type>boolean</type>)</term>
2772       <indexterm>
2773        <primary><varname>debug_print_parse</> configuration parameter</primary>
2774       </indexterm>
2775       <indexterm>
2776        <primary><varname>debug_print_rewritten</> configuration parameter</primary>
2777       </indexterm>
2778       <indexterm>
2779        <primary><varname>debug_print_plan</> configuration parameter</primary>
2780       </indexterm>
2781       <listitem>
2782        <para>
2783         These parameters enable various debugging output to be emitted.
2784         When set, they print the resulting parse tree, the query rewriter
2785         output, or the execution plan for each executed query.
2786         These messages are emitted at <literal>LOG</> message level, so by
2787         default they will appear in the server log but will not be sent to the
2788         client.  You can change that by adjusting
2789         <xref linkend="guc-client-min-messages"> and/or
2790         <xref linkend="guc-log-min-messages">.
2791         These parameters are off by default.
2792        </para>
2793       </listitem>
2794      </varlistentry>
2795
2796      <varlistentry>
2797       <term><varname>debug_pretty_print</varname> (<type>boolean</type>)</term>
2798       <indexterm>
2799        <primary><varname>debug_pretty_print</> configuration parameter</primary>
2800       </indexterm>
2801       <listitem>
2802        <para>
2803         When set, <varname>debug_pretty_print</varname> indents the messages
2804         produced by <varname>debug_print_parse</varname>,
2805         <varname>debug_print_rewritten</varname>, or
2806         <varname>debug_print_plan</varname>.  This results in more readable
2807         but much longer output than the <quote>compact</> format used when
2808         it is off.  It is on by default.
2809        </para>
2810       </listitem>
2811      </varlistentry>
2812
2813      <varlistentry id="guc-log-checkpoints" xreflabel="log_checkpoints">
2814       <term><varname>log_checkpoints</varname> (<type>boolean</type>)</term>
2815       <indexterm>
2816        <primary><varname>log_checkpoints</> configuration parameter</primary>
2817       </indexterm>
2818       <listitem>
2819        <para>
2820         Causes checkpoints to be logged in the server log. Some
2821         statistics about each checkpoint are included in the log messages,
2822         including the number of buffers written and the time spent writing
2823         them.
2824         This parameter can only be set in the <filename>postgresql.conf</>
2825         file or on the server command line. The default is off.
2826        </para>
2827       </listitem>
2828      </varlistentry>
2829
2830      <varlistentry id="guc-log-connections" xreflabel="log_connections">
2831       <term><varname>log_connections</varname> (<type>boolean</type>)</term>
2832       <indexterm>
2833        <primary><varname>log_connections</> configuration parameter</primary>
2834       </indexterm>
2835       <listitem>
2836        <para>
2837         Causes each attempted connection to the server to be logged,
2838         as well as successful completion of client authentication.
2839         This parameter can only be set in the <filename>postgresql.conf</>
2840         file or on the server command line.  The default is off.
2841        </para>
2842
2843        <note>
2844         <para>
2845          Some client programs, like <application>psql</>, attempt 
2846          to connect twice while determining if a password is required, so 
2847          duplicate <quote>connection received</> messages do not
2848          necessarily indicate a problem.
2849         </para>
2850        </note>
2851       </listitem>
2852      </varlistentry>
2853
2854      <varlistentry id="guc-log-disconnections" xreflabel="log_disconnections">
2855       <term><varname>log_disconnections</varname> (<type>boolean</type>)</term>
2856       <indexterm>
2857        <primary><varname>log_disconnections</> configuration parameter</primary>
2858       </indexterm>
2859       <listitem>
2860        <para>
2861         This outputs a line in the server log similar to
2862         <varname>log_connections</varname> but at session termination,
2863         and includes the duration of the session.  This is off by
2864         default.
2865         This parameter can only be set in the <filename>postgresql.conf</>
2866         file or on the server command line.
2867        </para>
2868       </listitem>
2869      </varlistentry>
2870
2871
2872      <varlistentry id="guc-log-duration" xreflabel="log_duration">
2873       <term><varname>log_duration</varname> (<type>boolean</type>)</term>
2874       <indexterm>
2875        <primary><varname>log_duration</> configuration parameter</primary>
2876       </indexterm>
2877       <listitem>
2878        <para>
2879         Causes the duration of every completed statement to be logged.
2880         The default is <literal>off</>.
2881         Only superusers can change this setting.
2882        </para>
2883
2884        <para>
2885         For clients using extended query protocol, durations of the Parse,
2886         Bind, and Execute steps are logged independently.
2887        </para>
2888
2889        <note>
2890         <para>
2891          The difference between setting this option and setting
2892          <xref linkend="guc-log-min-duration-statement"> to zero is that
2893          exceeding <varname>log_min_duration_statement</> forces the text of
2894          the query to be logged, but this option doesn't.  Thus, if
2895          <varname>log_duration</> is <literal>on</> and
2896          <varname>log_min_duration_statement</> has a positive value, all
2897          durations are logged but the query text is included only for
2898          statements exceeding the threshold.  This behavior can be useful for
2899          gathering statistics in high-load installations.
2900         </para>
2901        </note>
2902       </listitem>
2903      </varlistentry>
2904
2905      <varlistentry id="guc-log-hostname" xreflabel="log_hostname">
2906       <term><varname>log_hostname</varname> (<type>boolean</type>)</term>
2907       <indexterm>
2908        <primary><varname>log_hostname</> configuration parameter</primary>
2909       </indexterm>
2910       <listitem>
2911        <para>
2912         By default, connection log messages only show the IP address of the
2913         connecting host. Turning on this parameter causes logging of the
2914         host name as well.  Note that depending on your host name resolution
2915         setup this might impose a non-negligible performance penalty.
2916         This parameter can only be set in the <filename>postgresql.conf</>
2917         file or on the server command line.
2918        </para>
2919       </listitem>
2920      </varlistentry>
2921      
2922      <varlistentry id="guc-log-line-prefix" xreflabel="log_line_prefix">
2923       <term><varname>log_line_prefix</varname> (<type>string</type>)</term>
2924       <indexterm>
2925        <primary><varname>log_line_prefix</> configuration parameter</primary>
2926       </indexterm>
2927       <listitem>
2928        <para>
2929          This is a <function>printf</>-style string that is output at the
2930          beginning of each log line.
2931          <literal>%</> characters begin <quote>escape sequences</>
2932          that are replaced with status information as outlined below.
2933          Unrecognized escapes are ignored. Other
2934          characters are copied straight to the log line. Some escapes are
2935          only recognized by session processes, and do not apply to
2936          background processes such as the main server process.
2937          This parameter can only be set in the <filename>postgresql.conf</>
2938          file or on the server command line. The default is an empty string.
2939
2940          <informaltable>
2941           <tgroup cols="3">
2942            <thead>
2943             <row>
2944              <entry>Escape</entry>
2945              <entry>Effect</entry>
2946              <entry>Session only</entry>
2947              </row>
2948             </thead>
2949            <tbody>
2950             <row>
2951              <entry><literal>%u</literal></entry>
2952              <entry>User name</entry>
2953              <entry>yes</entry>
2954             </row>
2955             <row>
2956              <entry><literal>%d</literal></entry>
2957              <entry>Database name</entry>
2958              <entry>yes</entry>
2959             </row>
2960             <row>
2961              <entry><literal>%r</literal></entry>
2962              <entry>Remote host name or IP address, and remote port</entry>
2963              <entry>yes</entry>
2964             </row>
2965             <row>
2966              <entry><literal>%h</literal></entry>
2967              <entry>Remote host name or IP address</entry>
2968              <entry>yes</entry>
2969             </row>
2970             <row>
2971              <entry><literal>%p</literal></entry>
2972              <entry>Process ID</entry>
2973              <entry>no</entry>
2974             </row>
2975             <row>
2976              <entry><literal>%t</literal></entry>
2977              <entry>Time stamp without milliseconds</entry>
2978              <entry>no</entry>
2979             </row>
2980             <row>
2981              <entry><literal>%m</literal></entry>
2982              <entry>Time stamp with milliseconds</entry>
2983              <entry>no</entry>
2984             </row>
2985             <row>
2986              <entry><literal>%i</literal></entry>
2987              <entry>Command tag: type of session's current command</entry>
2988              <entry>yes</entry>
2989             </row>
2990             <row>
2991              <entry><literal>%c</literal></entry>
2992              <entry>Session ID: see below</entry>
2993              <entry>no</entry>
2994             </row>
2995             <row>
2996              <entry><literal>%l</literal></entry>
2997              <entry>Number of the log line for each session or process, starting at 1</entry>
2998              <entry>no</entry>
2999             </row>
3000             <row>
3001              <entry><literal>%s</literal></entry>
3002              <entry>Process start time stamp</entry>
3003              <entry>no</entry>
3004             </row>
3005             <row>
3006              <entry><literal>%v</literal></entry>
3007              <entry>Virtual transaction ID (backendID/localXID)</entry>
3008              <entry>no</entry>
3009             </row>
3010             <row>
3011              <entry><literal>%x</literal></entry>
3012              <entry>Transaction ID (0 if none is assigned)</entry>
3013              <entry>no</entry>
3014             </row>
3015             <row>
3016              <entry><literal>%q</literal></entry>
3017              <entry>Produces no output, but tells non-session
3018              processes to stop at this point in the string; ignored by
3019              session processes</entry>
3020              <entry>no</entry>
3021             </row>
3022             <row>
3023              <entry><literal>%%</literal></entry>
3024              <entry>Literal <literal>%</></entry>
3025              <entry>no</entry>
3026             </row>
3027            </tbody>
3028           </tgroup>
3029          </informaltable>
3030
3031          The <literal>%c</> escape prints a quasi-unique session identifier,
3032          consisting of two 4-byte hexadecimal numbers (without leading zeros)
3033          separated by a dot.  The numbers are the process start time and the
3034          process ID, so <literal>%c</> can also be used as a space saving way
3035          of printing those items.
3036        </para>
3037
3038        <tip>
3039         <para>
3040          If you set a nonempty value for <varname>log_line_prefix</>,
3041          you should usually make its last character be a space, to provide
3042          visual separation from the rest of the log line.  A punctuation
3043          character could be used too.
3044         </para>
3045        </tip>
3046
3047        <tip>
3048         <para>
3049          <application>Syslog</> produces its own 
3050          time stamp and process ID information, so you probably do not want to
3051          use those escapes if you are logging to <application>syslog</>.
3052         </para>
3053        </tip>
3054       </listitem>
3055      </varlistentry>
3056
3057      <varlistentry id="guc-log-lock-waits" xreflabel="log_lock_waits">
3058       <term><varname>log_lock_waits</varname> (<type>boolean</type>)</term>
3059       <indexterm>
3060        <primary><varname>log_lock_waits</> configuration parameter</primary>
3061       </indexterm>
3062       <listitem>
3063        <para>
3064         Controls whether a log message is produced when a session waits
3065         longer than <xref linkend="guc-deadlock-timeout"> to acquire a
3066         lock.  This is useful in determining if lock waits are causing
3067         poor performance.  The default is <literal>off</>.
3068        </para>
3069       </listitem>
3070      </varlistentry>
3071
3072      <varlistentry id="guc-log-statement" xreflabel="log_statement">
3073       <term><varname>log_statement</varname> (<type>enum</type>)</term>
3074       <indexterm>
3075        <primary><varname>log_statement</> configuration parameter</primary>
3076       </indexterm>
3077       <listitem>
3078        <para>
3079         Controls which SQL statements are logged. Valid values are
3080         <literal>none</>, <literal>ddl</>, <literal>mod</>, and
3081         <literal>all</>. <literal>ddl</> logs all data definition
3082         statements, such as <command>CREATE</>, <command>ALTER</>, and
3083         <command>DROP</> statements. <literal>mod</> logs all
3084         <literal>ddl</> statements, plus data-modifying statements
3085         such as <command>INSERT</>,
3086         <command>UPDATE</>, <command>DELETE</>, <command>TRUNCATE</>,
3087         and <command>COPY FROM</>.
3088         <command>PREPARE</>, <command>EXECUTE</>, and
3089         <command>EXPLAIN ANALYZE</> statements are also logged if their
3090         contained command is of an appropriate type.  For clients using
3091         extended query protocol, logging occurs when an Execute message
3092         is received, and values of the Bind parameters are included
3093         (with any embedded single-quote marks doubled).
3094        </para>
3095
3096        <para>
3097         The default is <literal>none</>. Only superusers can change this
3098         setting.
3099        </para>
3100
3101        <note>
3102         <para>
3103          Statements that contain simple syntax errors are not logged
3104          even by the <varname>log_statement</> = <literal>all</> setting,
3105          because the log message is emitted only after basic parsing has
3106          been done to determine the statement type.  In the case of extended
3107          query protocol, this setting likewise does not log statements that
3108          fail before the Execute phase (i.e., during parse analysis or
3109          planning).  Set <varname>log_min_error_statement</> to
3110          <literal>ERROR</> (or lower) to log such statements.      
3111         </para>
3112        </note>
3113       </listitem>
3114      </varlistentry>
3115
3116      <varlistentry id="guc-log-temp-files" xreflabel="log_temp_files">
3117       <term><varname>log_temp_files</varname> (<type>integer</type>)</term>
3118       <indexterm>
3119        <primary><varname>log_temp_files</> configuration parameter</primary>
3120       </indexterm>
3121       <listitem>
3122        <para>
3123         Controls whether temporary files are logged when deleted.
3124         Temporary files can be
3125         created for sorts, hashes, and temporary query results.
3126         A value of zero logs all temporary files, and positive
3127         values log only files whose size is equal or greater than
3128         the specified number of kilobytes.  The
3129         default is <literal>-1</>, which disables this logging.
3130         Only superusers can change this setting.
3131        </para>
3132       </listitem>
3133      </varlistentry>
3134
3135      <varlistentry id="guc-log-timezone" xreflabel="log_timezone">
3136       <term><varname>log_timezone</varname> (<type>string</type>)</term>
3137       <indexterm>
3138        <primary><varname>log_timezone</> configuration parameter</primary>
3139       </indexterm>
3140       <listitem>
3141        <para>
3142         Sets the time zone used for timestamps written in the log.
3143         Unlike <xref linkend="guc-timezone">, this value is cluster-wide,
3144         so that all sessions will report timestamps consistently.
3145         The default is <literal>unknown</>, which means to use whatever
3146         the system environment specifies as the time zone.  See <xref
3147         linkend="datatype-timezones"> for more information.
3148         This parameter can only be set in the <filename>postgresql.conf</>
3149         file or on the server command line.
3150        </para>
3151       </listitem>
3152      </varlistentry>
3153
3154      </variablelist>
3155     </sect2>
3156      <sect2 id="runtime-config-logging-csvlog">
3157      <title>Using CSV-Format Log Output</title>
3158
3159        <para>
3160         Including <literal>csvlog</> in the <varname>log_destination</> list 
3161         provides a convenient way to import log files into a database table. 
3162         This option emits log lines in comma-separated-value format,
3163         with these columns: timestamp with milliseconds, user name, database
3164         name, process ID, host:port number, session ID, per-session or -process line
3165         number, command tag, session start time, virtual transaction ID,
3166         regular transaction id, error severity, SQL state code, error message,
3167         error message detail, hint, internal query that led to the error (if
3168         any), character count of the error position thereof, error context,
3169         user query that led to the error (if any and enabled by
3170         <varname>log_min_error_statement</>), character count of the error
3171         position thereof, location of the error in the PostgreSQL source code
3172         (if <varname>log_error_verbosity</> is set to <literal>verbose</>).
3173         Here is a sample table definition for storing CSV-format log output:
3174
3175 <programlisting>
3176 CREATE TABLE postgres_log
3177 (
3178   log_time timestamp(3) with time zone,
3179   user_name text,
3180   database_name text,
3181   process_id integer,
3182   connection_from text,
3183   session_id text,
3184   session_line_num bigint,
3185   command_tag text,
3186   session_start_time timestamp with time zone,
3187   virtual_transaction_id text,
3188   transaction_id bigint,
3189   error_severity text,
3190   sql_state_code text,
3191   message text,
3192   detail text,
3193   hint text,
3194   internal_query text,
3195   internal_query_pos integer,
3196   context text,
3197   query text,
3198   query_pos integer,
3199   location text,
3200   PRIMARY KEY (session_id, session_line_num)
3201 );
3202 </programlisting>
3203        </para>
3204
3205        <para>
3206         To import a log file into this table, use the <command>COPY FROM</>
3207         command:
3208
3209 <programlisting>
3210 COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
3211 </programlisting>
3212        </para>
3213
3214        <para>
3215        There are a few things you need to do to simplify importing CSV log
3216        files easily and automatically:
3217
3218        <orderedlist>
3219          <listitem>
3220            <para>
3221             Set <varname>log_filename</varname> and
3222             <varname>log_rotation_age</> to provide a consistent,
3223             predictable naming scheme for your log files.  This lets you
3224             predict what the file name will be and know when an individual log
3225             file is complete and therefore ready to be imported.
3226          </para>
3227         </listitem>
3228
3229         <listitem>
3230            <para>
3231             Set <varname>log_rotation_size</varname> to 0 to disable 
3232             size-based log rotation, as it makes the log file name difficult 
3233             to predict. 
3234            </para>
3235         </listitem>
3236
3237         <listitem>
3238           <para>
3239            Set <varname>log_truncate_on_rotation</varname> to <literal>on</> so
3240            that old log data isn't mixed with the new in the same file.
3241           </para>
3242         </listitem>
3243
3244         <listitem>
3245           <para>
3246            The table definition above includes a primary key specification.
3247            This is useful to protect against accidentally importing the same
3248            information twice.  The <command>COPY</> command commits all of the
3249            data it imports at one time, so any error will cause the entire
3250            import to fail.  If you import a partial log file and later import
3251            the file again when it is complete, the primary key violation will
3252            cause the import to fail.  Wait until the log is complete and
3253            closed before importing.  This procedure will also protect against
3254            accidentally importing a partial line that hasn't been completely
3255            written, which would also cause <command>COPY</> to fail.
3256           </para>
3257         </listitem>
3258         </orderedlist>
3259       </para>
3260
3261     </sect2>
3262    </sect1>
3263
3264    <sect1 id="runtime-config-statistics">
3265     <title>Run-Time Statistics</title>
3266
3267     <sect2 id="runtime-config-statistics-collector">
3268      <title>Query and Index Statistics Collector</title>
3269
3270      <para>
3271       These parameters control server-wide statistics collection features.
3272       When statistics collection is enabled, the data that is produced can be
3273       accessed via the <structname>pg_stat</structname> and
3274       <structname>pg_statio</structname> family of system views.
3275       Refer to <xref linkend="monitoring"> for more information.
3276      </para>
3277
3278      <variablelist>
3279
3280      <varlistentry id="guc-track-activities" xreflabel="track_activities">
3281       <term><varname>track_activities</varname> (<type>boolean</type>)</term>
3282       <indexterm>
3283        <primary><varname>track_activities</> configuration parameter</primary>
3284       </indexterm>
3285       <listitem>
3286        <para>
3287         Enables the collection of information on the currently
3288         executing command of each session, along with the time at
3289         which that command began execution. This parameter is on by
3290         default. Note that even when enabled, this information is not
3291         visible to all users, only to superusers and the user owning
3292         the session being reported on; so it should not represent a
3293         security risk.
3294         Only superusers can change this setting.
3295        </para>
3296       </listitem>
3297      </varlistentry>
3298
3299      <varlistentry id="guc-track-activity-query-size" xreflabel="track_activity_query_size">
3300       <term><varname>track_activity_query_size</varname> (<type>integer</type>)</term>
3301       <indexterm>
3302        <primary><varname>track_activity_query_size</> configuration parameter</primary>
3303       </indexterm>
3304       <listitem>
3305        <para>
3306        Specifies the number of bytes reserved to track the currently
3307        executing command for each active session, for the
3308        <structname>pg_stat_activity</>.<structfield>current_query</> field.
3309        The default value is 1024. This parameter can only be set at server
3310        start.
3311        </para>
3312       </listitem>
3313      </varlistentry>
3314
3315      <varlistentry id="guc-track-counts" xreflabel="track_counts">
3316       <term><varname>track_counts</varname> (<type>boolean</type>)</term>
3317       <indexterm>
3318        <primary><varname>track_counts</> configuration parameter</primary>
3319       </indexterm>
3320       <listitem>
3321        <para>
3322         Enables collection of statistics on database activity.
3323         This parameter is on by default, because the autovacuum
3324         daemon needs the collected information.
3325         Only superusers can change this setting.
3326        </para>
3327       </listitem>
3328      </varlistentry>
3329
3330      <varlistentry id="guc-track-functions" xreflabel="track_functions">
3331       <term><varname>track_functions</varname> (<type>enum</type>)</term>
3332       <indexterm>
3333        <primary><varname>track_functions</> configuration parameter</primary>
3334       </indexterm>
3335       <listitem>
3336        <para>
3337         Enables tracking of function call counts and time used. Specify
3338         <literal>pl</literal> to count only procedural language functions,
3339         <literal>all</literal> to also track SQL and C language functions.
3340         The default is <literal>none</literal>.
3341         Only superusers can change this setting.
3342        </para>
3343       </listitem>
3344      </varlistentry>
3345
3346      <varlistentry id="guc-update-process-title" xreflabel="update_process_title">
3347       <term><varname>update_process_title</varname> (<type>boolean</type>)</term>
3348       <indexterm>
3349        <primary><varname>update_process_title</> configuration parameter</primary>
3350       </indexterm>
3351       <listitem>
3352        <para>
3353         Enables updating of the process title every time a new SQL command
3354         is received by the server.  The process title is typically viewed
3355         by the <command>ps</> command,
3356         or in Windows by using the <application>Process Explorer</>.
3357         Only superusers can change this setting.
3358        </para>
3359       </listitem>
3360      </varlistentry>
3361
3362      <varlistentry id="guc-stats-temp-directory" xreflabel="stats_temp_directory">
3363       <term><varname>stats_temp_directory</varname> (<type>string</type>)</term>
3364       <indexterm>
3365        <primary><varname>stats_temp_directory</> configuration parameter</primary>
3366       </indexterm>
3367       <listitem>
3368        <para>
3369         Sets the directory to store temporary statistics data in. This can be
3370         a path relative to the data directory or an absolute path. The default
3371         is <filename>pg_stat_tmp</filename>. Pointing this at a RAM based
3372         filesystem will decrease physical I/O requirements and can lead to
3373         improved performance.
3374         This parameter can only be set in the <filename>postgresql.conf</>
3375         file or on the server command line.
3376        </para>
3377       </listitem>
3378      </varlistentry>
3379
3380      </variablelist>
3381     </sect2>
3382
3383     <sect2 id="runtime-config-statistics-monitor">
3384      <title>Statistics Monitoring</title>
3385      <variablelist>
3386
3387      <varlistentry>
3388       <term><varname>log_statement_stats</varname> (<type>boolean</type>)</term>
3389       <term><varname>log_parser_stats</varname> (<type>boolean</type>)</term>
3390       <term><varname>log_planner_stats</varname> (<type>boolean</type>)</term>
3391       <term><varname>log_executor_stats</varname> (<type>boolean</type>)</term>
3392       <indexterm>
3393        <primary><varname>log_statement_stats</> configuration parameter</primary>
3394       </indexterm>
3395       <indexterm>
3396        <primary><varname>log_parser_stats</> configuration parameter</primary>
3397       </indexterm>
3398       <indexterm>
3399        <primary><varname>log_planner_stats</> configuration parameter</primary>
3400       </indexterm>
3401       <indexterm>
3402        <primary><varname>log_executor_stats</> configuration parameter</primary>
3403       </indexterm>
3404       <listitem>
3405        <para>
3406         For each query, write performance statistics of the respective
3407         module to the server log. This is a crude profiling
3408         instrument.  <varname>log_statement_stats</varname> reports total
3409         statement statistics, while the others report per-module statistics.
3410         <varname>log_statement_stats</varname> cannot be enabled together with
3411         any of the per-module options.  All of these options are disabled by
3412         default.   Only superusers can change these settings.
3413        </para>
3414       </listitem>
3415      </varlistentry>
3416
3417      </variablelist>
3418
3419     </sect2>
3420    </sect1>
3421
3422    <sect1 id="runtime-config-autovacuum">
3423     <title>Automatic Vacuuming</title>
3424
3425     <indexterm>
3426      <primary>autovacuum</primary>
3427      <secondary>configuration parameters</secondary>
3428     </indexterm>
3429
3430      <para>
3431       These settings control the behavior of the <firstterm>autovacuum</>
3432       feature.  Refer to <xref linkend="autovacuum"> for
3433       more information.
3434      </para>
3435
3436     <variablelist>
3437
3438      <varlistentry id="guc-autovacuum" xreflabel="autovacuum">
3439       <term><varname>autovacuum</varname> (<type>boolean</type>)</term>
3440       <indexterm>
3441        <primary><varname>autovacuum</> configuration parameter</primary>
3442       </indexterm>
3443       <listitem>
3444        <para>
3445         Controls whether the server should run the
3446         autovacuum launcher daemon.  This is on by default; however,
3447         <xref linkend="guc-track-counts"> must also be turned on for
3448         autovacuum to work.
3449         This parameter can only be set in the <filename>postgresql.conf</>
3450         file or on the server command line.
3451        </para>
3452        <para>
3453         Note that even when this parameter is disabled, the system
3454         will launch autovacuum processes if necessary to
3455         prevent transaction ID wraparound.  See <xref
3456         linkend="vacuum-for-wraparound"> for more information.
3457        </para>
3458       </listitem>
3459      </varlistentry>
3460
3461      <varlistentry id="guc-log-autovacuum-min-duration" xreflabel="log_autovacuum_min_duration">
3462       <term><varname>log_autovacuum_min_duration</varname> (<type>integer</type>)</term>
3463       <indexterm>
3464        <primary><varname>log_autovacuum_min_duration</> configuration parameter</primary>
3465       </indexterm>
3466       <listitem>
3467        <para>
3468         Causes each action executed by autovacuum to be logged if it ran for at
3469         least the specified number of milliseconds.  Setting this to zero logs
3470         all autovacuum actions. Minus-one (the default) disables logging
3471         autovacuum actions.  For example, if you set this to
3472         <literal>250ms</literal> then all automatic vacuums and analyzes that run
3473         250ms or longer will be logged.  Enabling this parameter can be helpful
3474         in tracking autovacuum activity.  This setting can only be set in
3475         the <filename>postgresql.conf</> file or on the server command line.
3476        </para>
3477       </listitem>
3478      </varlistentry>
3479
3480      <varlistentry id="guc-autovacuum-max-workers" xreflabel="autovacuum_max_workers">
3481       <term><varname>autovacuum_max_workers</varname> (<type>integer</type>)</term>
3482       <indexterm>
3483        <primary><varname>autovacuum_max_workers</> configuration parameter</primary>
3484       </indexterm>
3485       <listitem>
3486        <para>
3487         Specifies the maximum number of autovacuum processes (other than the
3488         autovacuum launcher) which may be running at any one time.  The default
3489         is three.  This parameter can only be set in
3490         the <filename>postgresql.conf</> file or on the server command line.
3491        </para>
3492       </listitem>
3493      </varlistentry>
3494
3495      <varlistentry id="guc-autovacuum-naptime" xreflabel="autovacuum_naptime">
3496       <term><varname>autovacuum_naptime</varname> (<type>integer</type>)</term>
3497       <indexterm>
3498        <primary><varname>autovacuum_naptime</> configuration parameter</primary>
3499       </indexterm>
3500       <listitem>
3501        <para>
3502         Specifies the minimum delay between autovacuum runs on any given
3503         database.  In each round the daemon examines the
3504         database and issues <command>VACUUM</> and <command>ANALYZE</> commands
3505         as needed for tables in that database.  The delay is measured
3506         in seconds, and the default is one minute (<literal>1m</>).
3507         This parameter can only be set in the <filename>postgresql.conf</>
3508         file or on the server command line.
3509        </para>
3510       </listitem>
3511      </varlistentry>
3512
3513      <varlistentry id="guc-autovacuum-vacuum-threshold" xreflabel="autovacuum_vacuum_threshold">
3514       <term><varname>autovacuum_vacuum_threshold</varname> (<type>integer</type>)</term>
3515       <indexterm>
3516        <primary><varname>autovacuum_vacuum_threshold</> configuration parameter</primary>
3517       </indexterm>
3518       <listitem>
3519        <para>
3520         Specifies the minimum number of updated or deleted tuples needed
3521         to trigger a <command>VACUUM</> in any one table.
3522         The default is 50 tuples.
3523         This parameter can only be set in the <filename>postgresql.conf</>
3524         file or on the server command line.
3525         This setting can be overridden for individual tables by entries in
3526         <structname>pg_autovacuum</>.
3527        </para>
3528       </listitem>
3529      </varlistentry>
3530
3531      <varlistentry id="guc-autovacuum-analyze-threshold" xreflabel="autovacuum_analyze_threshold">
3532       <term><varname>autovacuum_analyze_threshold</varname> (<type>integer</type>)</term>
3533       <indexterm>
3534        <primary><varname>autovacuum_analyze_threshold</> configuration parameter</primary>
3535       </indexterm>
3536       <listitem>
3537        <para>
3538         Specifies the minimum number of inserted, updated or deleted tuples
3539         needed to trigger an <command>ANALYZE</> in any one table.
3540         The default is 50 tuples.
3541         This parameter can only be set in the <filename>postgresql.conf</>
3542         file or on the server command line.
3543         This setting can be overridden for individual tables by entries in
3544         <structname>pg_autovacuum</>.
3545        </para>
3546       </listitem>
3547      </varlistentry>
3548
3549      <varlistentry id="guc-autovacuum-vacuum-scale-factor" xreflabel="autovacuum_vacuum_scale_factor">
3550       <term><varname>autovacuum_vacuum_scale_factor</varname> (<type>floating point</type>)</term>
3551       <indexterm>
3552        <primary><varname>autovacuum_vacuum_scale_factor</> configuration parameter</primary>
3553       </indexterm>
3554       <listitem>
3555        <para>
3556         Specifies a fraction of the table size to add to
3557         <varname>autovacuum_vacuum_threshold</varname>
3558         when deciding whether to trigger a <command>VACUUM</>.
3559         The default is 0.2 (20% of table size).
3560         This parameter can only be set in the <filename>postgresql.conf</>
3561         file or on the server command line.
3562         This setting can be overridden for individual tables by entries in
3563         <structname>pg_autovacuum</>.
3564        </para>
3565       </listitem>
3566      </varlistentry>
3567
3568      <varlistentry id="guc-autovacuum-analyze-scale-factor" xreflabel="autovacuum_analyze_scale_factor">
3569       <term><varname>autovacuum_analyze_scale_factor</varname> (<type>floating point</type>)</term>
3570       <indexterm>
3571        <primary><varname>autovacuum_analyze_scale_factor</> configuration parameter</primary>
3572       </indexterm>
3573       <listitem>
3574        <para>
3575         Specifies a fraction of the table size to add to
3576         <varname>autovacuum_analyze_threshold</varname>
3577         when deciding whether to trigger an <command>ANALYZE</>.
3578         The default is 0.1 (10% of table size).
3579         This parameter can only be set in the <filename>postgresql.conf</>
3580         file or on the server command line.
3581         This setting can be overridden for individual tables by entries in
3582         <structname>pg_autovacuum</>.
3583        </para>
3584       </listitem>
3585      </varlistentry>
3586
3587      <varlistentry id="guc-autovacuum-freeze-max-age" xreflabel="autovacuum_freeze_max_age">
3588       <term><varname>autovacuum_freeze_max_age</varname> (<type>integer</type>)</term>
3589       <indexterm>
3590        <primary><varname>autovacuum_freeze_max_age</> configuration parameter</primary>
3591       </indexterm>
3592       <listitem>
3593        <para>
3594         Specifies the maximum age (in transactions) that a table's
3595         <structname>pg_class</>.<structfield>relfrozenxid</> field can
3596         attain before a <command>VACUUM</> operation is forced to prevent
3597         transaction ID wraparound within the table.  Note that the system
3598         will launch autovacuum processes to prevent wraparound even when
3599         autovacuum is otherwise disabled.
3600         The default is 200 million transactions.
3601         This parameter can only be set at server start, but the setting
3602         can be reduced for individual tables by entries in
3603         <structname>pg_autovacuum</>.
3604         For more information see <xref linkend="vacuum-for-wraparound">.
3605        </para>
3606       </listitem>
3607      </varlistentry>
3608
3609      <varlistentry id="guc-autovacuum-vacuum-cost-delay" xreflabel="autovacuum_vacuum_cost_delay">
3610       <term><varname>autovacuum_vacuum_cost_delay</varname> (<type>integer</type>)</term>
3611       <indexterm>
3612        <primary><varname>autovacuum_vacuum_cost_delay</> configuration parameter</primary>
3613       </indexterm>
3614       <listitem>
3615        <para>
3616         Specifies the cost delay value that will be used in automatic
3617         <command>VACUUM</> operations.  If <literal>-1</> is
3618         specified, the regular
3619         <xref linkend="guc-vacuum-cost-delay"> value will be used.
3620         The default value is 20 milliseconds.
3621         This parameter can only be set in the <filename>postgresql.conf</>
3622         file or on the server command line.
3623         This setting can be overridden for individual tables by entries in
3624         <structname>pg_autovacuum</>.
3625        </para>
3626       </listitem>
3627      </varlistentry>
3628
3629      <varlistentry id="guc-autovacuum-vacuum-cost-limit" xreflabel="autovacuum_vacuum_cost_limit">
3630       <term><varname>autovacuum_vacuum_cost_limit</varname> (<type>integer</type>)</term>
3631       <indexterm>
3632        <primary><varname>autovacuum_vacuum_cost_limit</> configuration parameter</primary>
3633       </indexterm>
3634       <listitem>
3635        <para>
3636         Specifies the cost limit value that will be used in automatic
3637         <command>VACUUM</> operations.  If <literal>-1</> is specified (which is the
3638         default), the regular
3639         <xref linkend="guc-vacuum-cost-limit"> value will be used.  Note that
3640         the value is distributed proportionally among the running autovacuum
3641         workers, if there is more than one, so that the sum of the limits of
3642         each worker never exceeds the limit on this variable.
3643         This parameter can only be set in the <filename>postgresql.conf</>
3644         file or on the server command line.
3645         This setting can be overridden for individual tables by entries in
3646         <structname>pg_autovacuum</>.
3647        </para>
3648       </listitem>
3649      </varlistentry>
3650
3651     </variablelist>
3652    </sect1>
3653
3654    <sect1 id="runtime-config-client">
3655     <title>Client Connection Defaults</title>
3656
3657     <sect2 id="runtime-config-client-statement">
3658      <title>Statement Behavior</title>
3659      <variablelist>
3660
3661      <varlistentry id="guc-search-path" xreflabel="search_path">
3662       <term><varname>search_path</varname> (<type>string</type>)</term>
3663       <indexterm>
3664        <primary><varname>search_path</> configuration parameter</primary>
3665       </indexterm>
3666       <indexterm><primary>path</><secondary>for schemas</></>
3667       <listitem>
3668        <para>
3669         This variable specifies the order in which schemas are searched
3670         when an object (table, data type, function, etc.) is referenced by a
3671         simple name with no schema component.  When there are objects of
3672         identical names in different schemas, the one found first
3673         in the search path is used.  An object that is not in any of the
3674         schemas in the search path can only be referenced by specifying
3675         its containing schema with a qualified (dotted) name.
3676        </para>
3677
3678        <para>
3679         The value for <varname>search_path</varname> has to be a comma-separated
3680         list of schema names.  If one of the list items is
3681         the special value <literal>$user</literal>, then the schema
3682         having the name returned by <function>SESSION_USER</> is substituted, if there
3683         is such a schema.  (If not, <literal>$user</literal> is ignored.)
3684        </para>
3685
3686        <para>
3687         The system catalog schema, <literal>pg_catalog</>, is always
3688         searched, whether it is mentioned in the path or not.  If it is
3689         mentioned in the path then it will be searched in the specified
3690         order.  If <literal>pg_catalog</> is not in the path then it will
3691         be searched <emphasis>before</> searching any of the path items.
3692        </para>
3693
3694        <para>
3695         Likewise, the current session's temporary-table schema,
3696         <literal>pg_temp_<replaceable>nnn</></>, is always searched if it
3697         exists.  It can be explicitly listed in the path by using the
3698         alias <literal>pg_temp</>.  If it is not listed in the path then
3699         it is searched first (before even <literal>pg_catalog</>).  However,
3700         the temporary schema is only searched for relation (table, view,
3701         sequence, etc) and data type names.  It will never be searched for
3702         function or operator names.
3703        </para>
3704
3705        <para>
3706         When objects are created without specifying a particular target
3707         schema, they will be placed in the first schema listed
3708         in the search path.  An error is reported if the search path is
3709         empty.
3710        </para>
3711
3712        <para>
3713         The default value for this parameter is
3714         <literal>'"$user", public'</literal> (where the second part will be
3715         ignored if there is no schema named <literal>public</>).
3716         This supports shared use of a database (where no users
3717         have private schemas, and all share use of <literal>public</>),
3718         private per-user schemas, and combinations of these.  Other
3719         effects can be obtained by altering the default search path
3720         setting, either globally or per-user.
3721        </para>
3722
3723        <para>
3724         The current effective value of the search path can be examined
3725         via the <acronym>SQL</acronym> function
3726         <function>current_schemas()</>.  This is not quite the same as
3727         examining the value of <varname>search_path</varname>, since
3728         <function>current_schemas()</> shows how the requests
3729         appearing in <varname>search_path</varname> were resolved.
3730        </para>
3731
3732        <para>
3733         For more information on schema handling, see <xref linkend="ddl-schemas">.
3734        </para>
3735       </listitem>
3736      </varlistentry>
3737
3738      <varlistentry id="guc-default-tablespace" xreflabel="default_tablespace">
3739       <term><varname>default_tablespace</varname> (<type>string</type>)</term>
3740       <indexterm>
3741        <primary><varname>default_tablespace</> configuration parameter</primary>
3742       </indexterm>
3743       <indexterm><primary>tablespace</><secondary>default</></>
3744       <listitem>
3745        <para>
3746         This variable specifies the default tablespace in which to create
3747         objects (tables and indexes) when a <command>CREATE</> command does
3748         not explicitly specify a tablespace.
3749        </para>
3750
3751        <para>
3752         The value is either the name of a tablespace, or an empty string
3753         to specify using the default tablespace of the current database.
3754         If the value does not match the name of any existing tablespace,
3755         <productname>PostgreSQL</> will automatically use the default
3756         tablespace of the current database.  If a nondefault tablespace
3757         is specified, the user must have <literal>CREATE</> privilege
3758         for it, or creation attempts will fail.
3759        </para>
3760
3761        <para>
3762         This variable is not used for temporary tables; for them,
3763         <xref linkend="guc-temp-tablespaces"> is consulted instead.
3764        </para>
3765
3766        <para>
3767         For more information on tablespaces,
3768         see <xref linkend="manage-ag-tablespaces">.
3769        </para>
3770       </listitem>
3771      </varlistentry>
3772
3773      <varlistentry id="guc-temp-tablespaces" xreflabel="temp_tablespaces">
3774       <term><varname>temp_tablespaces</varname> (<type>string</type>)</term>
3775       <indexterm>
3776        <primary><varname>temp_tablespaces</> configuration parameter</primary>
3777       </indexterm>
3778       <indexterm><primary>tablespace</><secondary>temporary</></>
3779       <listitem>
3780        <para>
3781         This variable specifies tablespace(s) in which to create temporary
3782         objects (temp tables and indexes on temp tables) when a
3783         <command>CREATE</> command does not explicitly specify a tablespace.
3784         Temporary files for purposes such as sorting large data sets
3785         are also created in these tablespace(s).
3786        </para>
3787
3788        <para>
3789         The value is a list of names of tablespaces.  When there is more than
3790         one name in the list, <productname>PostgreSQL</> chooses a random
3791         member of the list each time a temporary object is to be created;
3792         except that within a transaction, successively created temporary
3793         objects are placed in successive tablespaces from the list.
3794         If the selected element of the list is an empty string,
3795         <productname>PostgreSQL</> will automatically use the default
3796         tablespace of the current database instead.
3797        </para>
3798
3799        <para>
3800         When <varname>temp_tablespaces</> is set interactively, specifying a
3801         nonexistent tablespace is an error, as is specifying a tablespace for
3802         which the user does not have <literal>CREATE</> privilege.  However,
3803         when using a previously set value, nonexistent tablespaces are
3804         ignored, as are tablespaces for which the user lacks
3805         <literal>CREATE</> privilege.  In particular, this rule applies when
3806         using a value set in <filename>postgresql.conf</>.
3807        </para>
3808
3809        <para>
3810         The default value is an empty string, which results in all temporary
3811         objects being created in the default tablespace of the current
3812         database.
3813        </para>
3814
3815        <para>
3816         See also <xref linkend="guc-default-tablespace">.
3817        </para>
3818       </listitem>
3819      </varlistentry>
3820
3821      <varlistentry id="guc-check-function-bodies" xreflabel="check_function_bodies">
3822       <term><varname>check_function_bodies</varname> (<type>boolean</type>)</term>
3823       <indexterm>
3824        <primary><varname>check_function_bodies</> configuration parameter</primary>
3825       </indexterm>
3826       <listitem>
3827        <para>
3828         This parameter is normally on. When set to <literal>off</>, it
3829         disables validation of the function body string during <xref
3830         linkend="sql-createfunction"
3831         endterm="sql-createfunction-title">. Disabling validation is
3832         occasionally useful to avoid problems such as forward references
3833         when restoring function definitions from a dump.
3834        </para>
3835       </listitem>
3836      </varlistentry>
3837
3838      <varlistentry id="guc-default-transaction-isolation" xreflabel="default_transaction_isolation">
3839       <indexterm>
3840        <primary>transaction isolation level</primary>
3841       </indexterm>
3842       <indexterm>
3843        <primary><varname>default_transaction_isolation</> configuration parameter</primary>
3844       </indexterm>
3845       <term><varname>default_transaction_isolation</varname> (<type>enum</type>)</term>
3846       <listitem>
3847        <para>
3848         Each SQL transaction has an isolation level, which can be
3849         either <quote>read uncommitted</quote>, <quote>read
3850         committed</quote>, <quote>repeatable read</quote>, or
3851         <quote>serializable</quote>.  This parameter controls the
3852         default isolation level of each new transaction. The default
3853         is <quote>read committed</quote>.
3854        </para>
3855
3856        <para>
3857         Consult <xref linkend="mvcc"> and <xref
3858         linkend="sql-set-transaction"
3859         endterm="sql-set-transaction-title"> for more information.
3860        </para>
3861       </listitem>
3862      </varlistentry>
3863
3864      <varlistentry id="guc-default-transaction-read-only" xreflabel="default_transaction_read_only">
3865       <indexterm>
3866        <primary>read-only transaction</primary>
3867       </indexterm>
3868       <indexterm>
3869        <primary><varname>default_transaction_read_only</> configuration parameter</primary>
3870       </indexterm>
3871
3872       <term><varname>default_transaction_read_only</varname> (<type>boolean</type>)</term>
3873       <listitem>
3874        <para>
3875         A read-only SQL transaction cannot alter non-temporary tables.
3876         This parameter controls the default read-only status of each new
3877         transaction. The default is <literal>off</> (read/write).
3878        </para>
3879
3880        <para>
3881         Consult <xref linkend="sql-set-transaction"
3882         endterm="sql-set-transaction-title"> for more information.
3883        </para>
3884       </listitem>
3885      </varlistentry>
3886
3887      <varlistentry id="guc-session-replication-role" xreflabel="session_replication_role">
3888       <term><varname>session_replication_role</varname> (<type>enum</type>)</term>
3889       <indexterm>
3890        <primary><varname>session_replication_role</> configuration parameter</primary>
3891       </indexterm>
3892       <listitem>
3893        <para>
3894         Controls firing of replication-related triggers and rules for the
3895         current session.  Setting this variable requires
3896         superuser privilege and results in discarding any previously cached
3897         query plans.  Possible values are <literal>origin</> (the default),
3898         <literal>replica</> and <literal>local</>.
3899         See <xref linkend="sql-altertable" endterm="sql-altertable-title"> for
3900         more information.
3901        </para>
3902       </listitem>
3903      </varlistentry>
3904
3905      <varlistentry id="guc-statement-timeout" xreflabel="statement_timeout">
3906       <term><varname>statement_timeout</varname> (<type>integer</type>)</term>
3907       <indexterm>
3908        <primary><varname>statement_timeout</> configuration parameter</primary>
3909       </indexterm>
3910       <listitem>
3911        <para>
3912         Abort any statement that takes over the specified number of
3913         milliseconds, starting from the time the command arrives at the server
3914         from the client.  If <varname>log_min_error_statement</> is set to
3915         <literal>ERROR</> or lower, the statement that timed out will also be
3916         logged.  A value of zero (the default) turns off the 
3917         limitation.
3918        </para>
3919
3920        <para>
3921         Setting <varname>statement_timeout</> in
3922         <filename>postgresql.conf</> is not recommended because it
3923         affects all sessions.
3924        </para>
3925       </listitem>
3926      </varlistentry>
3927
3928      <varlistentry id="guc-vacuum-freeze-min-age" xreflabel="vacuum_freeze_min_age">
3929       <term><varname>vacuum_freeze_min_age</varname> (<type>integer</type>)</term>
3930       <indexterm>
3931        <primary><varname>vacuum_freeze_min_age</> configuration parameter</primary>
3932       </indexterm>
3933       <listitem>
3934        <para>
3935         Specifies the cutoff age (in transactions) that <command>VACUUM</>
3936         should use to decide whether to replace transaction IDs with
3937         <literal>FrozenXID</> while scanning a table.
3938         The default is 100 million transactions.  Although
3939         users can set this value anywhere from zero to one billion,
3940         <command>VACUUM</> will silently limit the effective value to half
3941         the value of <xref linkend="guc-autovacuum-freeze-max-age">, so
3942         that there is not an unreasonably short time between forced
3943         autovacuums.  For more information see <xref
3944         linkend="vacuum-for-wraparound">.
3945        </para>
3946       </listitem>
3947      </varlistentry>
3948
3949      <varlistentry id="guc-xmlbinary" xreflabel="xmlbinary">
3950       <term><varname>xmlbinary</varname> (<type>enum</type>)</term>
3951       <indexterm>
3952        <primary><varname>xmlbinary</> configuration parameter</primary>
3953       </indexterm>
3954       <listitem>
3955        <para>
3956         Sets how binary values are to be encoded in XML.  This applies
3957         for example when <type>bytea</type> values are converted to
3958         XML by the functions <function>xmlelement</function> or
3959         <function>xmlforest</function>.  Possible values are
3960         <literal>base64</literal> and <literal>hex</literal>, which
3961         are both defined in the XML Schema standard.  The default is
3962         <literal>base64</literal>.  For further information about
3963         XML-related functions, see <xref linkend="functions-xml">.
3964        </para>
3965
3966        <para>
3967         The actual choice here is mostly a matter of taste,
3968         constrained only by possible restrictions in client
3969         applications.  Both methods support all possible values,
3970         although the hex encoding will be somewhat larger than the
3971         base64 encoding.
3972        </para>
3973       </listitem>
3974      </varlistentry>
3975
3976      <varlistentry id="guc-xmloption" xreflabel="xmloption">
3977       <term><varname>xmloption</varname> (<type>enum</type>)</term>
3978       <indexterm>
3979        <primary><varname>xmloption</> configuration parameter</primary>
3980       </indexterm>
3981       <indexterm>
3982        <primary><varname>SET XML OPTION</></primary>
3983       </indexterm>
3984       <indexterm>
3985        <primary>XML option</primary>
3986       </indexterm>
3987       <listitem>
3988        <para>
3989         Sets whether <literal>DOCUMENT</literal> or
3990         <literal>CONTENT</literal> is implicit when converting between
3991         XML and character string values.  See <xref
3992         linkend="datatype-xml"> for a description of this.  Valid
3993         values are <literal>DOCUMENT</literal> and
3994         <literal>CONTENT</literal>.  The default is
3995         <literal>CONTENT</literal>.
3996        </para>
3997
3998        <para>
3999         According to the SQL standard, the command to set this option is
4000 <synopsis>
4001 SET XML OPTION { DOCUMENT | CONTENT };
4002 </synopsis>
4003         This syntax is also available in PostgreSQL.
4004        </para>
4005       </listitem>
4006      </varlistentry>
4007
4008      </variablelist>
4009     </sect2>
4010      <sect2 id="runtime-config-client-format">
4011      <title>Locale and Formatting</title>
4012
4013      <variablelist>
4014
4015      <varlistentry id="guc-datestyle" xreflabel="DateStyle">
4016       <term><varname>DateStyle</varname> (<type>string</type>)</term>
4017       <indexterm>
4018        <primary><varname>DateStyle</> configuration parameter</primary>
4019       </indexterm>
4020       <listitem>
4021        <para>
4022         Sets the display format for date and time values, as well as the
4023         rules for interpreting ambiguous date input values. For
4024         historical reasons, this variable contains two independent
4025         components: the output format specification (<literal>ISO</>,
4026         <literal>Postgres</>, <literal>SQL</>, or <literal>German</>)
4027         and the input/output specification for year/month/day ordering
4028         (<literal>DMY</>, <literal>MDY</>, or <literal>YMD</>). These
4029         can be set separately or together. The keywords <literal>Euro</>
4030         and <literal>European</> are synonyms for <literal>DMY</>; the
4031         keywords <literal>US</>, <literal>NonEuro</>, and
4032         <literal>NonEuropean</> are synonyms for <literal>MDY</>. See
4033         <xref linkend="datatype-datetime"> for more information. The
4034         built-in default is <literal>ISO, MDY</>, but
4035         <application>initdb</application> will initialize the
4036         configuration file with a setting that corresponds to the
4037         behavior of the chosen <varname>lc_time</varname> locale.
4038        </para>
4039       </listitem>
4040      </varlistentry>
4041
4042      <varlistentry id="guc-intervalstyle" xreflabel="IntervalStyle">
4043       <term><varname>IntervalStyle</varname> (<type>enum</type>)</term>
4044       <indexterm>
4045        <primary><varname>IntervalStyle</> configuration parameter</primary>
4046       </indexterm>
4047       <listitem>
4048        <para>
4049         Sets the display format for interval values.
4050         The value <literal>sql_standard</> will produce
4051         output matching <acronym>SQL</acronym> standard interval literals.
4052         The value <literal>postgres</> (which is the default) will produce
4053         output matching <productname>PostgreSQL</> releases prior to 8.4
4054         when the <xref linkend="guc-datestyle">
4055         parameter was set to <literal>ISO</>.
4056         The value <literal>postgres_verbose</> will produce output
4057         matching <productname>PostgreSQL</> releases prior to 8.4
4058         when the <varname>DateStyle</>
4059         parameter was set to non-<literal>ISO</> output.
4060         The value <literal>iso_8601</> will produce output matching the time
4061         interval <quote>format with designators</> defined in section
4062         4.4.3.2 of ISO 8601.
4063        </para>
4064        <para>
4065         The <varname>IntervalStyle</> parameter also affects the
4066         interpretation of ambiguous interval input.  See
4067         <xref linkend="datatype-interval-input"> for more information.
4068        </para>
4069       </listitem>
4070      </varlistentry>
4071
4072      <varlistentry id="guc-timezone" xreflabel="timezone">
4073       <term><varname>timezone</varname> (<type>string</type>)</term>
4074       <indexterm>
4075        <primary><varname>timezone</> configuration parameter</primary>
4076       </indexterm>
4077       <indexterm><primary>time zone</></>
4078       <listitem>
4079        <para>
4080         Sets the time zone for displaying and interpreting time stamps.
4081         The default is <literal>unknown</>, which means to use whatever
4082         the system environment specifies as the time zone.  See <xref
4083         linkend="datatype-timezones"> for more
4084         information.
4085        </para>
4086       </listitem>
4087      </varlistentry>
4088
4089      <varlistentry id="guc-timezone-abbreviations" xreflabel="timezone_abbreviations">
4090       <term><varname>timezone_abbreviations</varname> (<type>string</type>)</term>
4091       <indexterm>
4092        <primary><varname>timezone_abbreviations</> configuration parameter</primary>
4093       </indexterm>
4094       <indexterm><primary>time zone names</></>
4095       <listitem>
4096        <para>
4097         Sets the collection of time zone abbreviations that will be accepted
4098         by the server for datetime input.  The default is <literal>'Default'</>,
4099         which is a collection that works in most of the world; there are
4100         also 'Australia' and 'India', and other collections can be defined
4101         for a particular installation.  See <xref
4102         linkend="datetime-appendix"> for more information.
4103        </para>
4104       </listitem>
4105      </varlistentry>
4106
4107      <varlistentry id="guc-extra-float-digits" xreflabel="extra_float_digits">
4108       <indexterm>
4109        <primary>significant digits</primary>
4110       </indexterm>
4111       <indexterm>
4112        <primary>floating-point</primary>
4113        <secondary>display</secondary>
4114       </indexterm>
4115       <indexterm>
4116        <primary><varname>extra_float_digits</> configuration parameter</primary>
4117       </indexterm>
4118
4119       <term><varname>extra_float_digits</varname> (<type>integer</type>)</term>
4120       <listitem>
4121        <para>
4122         This parameter adjusts the number of digits displayed for
4123         floating-point values, including <type>float4</>, <type>float8</>,
4124         and geometric data types.  The parameter value is added to the
4125         standard number of digits (<literal>FLT_DIG</> or <literal>DBL_DIG</>
4126         as appropriate).  The value can be set as high as 2, to include
4127         partially-significant digits; this is especially useful for dumping
4128         float data that needs to be restored exactly.  Or it can be set
4129         negative to suppress unwanted digits.
4130        </para>
4131       </listitem>
4132      </varlistentry>
4133
4134      <varlistentry id="guc-client-encoding" xreflabel="client_encoding">
4135       <term><varname>client_encoding</varname> (<type>string</type>)</term>
4136       <indexterm>
4137        <primary><varname>client_encoding</> configuration parameter</primary>
4138       </indexterm>
4139       <indexterm><primary>character set</></>
4140       <listitem>
4141        <para>
4142         Sets the client-side encoding (character set).
4143         The default is to use the database encoding.
4144        </para>
4145       </listitem>
4146      </varlistentry>
4147
4148      <varlistentry id="guc-lc-messages" xreflabel="lc_messages">
4149       <term><varname>lc_messages</varname> (<type>string</type>)</term>
4150       <indexterm>
4151        <primary><varname>lc_messages</> configuration parameter</primary>
4152       </indexterm>
4153       <listitem>
4154        <para>
4155         Sets the language in which messages are displayed.  Acceptable
4156         values are system-dependent; see <xref linkend="locale"> for
4157         more information.  If this variable is set to the empty string
4158         (which is the default) then the value is inherited from the
4159         execution environment of the server in a system-dependent way.
4160        </para>
4161
4162        <para>
4163         On some systems, this locale category does not exist.  Setting
4164         this variable will still work, but there will be no effect.
4165         Also, there is a chance that no translated messages for the
4166         desired language exist.  In that case you will continue to see
4167         the English messages.
4168        </para>
4169
4170        <para>
4171         Only superusers can change this setting, because it affects the
4172         messages sent to the server log as well as to the client.
4173        </para>
4174       </listitem>
4175      </varlistentry>
4176
4177      <varlistentry id="guc-lc-monetary" xreflabel="lc_monetary">
4178       <term><varname>lc_monetary</varname> (<type>string</type>)</term>
4179       <indexterm>
4180        <primary><varname>lc_monetary</> configuration parameter</primary>
4181       </indexterm>
4182       <listitem>
4183        <para>
4184         Sets the locale to use for formatting monetary amounts, for
4185         example with the <function>to_char</function> family of
4186         functions.  Acceptable values are system-dependent; see <xref
4187         linkend="locale"> for more information.  If this variable is
4188         set to the empty string (which is the default) then the value
4189         is inherited from the execution environment of the server in a
4190         system-dependent way.
4191        </para>
4192       </listitem>
4193      </varlistentry>
4194
4195      <varlistentry id="guc-lc-numeric" xreflabel="lc_numeric">
4196       <term><varname>lc_numeric</varname> (<type>string</type>)</term>
4197       <indexterm>
4198        <primary><varname>lc_numeric</> configuration parameter</primary>
4199       </indexterm>
4200       <listitem>
4201        <para>
4202         Sets the locale to use for formatting numbers, for example
4203         with the <function>to_char</function> family of
4204         functions. Acceptable values are system-dependent; see <xref
4205         linkend="locale"> for more information.  If this variable is
4206         set to the empty string (which is the default) then the value
4207         is inherited from the execution environment of the server in a
4208         system-dependent way.
4209        </para>
4210       </listitem>
4211      </varlistentry>
4212
4213      <varlistentry id="guc-lc-time" xreflabel="lc_time">
4214       <term><varname>lc_time</varname> (<type>string</type>)</term>
4215       <indexterm>
4216        <primary><varname>lc_time</> configuration parameter</primary>
4217       </indexterm>
4218       <listitem>
4219        <para>
4220         Sets the locale to use for formatting dates and times, for example
4221         with the <function>to_char</function> family of
4222         functions. Acceptable values are system-dependent; see <xref
4223         linkend="locale"> for more information.  If this variable is
4224         set to the empty string (which is the default) then the value
4225         is inherited from the execution environment of the server in a
4226         system-dependent way.
4227        </para>
4228       </listitem>
4229      </varlistentry>
4230
4231      <varlistentry id="guc-default-text-search-config" xreflabel="default_text_search_config">
4232       <term><varname>default_text_search_config</varname> (<type>string</type>)</term>
4233       <indexterm>
4234        <primary><varname>default_text_search_config</> configuration parameter</primary>
4235       </indexterm>
4236       <listitem>
4237        <para>
4238         Selects the text search configuration that is used by those variants
4239         of the text search functions that do not have an explicit argument
4240         specifying the configuration.
4241         See <xref linkend="textsearch"> for further information.
4242         The built-in default is <literal>pg_catalog.simple</>, but
4243         <application>initdb</application> will initialize the
4244         configuration file with a setting that corresponds to the
4245         chosen <varname>lc_ctype</varname> locale, if a configuration
4246         matching that locale can be identified.
4247        </para>
4248       </listitem>
4249      </varlistentry>
4250
4251      </variablelist>
4252
4253     </sect2>
4254      <sect2 id="runtime-config-client-other">
4255      <title>Other Defaults</title>
4256
4257      <variablelist>
4258
4259      <varlistentry id="guc-dynamic-library-path" xreflabel="dynamic_library_path">
4260       <term><varname>dynamic_library_path</varname> (<type>string</type>)</term>
4261       <indexterm>
4262        <primary><varname>dynamic_library_path</> configuration parameter</primary>
4263       </indexterm>
4264       <indexterm><primary>dynamic loading</></>
4265       <listitem>
4266        <para>
4267         If a dynamically loadable module needs to be opened and the
4268         file name specified in the <command>CREATE FUNCTION</command> or
4269         <command>LOAD</command> command
4270         does not have a directory component (i.e. the
4271         name does not contain a slash), the system will search this
4272         path for the required file.
4273        </para>
4274
4275        <para>
4276         The value for <varname>dynamic_library_path</varname> has to be a
4277         list of absolute directory paths separated by colons (or semi-colons
4278         on Windows).  If a list element starts
4279         with the special string <literal>$libdir</literal>, the
4280         compiled-in <productname>PostgreSQL</productname> package
4281         library directory is substituted for <literal>$libdir</literal>. This
4282         is where the modules provided by the standard
4283         <productname>PostgreSQL</productname> distribution are installed.
4284         (Use <literal>pg_config --pkglibdir</literal> to find out the name of
4285         this directory.) For example:
4286 <programlisting>
4287 dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
4288 </programlisting>
4289         or, in a Windows environment:
4290 <programlisting>
4291 dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
4292 </programlisting>
4293        </para>
4294
4295        <para>
4296         The default value for this parameter is
4297         <literal>'$libdir'</literal>. If the value is set to an empty
4298         string, the automatic path search is turned off.
4299        </para>
4300
4301        <para>
4302         This parameter can be changed at run time by superusers, but a
4303         setting done that way will only persist until the end of the
4304         client connection, so this method should be reserved for
4305         development purposes. The recommended way to set this parameter
4306         is in the <filename>postgresql.conf</filename> configuration
4307         file.
4308        </para>
4309       </listitem>
4310      </varlistentry>
4311
4312      <varlistentry id="guc-gin-fuzzy-search-limit" xreflabel="gin_fuzzy_search_limit">
4313       <term><varname>gin_fuzzy_search_limit</varname> (<type>integer</type>)</term>
4314       <indexterm>
4315        <primary><varname>gin_fuzzy_search_limit</> configuration parameter</primary>
4316       </indexterm>
4317       <listitem>
4318        <para>
4319         Soft upper limit of the size of the set returned by GIN index. For more
4320         information see <xref linkend="gin-tips">.
4321        </para>
4322       </listitem>
4323      </varlistentry>
4324
4325      <varlistentry id="guc-local-preload-libraries" xreflabel="local_preload_libraries">
4326       <term><varname>local_preload_libraries</varname> (<type>string</type>)</term>
4327       <indexterm>
4328        <primary><varname>local_preload_libraries</> configuration parameter</primary>
4329       </indexterm>
4330       <indexterm>
4331        <primary><filename>$libdir/plugins</></primary>
4332       </indexterm>
4333       <listitem>
4334        <para>
4335         This variable specifies one or more shared libraries that are
4336         to be preloaded at connection start.  If more than one library
4337         is to be loaded, separate their names with commas.
4338         This parameter cannot be changed after the start of a particular
4339         session.
4340        </para>
4341
4342        <para>
4343         Because this is not a superuser-only option, the libraries
4344         that can be loaded are restricted to those appearing in the
4345         <filename>plugins</> subdirectory of the installation's
4346         standard library directory.  (It is the database administrator's
4347         responsibility to ensure that only <quote>safe</> libraries
4348         are installed there.)  Entries in <varname>local_preload_libraries</>
4349         can specify this directory explicitly, for example
4350         <literal>$libdir/plugins/mylib</literal>, or just specify
4351         the library name &mdash; <literal>mylib</literal> would have
4352         the same effect as <literal>$libdir/plugins/mylib</literal>.
4353        </para>
4354
4355        <para>
4356         There is no performance advantage to loading a library at session
4357         start rather than when it is first used.  Rather, the intent of
4358         this feature is to allow debugging or performance-measurement
4359         libraries to be loaded into specific sessions without an explicit
4360         <command>LOAD</> command being given.  For example, debugging could
4361         be enabled for all sessions under a given user name by setting
4362         this parameter with <command>ALTER USER SET</>.
4363        </para>
4364
4365        <para>
4366         If a specified library is not found,
4367         the connection attempt will fail.
4368        </para>
4369
4370        <para>
4371         Every  PostgreSQL-supported library has a <quote>magic
4372         block</> that is checked to guarantee compatibility.  
4373         For this reason, non-PostgreSQL libraries cannot be
4374         loaded in this way.
4375        </para>
4376       </listitem>
4377      </varlistentry>
4378
4379      </variablelist>
4380     </sect2>
4381    </sect1>
4382
4383    <sect1 id="runtime-config-locks">
4384     <title>Lock Management</title>
4385
4386      <variablelist>
4387
4388      <varlistentry id="guc-deadlock-timeout" xreflabel="deadlock_timeout">
4389       <indexterm>
4390        <primary>deadlock</primary>
4391        <secondary>timeout during</secondary>
4392       </indexterm>
4393       <indexterm>
4394        <primary>timeout</primary>
4395        <secondary>deadlock</secondary>
4396       </indexterm>
4397       <indexterm>
4398        <primary><varname>deadlock_timeout</> configuration parameter</primary>
4399       </indexterm>
4400
4401       <term><varname>deadlock_timeout</varname> (<type>integer</type>)</term>
4402       <listitem>
4403        <para>
4404         This is the amount of time, in milliseconds, to wait on a lock
4405         before checking to see if there is a deadlock condition. The
4406         check for deadlock is relatively slow, so the server doesn't run
4407         it every time it waits for a lock. We optimistically assume
4408         that deadlocks are not common in production applications and
4409         just wait on the lock for a while before starting the check for a
4410         deadlock. Increasing this value reduces the amount of time
4411         wasted in needless deadlock checks, but slows down reporting of
4412         real deadlock errors. The default is one second (<literal>1s</>),
4413         which is probably about the smallest value you would want in
4414         practice. On a heavily loaded server you might want to raise it.
4415         Ideally the setting should exceed your typical transaction time,
4416         so as to improve the odds that a lock will be released before
4417         the waiter decides to check for deadlock.
4418        </para>
4419
4420        <para>
4421         When <xref linkend="guc-log-lock-waits"> is set,
4422         this parameter also determines the length of time to wait before
4423         a log message is issued about the lock wait.  If you are trying
4424         to investigate locking delays you might want to set a shorter than
4425         normal <varname>deadlock_timeout</varname>.
4426        </para>
4427       </listitem>
4428      </varlistentry>
4429
4430      <varlistentry id="guc-max-locks-per-transaction" xreflabel="max_locks_per_transaction">
4431       <term><varname>max_locks_per_transaction</varname> (<type>integer</type>)</term>
4432       <indexterm>
4433        <primary><varname>max_locks_per_transaction</> configuration parameter</primary>
4434       </indexterm>
4435       <listitem>
4436        <para>
4437         The shared lock table is created to track locks on
4438         <varname>max_locks_per_transaction</varname> * (<xref
4439         linkend="guc-max-connections"> + <xref
4440         linkend="guc-max-prepared-transactions">) objects (e.g.  tables);
4441         hence, no more than this many distinct objects can be locked at
4442         any one time.  This parameter controls the average number of object
4443         locks allocated for each transaction;  individual transactions
4444         can lock more objects as long as the locks of all transactions
4445         fit in the lock table.  This is <emphasis>not</> the number of
4446         rows that can be locked; that value is unlimited.  The default,
4447         64, has historically proven sufficient, but you might need to
4448         raise this value if you have clients that touch many different
4449         tables in a single transaction. This parameter can only be set at
4450         server start.
4451        </para>
4452
4453        <para>
4454         Increasing this parameter might cause <productname>PostgreSQL</>
4455         to request more <systemitem class="osname">System V</> shared
4456         memory than your operating system's default configuration
4457         allows. See <xref linkend="sysvipc"> for information on how to
4458         adjust those parameters, if necessary.
4459        </para>
4460       </listitem>
4461      </varlistentry>
4462
4463      </variablelist>
4464    </sect1>
4465
4466    <sect1 id="runtime-config-compatible">
4467     <title>Version and Platform Compatibility</title>
4468
4469     <sect2 id="runtime-config-compatible-version">
4470      <title>Previous PostgreSQL Versions</title>
4471
4472      <variablelist>
4473
4474      <varlistentry id="guc-add-missing-from" xreflabel="add_missing_from">
4475       <term><varname>add_missing_from</varname> (<type>boolean</type>)</term>
4476       <indexterm><primary>FROM</><secondary>missing</></>
4477       <indexterm>
4478        <primary><varname>add_missing_from</> configuration parameter</primary>
4479       </indexterm>
4480       <listitem>
4481        <para>
4482         When on, tables that are referenced by a query will be
4483         automatically added to the <literal>FROM</> clause if not
4484         already present. This behavior does not comply with the SQL
4485         standard and many people dislike it because it can mask mistakes
4486         (such as referencing a table where you should have referenced
4487         its alias). The default is <literal>off</>. This variable can be
4488         enabled for compatibility with releases of
4489         <productname>PostgreSQL</> prior to 8.1, where this behavior was
4490         allowed by default.
4491        </para>
4492
4493        <para>
4494         Note that even when this variable is enabled, a warning
4495         message will be emitted for each implicit <literal>FROM</>
4496         entry referenced by a query. Users are encouraged to update
4497         their applications to not rely on this behavior, by adding all
4498         tables referenced by a query to the query's <literal>FROM</>
4499         clause (or its <literal>USING</> clause in the case of
4500         <command>DELETE</>).
4501        </para>
4502       </listitem>
4503      </varlistentry>
4504
4505      <varlistentry id="guc-array-nulls" xreflabel="array_nulls">
4506       <term><varname>array_nulls</varname> (<type>boolean</type>)</term>
4507       <indexterm>
4508        <primary><varname>array_nulls</> configuration parameter</primary>
4509       </indexterm>
4510       <listitem>
4511        <para>
4512         This controls whether the array input parser recognizes
4513         unquoted <literal>NULL</> as specifying a null array element.
4514         By default, this is <literal>on</>, allowing array values containing
4515         null values to be entered.  However, <productname>PostgreSQL</> versions
4516         before 8.2 did not support null values in arrays, and therefore would
4517         treat <literal>NULL</> as specifying a normal array element with
4518         the string value <quote>NULL</>.  For backwards compatibility with
4519         applications that require the old behavior, this variable can be
4520         turned <literal>off</>.
4521        </para>
4522
4523        <para>
4524         Note that it is possible to create array values containing null values
4525         even when this variable is <literal>off</>.
4526        </para>
4527       </listitem>
4528      </varlistentry>
4529
4530      <varlistentry id="guc-backslash-quote" xreflabel="backslash_quote">
4531       <term><varname>backslash_quote</varname> (<type>enum</type>)</term>
4532       <indexterm><primary>strings</><secondary>backslash quotes</></>
4533       <indexterm>
4534        <primary><varname>backslash_quote</> configuration parameter</primary>
4535       </indexterm>
4536       <listitem>
4537        <para>
4538         This controls whether a quote mark can be represented by
4539         <literal>\'</> in a string literal.  The preferred, SQL-standard way
4540         to represent a quote mark is by doubling it (<literal>''</>) but
4541         <productname>PostgreSQL</> has historically also accepted
4542         <literal>\'</>. However, use of <literal>\'</> creates security risks
4543         because in some client character set encodings, there are multibyte
4544         characters in which the last byte is numerically equivalent to ASCII
4545         <literal>\</>.  If client-side code does escaping incorrectly then a
4546         SQL-injection attack is possible.  This risk can be prevented by
4547         making the server reject queries in which a quote mark appears to be
4548         escaped by a backslash.
4549         The allowed values of <varname>backslash_quote</> are
4550         <literal>on</> (allow <literal>\'</> always),
4551         <literal>off</> (reject always), and
4552         <literal>safe_encoding</> (allow only if client encoding does not
4553         allow ASCII <literal>\</> within a multibyte character).
4554         <literal>safe_encoding</> is the default setting.
4555        </para>
4556
4557        <para>
4558         Note that in a standard-conforming string literal, <literal>\</> just
4559         means <literal>\</> anyway.  This parameter affects the handling of
4560         non-standard-conforming literals, including
4561         escape string syntax (<literal>E'...'</>).
4562        </para>
4563       </listitem>
4564      </varlistentry>
4565
4566      <varlistentry id="guc-default-with-oids" xreflabel="default_with_oids">
4567       <term><varname>default_with_oids</varname> (<type>boolean</type>)</term>
4568       <indexterm>
4569        <primary><varname>default_with_oids</> configuration parameter</primary>
4570       </indexterm>
4571       <listitem>
4572        <para>
4573         This controls whether <command>CREATE TABLE</command> and
4574         <command>CREATE TABLE AS</command> include an OID column in
4575         newly-created tables, if neither <literal>WITH OIDS</literal>
4576         nor <literal>WITHOUT OIDS</literal> is specified. It also
4577         determines whether OIDs will be included in tables created by
4578         <command>SELECT INTO</command>. In <productname>PostgreSQL</>
4579         8.1 <varname>default_with_oids</> is <literal>off</> by default; in
4580         prior versions of <productname>PostgreSQL</productname>, it
4581         was on by default.
4582        </para>
4583
4584        <para>
4585         The use of OIDs in user tables is considered deprecated, so
4586         most installations should leave this variable disabled.
4587         Applications that require OIDs for a particular table should
4588         specify <literal>WITH OIDS</literal> when creating the
4589         table. This variable can be enabled for compatibility with old
4590         applications that do not follow this behavior.
4591        </para>
4592       </listitem>
4593      </varlistentry>
4594
4595      <varlistentry id="guc-escape-string-warning" xreflabel="escape_string_warning">
4596       <term><varname>escape_string_warning</varname> (<type>boolean</type>)</term>
4597       <indexterm><primary>strings</><secondary>escape warning</></>
4598       <indexterm>
4599        <primary><varname>escape_string_warning</> configuration parameter</primary>
4600       </indexterm>
4601       <listitem>
4602        <para>
4603         When on, a warning is issued if a backslash (<literal>\</>)
4604         appears in an ordinary string literal (<literal>'...'</>
4605         syntax) and <varname>standard_conforming_strings</varname> is off.
4606         The default is <literal>on</>.
4607        </para>
4608        <para>
4609         Applications that wish to use backslash as escape should be
4610         modified to use escape string syntax (<literal>E'...'</>),
4611         because the default behavior of ordinary strings will change
4612         in a future release for SQL compatibility.  This variable can
4613         be enabled to help detect applications that will break.
4614        </para>
4615       </listitem>
4616      </varlistentry>
4617
4618      <varlistentry id="guc-regex-flavor" xreflabel="regex_flavor">
4619       <term><varname>regex_flavor</varname> (<type>enum</type>)</term>
4620       <indexterm><primary>regular expressions</></>
4621       <indexterm>
4622        <primary><varname>regex_flavor</> configuration parameter</primary>
4623       </indexterm>
4624       <listitem>
4625        <para>
4626         The regular expression <quote>flavor</> can be set to
4627         <literal>advanced</>, <literal>extended</>, or <literal>basic</>.
4628         The default is <literal>advanced</>.  The <literal>extended</>
4629         setting might be useful for exact backwards compatibility with
4630         pre-7.4 releases of <productname>PostgreSQL</>.  See
4631         <xref linkend="posix-syntax-details"> for details.
4632        </para>
4633       </listitem>
4634      </varlistentry>
4635
4636      <varlistentry id="guc-sql-inheritance" xreflabel="sql_inheritance">
4637       <term><varname>sql_inheritance</varname> (<type>boolean</type>)</term>
4638       <indexterm>
4639        <primary><varname>sql_inheritance</> configuration parameter</primary>
4640       </indexterm>
4641       <indexterm><primary>inheritance</></>
4642       <listitem>
4643        <para>
4644         This controls the inheritance semantics.  If turned <literal>off</>,
4645         subtables are not included by various commands by default; basically
4646         an implied <literal>ONLY</literal> key word.  This was added for 
4647         compatibility with releases prior to 7.1.  See
4648         <xref linkend="ddl-inherit"> for more information.
4649        </para>
4650       </listitem>
4651      </varlistentry>
4652
4653      <varlistentry id="guc-standard-conforming-strings" xreflabel="standard_conforming_strings">
4654       <term><varname>standard_conforming_strings</varname> (<type>boolean</type>)</term>
4655       <indexterm><primary>strings</><secondary>standard conforming</></>
4656       <indexterm>
4657        <primary><varname>standard_conforming_strings</> configuration parameter</primary>
4658       </indexterm>
4659       <listitem>
4660        <para>
4661         This controls whether ordinary string literals
4662         (<literal>'...'</>) treat backslashes literally, as specified in
4663         the SQL standard.
4664         The default is currently <literal>off</>, causing
4665         <productname>PostgreSQL</productname> to have its historical
4666         behavior of treating backslashes as escape characters.
4667         The default will change to <literal>on</> in a future release
4668         to improve compatibility with the standard.
4669         Applications can check this
4670         parameter to determine how string literals will be processed.
4671         The presence of this parameter can also be taken as an indication
4672         that the escape string syntax (<literal>E'...'</>) is supported.
4673         Escape string syntax should be used if an application desires
4674         backslashes to be treated as escape characters.
4675        </para>
4676       </listitem>
4677      </varlistentry>
4678
4679      <varlistentry id="guc-synchronize-seqscans" xreflabel="synchronize_seqscans">
4680       <term><varname>synchronize_seqscans</varname> (<type>boolean</type>)</term>
4681       <indexterm>
4682        <primary><varname>synchronize_seqscans</> configuration parameter</primary>
4683       </indexterm>
4684       <listitem>
4685        <para>
4686         This allows sequential scans of large tables to synchronize with each
4687         other, so that concurrent scans read the same block at about the
4688         same time and hence share the I/O workload.  When this is enabled,
4689         a scan might start in the middle of the table and then <quote>wrap
4690         around</> the end to cover all rows, so as to synchronize with the
4691         activity of scans already in progress.  This can result in
4692         unpredictable changes in the row ordering returned by queries that
4693         have no <literal>ORDER BY</> clause.  Setting this parameter to
4694         <literal>off</> ensures the pre-8.3 behavior in which a sequential
4695         scan always starts from the beginning of the table.  The default
4696         is <literal>on</>.
4697        </para>
4698       </listitem>
4699      </varlistentry>
4700
4701      </variablelist>
4702     </sect2>
4703
4704     <sect2 id="runtime-config-compatible-clients">
4705      <title>Platform and Client Compatibility</title>
4706      <variablelist>
4707
4708      <varlistentry id="guc-transform-null-equals" xreflabel="transform_null_equals">
4709       <term><varname>transform_null_equals</varname> (<type>boolean</type>)</term>
4710       <indexterm><primary>IS NULL</></>
4711       <indexterm>
4712        <primary><varname>transform_null_equals</> configuration parameter</primary>
4713       </indexterm>
4714       <listitem>
4715        <para>
4716         When on, expressions of the form <literal><replaceable>expr</> =
4717         NULL</literal> (or <literal>NULL =
4718         <replaceable>expr</></literal>) are treated as
4719         <literal><replaceable>expr</> IS NULL</literal>, that is, they
4720         return true if <replaceable>expr</> evaluates to the null value,
4721         and false otherwise. The correct SQL-spec-compliant behavior of
4722         <literal><replaceable>expr</> = NULL</literal> is to always
4723         return null (unknown). Therefore this parameter defaults to
4724         <literal>off</>.
4725        </para>
4726
4727        <para>
4728         However, filtered forms in <productname>Microsoft
4729         Access</productname> generate queries that appear to use
4730         <literal><replaceable>expr</> = NULL</literal> to test for
4731         null values, so if you use that interface to access the database you
4732         might want to turn this option on.  Since expressions of the
4733         form <literal><replaceable>expr</> = NULL</literal> always
4734         return the null value (using the correct interpretation) they are not
4735         very useful and do not appear often in normal applications, so
4736         this option does little harm in practice.  But new users are
4737         frequently confused about the semantics of expressions
4738         involving null values, so this option is not on by default.
4739        </para>
4740
4741        <para>
4742         Note that this option only affects the exact form <literal>= NULL</>,
4743         not other comparison operators or other expressions
4744         that are computationally equivalent to some expression
4745         involving the equals operator (such as <literal>IN</literal>).
4746         Thus, this option is not a general fix for bad programming.
4747        </para>
4748
4749        <para>
4750         Refer to <xref linkend="functions-comparison"> for related information.
4751        </para>
4752       </listitem>
4753      </varlistentry>
4754
4755      </variablelist>
4756     </sect2>
4757    </sect1>
4758
4759    <sect1 id="runtime-config-preset">
4760     <title>Preset Options</title>
4761
4762     <para>
4763      The following <quote>parameters</> are read-only, and are determined
4764      when <productname>PostgreSQL</productname> is compiled or when it is
4765      installed. As such, they have been excluded from the sample
4766      <filename>postgresql.conf</> file.  These options report
4767      various aspects of <productname>PostgreSQL</productname> behavior
4768      that might be of interest to certain applications, particularly
4769      administrative front-ends.
4770     </para>
4771
4772     <variablelist>
4773
4774      <varlistentry id="guc-block-size" xreflabel="block_size">
4775       <term><varname>block_size</varname> (<type>integer</type>)</term>
4776       <indexterm>
4777        <primary><varname>block_size</> configuration parameter</primary>
4778       </indexterm>
4779       <listitem>
4780        <para>
4781         Reports the size of a disk block.  It is determined by the value
4782         of <literal>BLCKSZ</> when building the server. The default
4783         value is 8192 bytes.  The meaning of some configuration
4784         variables (such as <xref linkend="guc-shared-buffers">) is
4785         influenced by <varname>block_size</varname>. See <xref
4786         linkend="runtime-config-resource"> for information.
4787        </para>
4788       </listitem>
4789      </varlistentry>
4790
4791      <varlistentry id="guc-integer-datetimes" xreflabel="integer_datetimes">
4792       <term><varname>integer_datetimes</varname> (<type>boolean</type>)</term>
4793       <indexterm>
4794        <primary><varname>integer_datetimes</> configuration parameter</primary>
4795       </indexterm>
4796       <listitem>
4797        <para>
4798         Reports whether <productname>PostgreSQL</> was built with
4799         support for 64-bit-integer dates and times.  This can be
4800         disabled by configuring with <literal>--disable-integer-datetimes</>
4801         when building <productname>PostgreSQL</>.  The default value is
4802         <literal>on</literal>.
4803        </para>
4804       </listitem>
4805      </varlistentry>
4806
4807      <varlistentry id="guc-lc-collate" xreflabel="lc_collate">
4808       <term><varname>lc_collate</varname> (<type>string</type>)</term>
4809       <indexterm>
4810        <primary><varname>lc_collate</> configuration parameter</primary>
4811       </indexterm>
4812       <listitem>
4813        <para>
4814         Reports the locale in which sorting of textual data is done.
4815         See <xref linkend="locale"> for more information.
4816         The value is determined when the database cluster is initialized.
4817        </para>
4818       </listitem>
4819      </varlistentry>
4820
4821      <varlistentry id="guc-lc-ctype" xreflabel="lc_ctype">
4822       <term><varname>lc_ctype</varname> (<type>string</type>)</term>
4823       <indexterm>
4824        <primary><varname>lc_ctype</> configuration parameter</primary>
4825       </indexterm>
4826       <listitem>
4827        <para>
4828         Reports the locale that determines character classifications.
4829         See <xref linkend="locale"> for more information.
4830         The value is determined when the database cluster is initialized.
4831         Ordinarily this will be the same as <varname>lc_collate</varname>,
4832         but for special applications it might be set differently.
4833        </para>
4834       </listitem>
4835      </varlistentry>
4836
4837      <varlistentry id="guc-max-function-args" xreflabel="max_function_args">
4838       <term><varname>max_function_args</varname> (<type>integer</type>)</term>
4839       <indexterm>
4840        <primary><varname>max_function_args</> configuration parameter</primary>
4841       </indexterm>
4842       <listitem>
4843        <para>
4844         Reports the maximum number of function arguments. It is determined by
4845         the value of <literal>FUNC_MAX_ARGS</> when building the server. The
4846         default value is 100 arguments.
4847        </para>
4848       </listitem>
4849      </varlistentry>
4850
4851      <varlistentry id="guc-max-identifier-length" xreflabel="max_identifier_length">
4852       <term><varname>max_identifier_length</varname> (<type>integer</type>)</term>
4853       <indexterm>
4854        <primary><varname>max_identifier_length</> configuration parameter</primary>
4855       </indexterm>
4856       <listitem>
4857        <para>
4858         Reports the maximum identifier length. It is determined as one
4859         less than the value of <literal>NAMEDATALEN</> when building
4860         the server. The default value of <literal>NAMEDATALEN</> is
4861         64; therefore the default
4862         <varname>max_identifier_length</varname> is 63 bytes.
4863        </para>
4864       </listitem>
4865      </varlistentry>
4866
4867      <varlistentry id="guc-max-index-keys" xreflabel="max_index_keys">
4868       <term><varname>max_index_keys</varname> (<type>integer</type>)</term>
4869       <indexterm>
4870        <primary><varname>max_index_keys</> configuration parameter</primary>
4871       </indexterm>
4872       <listitem>
4873        <para>
4874         Reports the maximum number of index keys. It is determined by
4875         the value of <literal>INDEX_MAX_KEYS</> when building the server. The
4876         default value is 32 keys.
4877        </para>
4878       </listitem>
4879      </varlistentry>
4880
4881      <varlistentry id="guc-segment-size" xreflabel="segment_size">
4882       <term><varname>segment_size</varname> (<type>integer</type>)</term>
4883       <indexterm>
4884        <primary><varname>segment_size</> configuration parameter</primary>
4885       </indexterm>
4886       <listitem>
4887        <para>
4888         Reports the number of blocks (pages) that can be stored within a file
4889         segment.  It is determined by the value of <literal>RELSEG_SIZE</>
4890         when building the server.  The maximum size of a segment file in bytes
4891         is equal to <varname>segment_size</> multiplied by
4892         <varname>block_size</>; by default this is 1GB.
4893        </para>
4894       </listitem>
4895      </varlistentry>
4896
4897      <varlistentry id="guc-server-encoding" xreflabel="server_encoding">
4898       <term><varname>server_encoding</varname> (<type>string</type>)</term>
4899       <indexterm>
4900        <primary><varname>server_encoding</> configuration parameter</primary>
4901       </indexterm>
4902       <indexterm><primary>character set</></>
4903       <listitem>
4904        <para>
4905         Reports the database encoding (character set).
4906         It is determined when the database is created.  Ordinarily,
4907         clients need only be concerned with the value of <xref
4908         linkend="guc-client-encoding">.
4909        </para>
4910       </listitem>
4911      </varlistentry>
4912
4913      <varlistentry id="guc-server-version" xreflabel="server_version">
4914       <term><varname>server_version</varname> (<type>string</type>)</term>
4915       <indexterm>
4916        <primary><varname>server_version</> configuration parameter</primary>
4917       </indexterm>
4918       <listitem>
4919        <para>
4920         Reports the version number of the server. It is determined by the
4921         value of <literal>PG_VERSION</> when building the server.
4922        </para>
4923       </listitem>
4924      </varlistentry>
4925
4926      <varlistentry id="guc-server-version-num" xreflabel="server_version_num">
4927       <term><varname>server_version_num</varname> (<type>integer</type>)</term>
4928       <indexterm>
4929        <primary><varname>server_version_num</> configuration parameter</primary>
4930       </indexterm>
4931       <listitem>
4932        <para>
4933         Reports the version number of the server as an integer. It is determined
4934         by the value of <literal>PG_VERSION_NUM</> when building the server.
4935        </para>
4936       </listitem>
4937      </varlistentry>
4938
4939      <varlistentry id="guc-wal-block-size" xreflabel="wal_block_size">
4940       <term><varname>wal_block_size</varname> (<type>integer</type>)</term>
4941       <indexterm>
4942        <primary><varname>wal_block_size</> configuration parameter</primary>
4943       </indexterm>
4944       <listitem>
4945        <para>
4946         Reports the size of a WAL disk block.  It is determined by the value
4947         of <literal>XLOG_BLCKSZ</> when building the server. The default value
4948         is 8192 bytes.
4949        </para>
4950       </listitem>
4951      </varlistentry>
4952
4953      <varlistentry id="guc-wal-segment-size" xreflabel="wal_segment_size">
4954       <term><varname>wal_segment_size</varname> (<type>integer</type>)</term>
4955       <indexterm>
4956        <primary><varname>wal_segment_size</> configuration parameter</primary>
4957       </indexterm>
4958       <listitem>
4959        <para>
4960         Reports the number of blocks (pages) in a WAL segment file.
4961         The total size of a WAL segment file in bytes is equal to
4962         <varname>wal_segment_size</> multiplied by <varname>wal_block_size</>;
4963         by default this is 16MB.  See <xref linkend="wal-configuration"> for
4964         more information.
4965        </para>
4966       </listitem>
4967      </varlistentry>
4968
4969     </variablelist>
4970    </sect1>
4971
4972    <sect1 id="runtime-config-custom">
4973     <title>Customized Options</title>
4974
4975     <para>
4976      This feature was designed to allow parameters not normally known to
4977      <productname>PostgreSQL</productname> to be added by add-on modules
4978      (such as procedural languages).  This allows add-on modules to be
4979      configured in the standard ways.
4980     </para>
4981
4982     <variablelist>
4983
4984      <varlistentry id="guc-custom-variable-classes" xreflabel="custom_variable_classes">
4985       <term><varname>custom_variable_classes</varname> (<type>string</type>)</term>
4986       <indexterm>
4987        <primary><varname>custom_variable_classes</> configuration parameter</primary>
4988       </indexterm>
4989       <listitem>
4990        <para>
4991         This variable specifies one or several class names to be used for
4992         custom variables, in the form of a comma-separated list. A custom
4993         variable is a variable not normally known
4994         to <productname>PostgreSQL</productname> proper but used by some
4995         add-on module.  Such variables must have names consisting of a class
4996         name, a dot, and a variable name.  <varname>custom_variable_classes</>
4997         specifies all the class names in use in a particular installation.
4998         This parameter can only be set in the <filename>postgresql.conf</>
4999         file or on the server command line.
5000        </para>
5001
5002       </listitem>
5003      </varlistentry>
5004     </variablelist>
5005
5006     <para>
5007      The difficulty with setting custom variables in
5008      <filename>postgresql.conf</> is that the file must be read before add-on
5009      modules have been loaded, and so custom variables would ordinarily be
5010      rejected as unknown.  When <varname>custom_variable_classes</> is set,
5011      the server will accept definitions of arbitrary variables within each
5012      specified class.  These variables will be treated as placeholders and
5013      will have no function until the module that defines them is loaded. When a
5014      module for a specific class is loaded, it will add the proper variable
5015      definitions for its class name, convert any placeholder
5016      values according to those definitions, and issue warnings for any
5017      placeholders of its class that remain (which presumably would be
5018      misspelled configuration variables).
5019     </para>
5020
5021     <para>
5022      Here is an example of what <filename>postgresql.conf</> might contain
5023      when using custom variables:
5024
5025 <programlisting>
5026 custom_variable_classes = 'plr,plperl'
5027 plr.path = '/usr/lib/R'
5028 plperl.use_strict = true
5029 plruby.use_strict = true        # generates error: unknown class name
5030 </programlisting>
5031     </para>
5032    </sect1>
5033
5034    <sect1 id="runtime-config-developer">
5035     <title>Developer Options</title>
5036
5037     <para>
5038      The following parameters are intended for work on the
5039      <productname>PostgreSQL</productname> source, and in some cases
5040      to assist with recovery of severely damaged databases.  There
5041      should be no reason to use them in a production database setup.
5042      As such, they have been excluded from the sample
5043      <filename>postgresql.conf</> file.  Note that many of these
5044      parameters require special source compilation flags to work at all.
5045     </para>
5046
5047     <variablelist>
5048      <varlistentry id="guc-allow-system-table-mods" xreflabel="allow_system_table_mods">
5049       <term><varname>allow_system_table_mods</varname> (<type>boolean</type>)</term>
5050       <indexterm>
5051         <primary><varname>allow_system_table_mods</varname> configuration parameter</primary>
5052       </indexterm>
5053       <listitem>
5054        <para>
5055         Allows modification of the structure of system tables.
5056         This is used by <command>initdb</command>.
5057         This parameter can only be set at server start.
5058        </para>
5059       </listitem>
5060      </varlistentry>
5061
5062      <varlistentry id="guc-debug-assertions" xreflabel="debug_assertions">
5063       <term><varname>debug_assertions</varname> (<type>boolean</type>)</term>
5064       <indexterm>
5065        <primary><varname>debug_assertions</> configuration parameter</primary>
5066       </indexterm>
5067       <listitem>
5068        <para>
5069         Turns on various assertion checks. This is a debugging aid. If
5070         you are experiencing strange problems or crashes you might want
5071         to turn this on, as it might expose programming mistakes. To use
5072         this parameter, the macro <symbol>USE_ASSERT_CHECKING</symbol>
5073         must be defined when <productname>PostgreSQL</productname> is
5074         built (accomplished by the <command>configure</command> option
5075         <option>--enable-cassert</option>). Note that
5076         <varname>debug_assertions</varname> defaults to <literal>on</>
5077         if <productname>PostgreSQL</productname> has been built with
5078         assertions enabled.
5079        </para>
5080       </listitem>
5081      </varlistentry>
5082
5083      <varlistentry id="guc-ignore-system-indexes" xreflabel="ignore_system_indexes">
5084       <term><varname>ignore_system_indexes</varname> (<type>boolean</type>)</term>
5085       <indexterm>
5086         <primary><varname>ignore_system_indexes</varname> configuration parameter</primary>
5087       </indexterm>
5088       <listitem>
5089        <para>
5090         Ignore system indexes when reading system tables (but still
5091         update the indexes when modifying the tables).  This is useful
5092         when recovering from damaged system indexes.
5093         This parameter cannot be changed after session start.
5094        </para>
5095       </listitem>
5096      </varlistentry>
5097
5098      <varlistentry id="guc-post-auth-delay" xreflabel="post_auth_delay">
5099       <term><varname>post_auth_delay</varname> (<type>integer</type>)</term>
5100       <indexterm>
5101        <primary><varname>post_auth_delay</> configuration parameter</primary>
5102       </indexterm>
5103       <listitem>
5104        <para>
5105         If nonzero, a delay of this many seconds occurs when a new
5106         server process is started, after it conducts the
5107         authentication procedure.  This is intended to give an
5108         opportunity to attach to the server process with a debugger.
5109         This parameter cannot be changed after session start.
5110        </para>
5111       </listitem>
5112      </varlistentry>
5113
5114      <varlistentry id="guc-pre-auth-delay" xreflabel="pre_auth_delay">
5115       <term><varname>pre_auth_delay</varname> (<type>integer</type>)</term>
5116       <indexterm>
5117        <primary><varname>pre_auth_delay</> configuration parameter</primary>
5118       </indexterm>
5119       <listitem>
5120        <para>
5121         If nonzero, a delay of this many seconds occurs just after a
5122         new server process is forked, before it conducts the
5123         authentication procedure.  This is intended to give an
5124         opportunity to attach to the server process with a debugger to
5125         trace down misbehavior in authentication.
5126         This parameter can only be set in the <filename>postgresql.conf</>
5127         file or on the server command line.
5128        </para>
5129       </listitem>
5130      </varlistentry>
5131
5132      <varlistentry id="guc-trace-notify" xreflabel="trace_notify">
5133       <term><varname>trace_notify</varname> (<type>boolean</type>)</term>
5134       <indexterm>
5135        <primary><varname>trace_notify</> configuration parameter</primary>
5136       </indexterm>
5137       <listitem>
5138        <para>
5139         Generates a great amount of debugging output for the
5140         <command>LISTEN</command> and <command>NOTIFY</command>
5141         commands.  <xref linkend="guc-client-min-messages"> or
5142         <xref linkend="guc-log-min-messages"> must be
5143         <literal>DEBUG1</literal> or lower to send this output to the
5144         client or server log, respectively.
5145        </para>
5146       </listitem>
5147      </varlistentry>
5148
5149      <varlistentry id="guc-trace-sort" xreflabel="trace_sort">
5150       <term><varname>trace_sort</varname> (<type>boolean</type>)</term>
5151       <indexterm>
5152        <primary><varname>trace_sort</> configuration parameter</primary>
5153       </indexterm>
5154       <listitem>
5155        <para>
5156         If on, emit information about resource usage during sort operations.
5157         This parameter is only available if the <symbol>TRACE_SORT</symbol> macro
5158         was defined when <productname>PostgreSQL</productname> was compiled.
5159         (However, <symbol>TRACE_SORT</symbol> is currently defined by default.)
5160        </para>
5161       </listitem>
5162      </varlistentry>
5163
5164      <varlistentry>
5165       <term><varname>trace_locks</varname> (<type>boolean</type>)</term>
5166       <indexterm>
5167        <primary><varname>trace_locks</> configuration parameter</primary>
5168       </indexterm>
5169       <listitem>
5170        <para>
5171         If on, emit information about lock usage.  Information dumped
5172         includes the type of lock operation, the type of lock and the unique
5173         identifier of the object being locked or unlocked.  Also included
5174         are bitmasks for the lock types already granted on this object as
5175         well as for the lock types awaited on this object.  For each lock
5176         type a count of the number of granted locks and waiting locks is
5177         also dumped as well as the totals.  An example of the log file output
5178         is shown here:
5179        </para>
5180        <para>
5181         LOG:  LockAcquire: new: lock(0xb7acd844) id(24688,24696,0,0,0,1)
5182               grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
5183               wait(0) type(AccessShareLock)
5184        </para>
5185        <para>
5186         LOG:  GrantLock: lock(0xb7acd844) id(24688,24696,0,0,0,1)
5187               grantMask(2) req(1,0,0,0,0,0,0)=1 grant(1,0,0,0,0,0,0)=1
5188               wait(0) type(AccessShareLock)
5189
5190        </para>
5191        <para>
5192         LOG:  UnGrantLock: updated: lock(0xb7acd844) id(24688,24696,0,0,0,1)
5193               grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
5194               wait(0) type(AccessShareLock)
5195        </para>
5196        <para>
5197         LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
5198               grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
5199               wait(0) type(INVALID)
5200        </para>
5201        <para>
5202         Details of the structure being dumped may be found in
5203         src/include/storage/lock.h
5204        </para>
5205        <para>
5206         This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5207         macro was defined when <productname>PostgreSQL</productname> was
5208         compiled.
5209        </para>
5210       </listitem>
5211      </varlistentry>
5212
5213      <varlistentry>
5214       <term><varname>trace_lwlocks</varname> (<type>boolean</type>)</term>
5215       <indexterm>
5216        <primary><varname>trace_lwlocks</> configuration parameter</primary>
5217       </indexterm>
5218       <listitem>
5219        <para>
5220         If on, emit information about lightweight lock usage.  Lightweight
5221         locks are intended primarily to provide mutual exclusion of access
5222         to shared-memory data structures.
5223        </para>
5224        <para>
5225         This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5226         macro was defined when <productname>PostgreSQL</productname> was
5227         compiled.
5228        </para>
5229       </listitem>
5230      </varlistentry>
5231
5232      <varlistentry>
5233       <term><varname>trace_userlocks</varname> (<type>boolean</type>)</term>
5234       <indexterm>
5235        <primary><varname>trace_userlocks</> configuration parameter</primary>
5236       </indexterm>
5237       <listitem>
5238        <para>
5239         If on, emit information about user lock usage.  Output is the same
5240         as for <symbol>trace_locks</symbol>, only for user locks.
5241        </para>
5242        <para>
5243         User locks were removed as of PostgreSQL version 8.2.  This option
5244         currently has no effect.
5245        </para>
5246        <para>
5247         This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5248         macro was defined when <productname>PostgreSQL</productname> was
5249         compiled.
5250        </para>
5251       </listitem>
5252      </varlistentry>
5253
5254      <varlistentry>
5255       <term><varname>trace_lock_oidmin</varname> (<type>integer</type>)</term>
5256       <indexterm>
5257        <primary><varname>trace_lock_oidmin</> configuration parameter</primary>
5258       </indexterm>
5259       <listitem>
5260        <para>
5261         If set, do not trace locks for tables below this OID. (use to avoid
5262         output on system tables)
5263        </para>
5264        <para>
5265         This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5266         macro was defined when <productname>PostgreSQL</productname> was
5267         compiled.
5268        </para>
5269       </listitem>
5270      </varlistentry>
5271
5272      <varlistentry>
5273       <term><varname>trace_lock_table</varname> (<type>integer</type>)</term>
5274       <indexterm>
5275        <primary><varname>trace_lock_table</> configuration parameter</primary>
5276       </indexterm>
5277       <listitem>
5278        <para>
5279         Unconditionally trace locks on this table (OID).
5280        </para>
5281        <para>
5282         This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5283         macro was defined when <productname>PostgreSQL</productname> was
5284         compiled.
5285        </para>
5286       </listitem>
5287      </varlistentry>
5288
5289      <varlistentry>
5290       <term><varname>debug_deadlocks</varname> (<type>boolean</type>)</term>
5291       <indexterm>
5292        <primary><varname>debug_deadlocks</> configuration parameter</primary>
5293       </indexterm>
5294       <listitem>
5295        <para>
5296         If set, dumps information about all current locks when a
5297         DeadLockTimeout occurs.
5298        </para>
5299        <para>
5300         This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5301         macro was defined when <productname>PostgreSQL</productname> was
5302         compiled.
5303        </para>
5304       </listitem>
5305      </varlistentry>
5306
5307      <varlistentry>
5308       <term><varname>log_btree_build_stats</varname> (<type>boolean</type>)</term>
5309       <indexterm>
5310        <primary><varname>log_btree_build_stats</> configuration parameter</primary>
5311       </indexterm>
5312       <listitem>
5313        <para>
5314         If set, logs system resource usage statistics (memory and CPU) on
5315         various btree operations.
5316        </para>
5317        <para>
5318         This parameter is only available if the <symbol>BTREE_BUILD_STATS</symbol>
5319         macro was defined when <productname>PostgreSQL</productname> was
5320         compiled.
5321        </para>
5322       </listitem>
5323      </varlistentry>
5324
5325      <varlistentry id="guc-wal-debug" xreflabel="wal_debug">
5326       <term><varname>wal_debug</varname> (<type>boolean</type>)</term>
5327       <indexterm>
5328        <primary><varname>wal_debug</> configuration parameter</primary>
5329       </indexterm>
5330       <listitem>
5331        <para>
5332         If on, emit WAL-related debugging output. This parameter is
5333         only available if the <symbol>WAL_DEBUG</symbol> macro was
5334         defined when <productname>PostgreSQL</productname> was
5335         compiled.
5336        </para>
5337       </listitem>
5338      </varlistentry>
5339
5340     <varlistentry id="guc-zero-damaged-pages" xreflabel="zero_damaged_pages">
5341       <term><varname>zero_damaged_pages</varname> (<type>boolean</type>)</term>
5342       <indexterm>
5343        <primary><varname>zero_damaged_pages</> configuration parameter</primary>
5344       </indexterm>
5345       <listitem>
5346        <para>
5347         Detection of a damaged page header normally causes
5348         <productname>PostgreSQL</> to report an error, aborting the current
5349         command.  Setting <varname>zero_damaged_pages</> to on causes
5350         the system to instead report a warning, zero out the damaged page,
5351         and continue processing.  This behavior <emphasis>will destroy data</>,
5352         namely all the rows on the damaged page.  But it allows you to get
5353         past the error and retrieve rows from any undamaged pages that might
5354         be present in the table.  So it is useful for recovering data if
5355         corruption has occurred due to hardware or software error.  You should
5356         generally not set this on until you have given up hope of recovering
5357         data from the damaged page(s) of a table.  The
5358         default setting is <literal>off</>, and it can only be changed
5359         by a superuser.
5360        </para>
5361       </listitem>
5362      </varlistentry>
5363    </variablelist>
5364   </sect1>
5365   <sect1 id="runtime-config-short">
5366    <title>Short Options</title>
5367
5368    <para>
5369     For convenience there are also single letter command-line option
5370     switches available for some parameters.  They are described in
5371     <xref linkend="runtime-config-short-table">.  Some of these
5372     options exist for historical reasons, and their presence as a
5373     single-letter option does not necessarily indicate an endorsement
5374     to use the option heavily.
5375    </para>
5376
5377     <table id="runtime-config-short-table">
5378      <title>Short option key</title>
5379      <tgroup cols="2">
5380       <thead>
5381        <row>
5382         <entry>Short option</entry>
5383         <entry>Equivalent</entry>
5384        </row>
5385       </thead>
5386
5387       <tbody>
5388        <row>
5389         <entry><option>-A <replaceable>x</replaceable></option></entry>
5390         <entry><literal>debug_assertions = <replaceable>x</replaceable></></entry>
5391        </row>
5392        <row>
5393         <entry><option>-B <replaceable>x</replaceable></option></entry>
5394         <entry><literal>shared_buffers = <replaceable>x</replaceable></></entry>
5395        </row>
5396        <row>
5397         <entry><option>-d <replaceable>x</replaceable></option></entry>
5398         <entry><literal>log_min_messages = DEBUG<replaceable>x</replaceable></></entry>
5399        </row>
5400        <row>
5401         <entry><option>-e</option></entry>
5402         <entry><literal>datestyle = euro</></entry>
5403        </row>
5404        <row>
5405         <entry>
5406           <option>-fb</option>, <option>-fh</option>, <option>-fi</option>,
5407           <option>-fm</option>, <option>-fn</option>,
5408           <option>-fs</option>, <option>-ft</option>
5409          </entry>
5410          <entry>
5411           <literal>enable_bitmapscan = off</>,
5412           <literal>enable_hashjoin = off</>,
5413           <literal>enable_indexscan = off</>,
5414           <literal>enable_mergejoin = off</>,
5415           <literal>enable_nestloop = off</>,
5416           <literal>enable_seqscan = off</>,
5417           <literal>enable_tidscan = off</>
5418          </entry>
5419        </row>
5420        <row>
5421         <entry><option>-F</option></entry>
5422         <entry><literal>fsync = off</></entry>
5423        </row>
5424        <row>
5425         <entry><option>-h <replaceable>x</replaceable></option></entry>
5426         <entry><literal>listen_addresses = <replaceable>x</replaceable></></entry>
5427        </row>
5428        <row>
5429         <entry><option>-i</option></entry>
5430         <entry><literal>listen_addresses = '*'</></entry>
5431        </row>
5432        <row>
5433         <entry><option>-k <replaceable>x</replaceable></option></entry>
5434         <entry><literal>unix_socket_directory = <replaceable>x</replaceable></></entry>
5435        </row>
5436        <row>
5437         <entry><option>-l</option></entry>
5438         <entry><literal>ssl = on</></entry>
5439        </row>
5440        <row>
5441         <entry><option>-N <replaceable>x</replaceable></option></entry>
5442         <entry><literal>max_connections = <replaceable>x</replaceable></></entry>
5443        </row>
5444        <row>
5445         <entry><option>-O</option></entry>
5446         <entry><literal>allow_system_table_mods = on</></entry>
5447        </row>
5448        <row>
5449         <entry><option>-p <replaceable>x</replaceable></option></entry>
5450         <entry><literal>port = <replaceable>x</replaceable></></entry>
5451        </row>
5452        <row>
5453         <entry><option>-P</option></entry>
5454         <entry><literal>ignore_system_indexes = on</></entry>
5455        </row>
5456        <row>
5457         <entry><option>-s</option></entry>
5458         <entry><literal>log_statement_stats = on</></entry>
5459        </row>
5460        <row>
5461         <entry><option>-S <replaceable>x</replaceable></option></entry>
5462         <entry><literal>work_mem = <replaceable>x</replaceable></></entry>
5463        </row>
5464        <row>
5465         <entry><option>-tpa</option>, <option>-tpl</option>, <option>-te</option></entry>
5466         <entry><literal>log_parser_stats = on</>,
5467         <literal>log_planner_stats = on</>, 
5468         <literal>log_executor_stats = on</></entry>
5469        </row>
5470        <row>
5471         <entry><option>-W <replaceable>x</replaceable></option></entry>
5472         <entry><literal>post_auth_delay = <replaceable>x</replaceable></></entry>
5473        </row>
5474       </tbody>
5475      </tgroup>
5476     </table>
5477
5478   </sect1>
5479 </chapter>