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