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