Add vacuum_freeze_table_age GUC option, to control when VACUUM should
[PostgreSQL.git] / doc / src / sgml / config.sgml
blobec9a46d778a02ff80ffb607d92fdcd80f6be3f26
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 disables the prepared-transaction
789 feature.
790 The default is five transactions.
791 This parameter can only be set at server start.
792 </para>
794 <para>
795 If you are not using prepared transactions, this parameter may as
796 well be set to zero. If you are using them, you will probably
797 want <varname>max_prepared_transactions</varname> to be at least
798 as large as <xref linkend="guc-max-connections">, to avoid unwanted
799 failures at the prepare step.
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. To enable it, set the
1014 <varname>vacuum_cost_delay</varname> variable to a nonzero
1015 value.
1016 </para>
1018 <variablelist>
1019 <varlistentry id="guc-vacuum-cost-delay" xreflabel="vacuum_cost_delay">
1020 <term><varname>vacuum_cost_delay</varname> (<type>integer</type>)</term>
1021 <indexterm>
1022 <primary><varname>vacuum_cost_delay</> configuration parameter</primary>
1023 </indexterm>
1024 <listitem>
1025 <para>
1026 The length of time, in milliseconds, that the process will sleep
1027 when the cost limit has been exceeded.
1028 The default value is zero, which disables the cost-based vacuum
1029 delay feature. Positive values enable cost-based vacuuming.
1030 Note that on many systems, the effective resolution
1031 of sleep delays is 10 milliseconds; setting
1032 <varname>vacuum_cost_delay</varname> to a value that is
1033 not a multiple of 10 might have the same results as setting it
1034 to the next higher multiple of 10.
1035 </para>
1036 </listitem>
1037 </varlistentry>
1039 <varlistentry id="guc-vacuum-cost-page-hit" xreflabel="vacuum_cost_page_hit">
1040 <term><varname>vacuum_cost_page_hit</varname> (<type>integer</type>)</term>
1041 <indexterm>
1042 <primary><varname>vacuum_cost_page_hit</> configuration parameter</primary>
1043 </indexterm>
1044 <listitem>
1045 <para>
1046 The estimated cost for vacuuming a buffer found in the shared buffer
1047 cache. It represents the cost to lock the buffer pool, lookup
1048 the shared hash table and scan the content of the page. The
1049 default value is one.
1050 </para>
1051 </listitem>
1052 </varlistentry>
1054 <varlistentry id="guc-vacuum-cost-page-miss" xreflabel="vacuum_cost_page_miss">
1055 <term><varname>vacuum_cost_page_miss</varname> (<type>integer</type>)</term>
1056 <indexterm>
1057 <primary><varname>vacuum_cost_page_miss</> configuration parameter</primary>
1058 </indexterm>
1059 <listitem>
1060 <para>
1061 The estimated cost for vacuuming a buffer that has to be read from
1062 disk. This represents the effort to lock the buffer pool,
1063 lookup the shared hash table, read the desired block in from
1064 the disk and scan its content. The default value is 10.
1065 </para>
1066 </listitem>
1067 </varlistentry>
1069 <varlistentry id="guc-vacuum-cost-page-dirty" xreflabel="vacuum_cost_page_dirty">
1070 <term><varname>vacuum_cost_page_dirty</varname> (<type>integer</type>)</term>
1071 <indexterm>
1072 <primary><varname>vacuum_cost_page_dirty</> configuration parameter</primary>
1073 </indexterm>
1074 <listitem>
1075 <para>
1076 The estimated cost charged when vacuum modifies a block that was
1077 previously clean. It represents the extra I/O required to
1078 flush the dirty block out to disk again. The default value is
1080 </para>
1081 </listitem>
1082 </varlistentry>
1084 <varlistentry id="guc-vacuum-cost-limit" xreflabel="vacuum_cost_limit">
1085 <term><varname>vacuum_cost_limit</varname> (<type>integer</type>)</term>
1086 <indexterm>
1087 <primary><varname>vacuum_cost_limit</> configuration parameter</primary>
1088 </indexterm>
1089 <listitem>
1090 <para>
1091 The accumulated cost that will cause the vacuuming process to sleep.
1092 The default value is 200.
1093 </para>
1094 </listitem>
1095 </varlistentry>
1096 </variablelist>
1098 <note>
1099 <para>
1100 There are certain operations that hold critical locks and should
1101 therefore complete as quickly as possible. Cost-based vacuum
1102 delays do not occur during such operations. Therefore it is
1103 possible that the cost accumulates far higher than the specified
1104 limit. To avoid uselessly long delays in such cases, the actual
1105 delay is calculated as <varname>vacuum_cost_delay</varname> *
1106 <varname>accumulated_balance</varname> /
1107 <varname>vacuum_cost_limit</varname> with a maximum of
1108 <varname>vacuum_cost_delay</varname> * 4.
1109 </para>
1110 </note>
1111 </sect2>
1113 <sect2 id="runtime-config-resource-background-writer">
1114 <title>Background Writer</title>
1116 <para>
1117 There is a separate server
1118 process called the <firstterm>background writer</>, whose function
1119 is to issue writes of <quote>dirty</> shared buffers. The intent is
1120 that server processes handling user queries should seldom or never have
1121 to wait for a write to occur, because the background writer will do it.
1122 However there is a net overall
1123 increase in I/O load, because a repeatedly-dirtied page might
1124 otherwise be written only once per checkpoint interval, but the
1125 background writer might write it several times in the same interval.
1126 The parameters discussed in this subsection can be used to
1127 tune the behavior for local needs.
1128 </para>
1130 <variablelist>
1131 <varlistentry id="guc-bgwriter-delay" xreflabel="bgwriter_delay">
1132 <term><varname>bgwriter_delay</varname> (<type>integer</type>)</term>
1133 <indexterm>
1134 <primary><varname>bgwriter_delay</> configuration parameter</primary>
1135 </indexterm>
1136 <listitem>
1137 <para>
1138 Specifies the delay between activity rounds for the
1139 background writer. In each round the writer issues writes
1140 for some number of dirty buffers (controllable by the
1141 following parameters). It then sleeps for <varname>bgwriter_delay</>
1142 milliseconds, and repeats. The default value is 200 milliseconds
1143 (<literal>200ms</>). Note that on many systems, the effective
1144 resolution of sleep delays is 10 milliseconds; setting
1145 <varname>bgwriter_delay</> to a value that is not a multiple of
1146 10 might have the same results as setting it to the next higher
1147 multiple of 10. This parameter can only be set in the
1148 <filename>postgresql.conf</> file or on the server command line.
1149 </para>
1150 </listitem>
1151 </varlistentry>
1153 <varlistentry id="guc-bgwriter-lru-maxpages" xreflabel="bgwriter_lru_maxpages">
1154 <term><varname>bgwriter_lru_maxpages</varname> (<type>integer</type>)</term>
1155 <indexterm>
1156 <primary><varname>bgwriter_lru_maxpages</> configuration parameter</primary>
1157 </indexterm>
1158 <listitem>
1159 <para>
1160 In each round, no more than this many buffers will be written
1161 by the background writer. Setting this to zero disables
1162 background writing (except for checkpoint activity).
1163 The default value is 100 buffers.
1164 This parameter can only be set in the <filename>postgresql.conf</>
1165 file or on the server command line.
1166 </para>
1167 </listitem>
1168 </varlistentry>
1170 <varlistentry id="guc-bgwriter-lru-multiplier" xreflabel="bgwriter_lru_multiplier">
1171 <term><varname>bgwriter_lru_multiplier</varname> (<type>floating point</type>)</term>
1172 <indexterm>
1173 <primary><varname>bgwriter_lru_multiplier</> configuration parameter</primary>
1174 </indexterm>
1175 <listitem>
1176 <para>
1177 The number of dirty buffers written in each round is based on the
1178 number of new buffers that have been needed by server processes
1179 during recent rounds. The average recent need is multiplied by
1180 <varname>bgwriter_lru_multiplier</> to arrive at an estimate of the
1181 number of buffers that will be needed during the next round. Dirty
1182 buffers are written until there are that many clean, reusable buffers
1183 available. (However, no more than <varname>bgwriter_lru_maxpages</>
1184 buffers will be written per round.)
1185 Thus, a setting of 1.0 represents a <quote>just in time</> policy
1186 of writing exactly the number of buffers predicted to be needed.
1187 Larger values provide some cushion against spikes in demand,
1188 while smaller values intentionally leave writes to be done by
1189 server processes.
1190 The default is 2.0.
1191 This parameter can only be set in the <filename>postgresql.conf</>
1192 file or on the server command line.
1193 </para>
1194 </listitem>
1195 </varlistentry>
1196 </variablelist>
1198 <para>
1199 Smaller values of <varname>bgwriter_lru_maxpages</varname> and
1200 <varname>bgwriter_lru_multiplier</varname> reduce the extra I/O load
1201 caused by the background writer, but make it more likely that server
1202 processes will have to issue writes for themselves, delaying interactive
1203 queries.
1204 </para>
1205 </sect2>
1207 <sect2 id="runtime-config-resource-async-behavior">
1208 <title>Asynchronous Behavior</title>
1210 <variablelist>
1211 <varlistentry id="guc-effective-io-concurrency" xreflabel="effective_io_concurrency">
1212 <term><varname>effective_io_concurrency</varname> (<type>integer</type>)</term>
1213 <indexterm>
1214 <primary><varname>effective_io_concurrency</> configuration parameter</primary>
1215 </indexterm>
1216 <listitem>
1217 <para>
1218 Sets the number of concurrent disk I/O operations that
1219 <productname>PostgreSQL</> expects can be executed
1220 simultaneously. Raising this value will increase the number of I/O
1221 operations that any individual <productname>PostgreSQL</> session
1222 attempts to initiate in parallel. The allowed range is 1 to 1000,
1223 or zero to disable issuance of asynchronous I/O requests.
1224 </para>
1226 <para>
1227 A good starting point for this setting is the number of separate
1228 drives comprising a RAID 0 stripe or RAID 1 mirror being used for the
1229 database. (For RAID 5 the parity drive should not be counted.)
1230 However, if the database is often busy with multiple queries issued in
1231 concurrent sessions, lower values may be sufficient to keep the disk
1232 array busy. A value higher than needed to keep the disks busy will
1233 only result in extra CPU overhead.
1234 </para>
1236 <para>
1237 For more exotic systems, such as memory-based storage or a RAID array
1238 that is limited by bus bandwidth, the correct value might be the
1239 number of I/O paths available. Some experimentation may be needed
1240 to find the best value.
1241 </para>
1243 <para>
1244 Asynchronous I/O depends on an effective <function>posix_fadvise</>
1245 function, which some operating systems lack. If the function is not
1246 present then setting this parameter to anything but zero will result
1247 in an error. On some operating systems the function is present but
1248 does not actually do anything. On such systems setting a nonzero
1249 value will add CPU overhead without improving performance.
1250 </para>
1251 </listitem>
1252 </varlistentry>
1253 </variablelist>
1254 </sect2>
1255 </sect1>
1257 <sect1 id="runtime-config-wal">
1258 <title>Write Ahead Log</title>
1260 <para>
1261 See also <xref linkend="wal-configuration"> for details on WAL
1262 and checkpoint tuning.
1263 </para>
1265 <sect2 id="runtime-config-wal-settings">
1266 <title>Settings</title>
1267 <variablelist>
1269 <varlistentry id="guc-fsync" xreflabel="fsync">
1270 <indexterm>
1271 <primary><varname>fsync</> configuration parameter</primary>
1272 </indexterm>
1273 <term><varname>fsync</varname> (<type>boolean</type>)</term>
1274 <listitem>
1275 <para>
1276 If this parameter is on, the <productname>PostgreSQL</> server
1277 will try to make sure that updates are physically written to
1278 disk, by issuing <function>fsync()</> system calls or various
1279 equivalent methods (see <xref linkend="guc-wal-sync-method">).
1280 This ensures that the database cluster can recover to a
1281 consistent state after an operating system or hardware crash.
1282 </para>
1284 <para>
1285 However, using <varname>fsync</varname> results in a
1286 performance penalty: when a transaction is committed,
1287 <productname>PostgreSQL</productname> must wait for the
1288 operating system to flush the write-ahead log to disk. When
1289 <varname>fsync</varname> is disabled, the operating system is
1290 allowed to do its best in buffering, ordering, and delaying
1291 writes. This can result in significantly improved performance.
1292 However, if the system crashes, the results of the last few
1293 committed transactions might be lost in part or whole. In the
1294 worst case, unrecoverable data corruption might occur.
1295 (Crashes of the database software itself are <emphasis>not</>
1296 a risk factor here. Only an operating-system-level crash
1297 creates a risk of corruption.)
1298 </para>
1300 <para>
1301 Due to the risks involved, there is no universally correct
1302 setting for <varname>fsync</varname>. Some administrators
1303 always disable <varname>fsync</varname>, while others only
1304 turn it off during initial bulk data loads, where there is a clear
1305 restart point if something goes wrong. Others
1306 always leave <varname>fsync</varname> enabled. The default is
1307 to enable <varname>fsync</varname>, for maximum reliability.
1308 If you trust your operating system, your hardware, and your
1309 utility company (or your battery backup), you can consider
1310 disabling <varname>fsync</varname>.
1311 </para>
1313 <para>
1314 In many situations, turning off <xref linkend="guc-synchronous-commit">
1315 for noncritical transactions can provide much of the potential
1316 performance benefit of turning off <varname>fsync</varname>, without
1317 the attendant risks of data corruption.
1318 </para>
1320 <para>
1321 This parameter can only be set in the <filename>postgresql.conf</>
1322 file or on the server command line.
1323 If you turn this parameter off, also consider turning off
1324 <xref linkend="guc-full-page-writes">.
1325 </para>
1326 </listitem>
1327 </varlistentry>
1329 <varlistentry id="guc-synchronous-commit" xreflabel="synchronous_commit">
1330 <term><varname>synchronous_commit</varname> (<type>boolean</type>)</term>
1331 <indexterm>
1332 <primary><varname>synchronous_commit</> configuration parameter</primary>
1333 </indexterm>
1334 <listitem>
1335 <para>
1336 Specifies whether transaction commit will wait for WAL records
1337 to be written to disk before the command returns a <quote>success</>
1338 indication to the client. The default, and safe, setting is
1339 <literal>on</>. When <literal>off</>, there can be a delay between
1340 when success is reported to the client and when the transaction is
1341 really guaranteed to be safe against a server crash. (The maximum
1342 delay is three times <xref linkend="guc-wal-writer-delay">.) Unlike
1343 <xref linkend="guc-fsync">, setting this parameter to <literal>off</>
1344 does not create any risk of database inconsistency: a crash might
1345 result in some recent allegedly-committed transactions being lost, but
1346 the database state will be just the same as if those transactions had
1347 been aborted cleanly. So, turning <varname>synchronous_commit</> off
1348 can be a useful alternative when performance is more important than
1349 exact certainty about the durability of a transaction. For more
1350 discussion see <xref linkend="wal-async-commit">.
1351 </para>
1352 <para>
1353 This parameter can be changed at any time; the behavior for any
1354 one transaction is determined by the setting in effect when it
1355 commits. It is therefore possible, and useful, to have some
1356 transactions commit synchronously and others asynchronously.
1357 For example, to make a single multi-statement transaction commit
1358 asynchronously when the default is the opposite, issue <command>SET
1359 LOCAL synchronous_commit TO OFF</> within the transaction.
1360 </para>
1361 </listitem>
1362 </varlistentry>
1364 <varlistentry id="guc-wal-sync-method" xreflabel="wal_sync_method">
1365 <term><varname>wal_sync_method</varname> (<type>enum</type>)</term>
1366 <indexterm>
1367 <primary><varname>wal_sync_method</> configuration parameter</primary>
1368 </indexterm>
1369 <listitem>
1370 <para>
1371 Method used for forcing WAL updates out to disk.
1372 If <varname>fsync</varname> is off then this setting is irrelevant,
1373 since updates will not be forced out at all.
1374 Possible values are:
1375 </para>
1376 <itemizedlist>
1377 <listitem>
1378 <para>
1379 <literal>open_datasync</> (write WAL files with <function>open()</> option <symbol>O_DSYNC</>)
1380 </para>
1381 </listitem>
1382 <listitem>
1383 <para>
1384 <literal>fdatasync</> (call <function>fdatasync()</> at each commit)
1385 </para>
1386 </listitem>
1387 <listitem>
1388 <para>
1389 <literal>fsync_writethrough</> (call <function>fsync()</> at each commit, forcing write-through of any disk write cache)
1390 </para>
1391 </listitem>
1392 <listitem>
1393 <para>
1394 <literal>fsync</> (call <function>fsync()</> at each commit)
1395 </para>
1396 </listitem>
1397 <listitem>
1398 <para>
1399 <literal>open_sync</> (write WAL files with <function>open()</> option <symbol>O_SYNC</>)
1400 </para>
1401 </listitem>
1402 </itemizedlist>
1403 <para>
1404 Not all of these choices are available on all platforms.
1405 The default is the first method in the above list that is supported
1406 by the platform.
1407 The <literal>open_</>* options also use <literal>O_DIRECT</> if available.
1408 This parameter can only be set in the <filename>postgresql.conf</>
1409 file or on the server command line.
1410 </para>
1411 </listitem>
1412 </varlistentry>
1414 <varlistentry id="guc-full-page-writes" xreflabel="full_page_writes">
1415 <indexterm>
1416 <primary><varname>full_page_writes</> configuration parameter</primary>
1417 </indexterm>
1418 <term><varname>full_page_writes</varname> (<type>boolean</type>)</term>
1419 <listitem>
1420 <para>
1421 When this parameter is on, the <productname>PostgreSQL</> server
1422 writes the entire content of each disk page to WAL during the
1423 first modification of that page after a checkpoint.
1424 This is needed because
1425 a page write that is in process during an operating system crash might
1426 be only partially completed, leading to an on-disk page
1427 that contains a mix of old and new data. The row-level change data
1428 normally stored in WAL will not be enough to completely restore
1429 such a page during post-crash recovery. Storing the full page image
1430 guarantees that the page can be correctly restored, but at a price
1431 in increasing the amount of data that must be written to WAL.
1432 (Because WAL replay always starts from a checkpoint, it is sufficient
1433 to do this during the first change of each page after a checkpoint.
1434 Therefore, one way to reduce the cost of full-page writes is to
1435 increase the checkpoint interval parameters.)
1436 </para>
1438 <para>
1439 Turning this parameter off speeds normal operation, but
1440 might lead to a corrupt database after an operating system crash
1441 or power failure. The risks are similar to turning off
1442 <varname>fsync</>, though smaller. It might be safe to turn off
1443 this parameter if you have hardware (such as a battery-backed disk
1444 controller) or file-system software that reduces
1445 the risk of partial page writes to an acceptably low level (e.g., ReiserFS 4).
1446 </para>
1448 <para>
1449 Turning off this parameter does not affect use of
1450 WAL archiving for point-in-time recovery (PITR)
1451 (see <xref linkend="continuous-archiving">).
1452 </para>
1454 <para>
1455 This parameter can only be set in the <filename>postgresql.conf</>
1456 file or on the server command line.
1457 The default is <literal>on</>.
1458 </para>
1459 </listitem>
1460 </varlistentry>
1462 <varlistentry id="guc-wal-buffers" xreflabel="wal_buffers">
1463 <term><varname>wal_buffers</varname> (<type>integer</type>)</term>
1464 <indexterm>
1465 <primary><varname>wal_buffers</> configuration parameter</primary>
1466 </indexterm>
1467 <listitem>
1468 <para>
1469 The amount of memory used in shared memory for WAL data. The
1470 default is 64 kilobytes (<literal>64kB</>). The setting need only
1471 be large enough to hold the amount of WAL data generated by one
1472 typical transaction, since the data is written out to disk at
1473 every transaction commit. This parameter can only be set at server
1474 start.
1475 </para>
1477 <para>
1478 Increasing this parameter might cause <productname>PostgreSQL</>
1479 to request more <systemitem class="osname">System V</> shared
1480 memory than your operating system's default configuration
1481 allows. See <xref linkend="sysvipc"> for information on how to
1482 adjust those parameters, if necessary.
1483 </para>
1484 </listitem>
1485 </varlistentry>
1487 <varlistentry id="guc-wal-writer-delay" xreflabel="wal_writer_delay">
1488 <term><varname>wal_writer_delay</varname> (<type>integer</type>)</term>
1489 <indexterm>
1490 <primary><varname>wal_writer_delay</> configuration parameter</primary>
1491 </indexterm>
1492 <listitem>
1493 <para>
1494 Specifies the delay between activity rounds for the WAL writer.
1495 In each round the writer will flush WAL to disk. It then sleeps for
1496 <varname>wal_writer_delay</> milliseconds, and repeats. The default
1497 value is 200 milliseconds (<literal>200ms</>). Note that on many
1498 systems, the effective resolution of sleep delays is 10 milliseconds;
1499 setting <varname>wal_writer_delay</> to a value that is not a multiple
1500 of 10 might have the same results as setting it to the next higher
1501 multiple of 10. This parameter can only be set in the
1502 <filename>postgresql.conf</> file or on the server command line.
1503 </para>
1504 </listitem>
1505 </varlistentry>
1507 <varlistentry id="guc-commit-delay" xreflabel="commit_delay">
1508 <term><varname>commit_delay</varname> (<type>integer</type>)</term>
1509 <indexterm>
1510 <primary><varname>commit_delay</> configuration parameter</primary>
1511 </indexterm>
1512 <listitem>
1513 <para>
1514 Time delay between writing a commit record to the WAL buffer
1515 and flushing the buffer out to disk, in microseconds. A
1516 nonzero delay can allow multiple transactions to be committed
1517 with only one <function>fsync()</function> system call, if
1518 system load is high enough that additional transactions become
1519 ready to commit within the given interval. But the delay is
1520 just wasted if no other transactions become ready to
1521 commit. Therefore, the delay is only performed if at least
1522 <varname>commit_siblings</varname> other transactions are
1523 active at the instant that a server process has written its
1524 commit record. The default is zero (no delay).
1525 </para>
1526 </listitem>
1527 </varlistentry>
1529 <varlistentry id="guc-commit-siblings" xreflabel="commit_siblings">
1530 <term><varname>commit_siblings</varname> (<type>integer</type>)</term>
1531 <indexterm>
1532 <primary><varname>commit_siblings</> configuration parameter</primary>
1533 </indexterm>
1534 <listitem>
1535 <para>
1536 Minimum number of concurrent open transactions to require
1537 before performing the <varname>commit_delay</> delay. A larger
1538 value makes it more probable that at least one other
1539 transaction will become ready to commit during the delay
1540 interval. The default is five transactions.
1541 </para>
1542 </listitem>
1543 </varlistentry>
1545 </variablelist>
1546 </sect2>
1547 <sect2 id="runtime-config-wal-checkpoints">
1548 <title>Checkpoints</title>
1550 <variablelist>
1551 <varlistentry id="guc-checkpoint-segments" xreflabel="checkpoint_segments">
1552 <term><varname>checkpoint_segments</varname> (<type>integer</type>)</term>
1553 <indexterm>
1554 <primary><varname>checkpoint_segments</> configuration parameter</primary>
1555 </indexterm>
1556 <listitem>
1557 <para>
1558 Maximum number of log file segments between automatic WAL
1559 checkpoints (each segment is normally 16 megabytes). The default
1560 is three segments. Increasing this parameter can increase the
1561 amount of time needed for crash recovery.
1562 This parameter can only be set in the <filename>postgresql.conf</>
1563 file or on the server command line.
1564 </para>
1565 </listitem>
1566 </varlistentry>
1568 <varlistentry id="guc-checkpoint-timeout" xreflabel="checkpoint_timeout">
1569 <term><varname>checkpoint_timeout</varname> (<type>integer</type>)</term>
1570 <indexterm>
1571 <primary><varname>checkpoint_timeout</> configuration parameter</primary>
1572 </indexterm>
1573 <listitem>
1574 <para>
1575 Maximum time between automatic WAL checkpoints, in
1576 seconds. The default is five minutes (<literal>5min</>).
1577 Increasing this parameter can increase the amount of time needed
1578 for crash recovery.
1579 This parameter can only be set in the <filename>postgresql.conf</>
1580 file or on the server command line.
1581 </para>
1582 </listitem>
1583 </varlistentry>
1585 <varlistentry id="guc-checkpoint-completion-target" xreflabel="checkpoint_completion_target">
1586 <term><varname>checkpoint_completion_target</varname> (<type>floating point</type>)</term>
1587 <indexterm>
1588 <primary><varname>checkpoint_completion_target</> configuration parameter</primary>
1589 </indexterm>
1590 <listitem>
1591 <para>
1592 Specifies the target length of checkpoints, as a fraction of
1593 the checkpoint interval. The default is 0.5.
1595 This parameter can only be set in the <filename>postgresql.conf</>
1596 file or on the server command line.
1597 </para>
1598 </listitem>
1599 </varlistentry>
1601 <varlistentry id="guc-checkpoint-warning" xreflabel="checkpoint_warning">
1602 <term><varname>checkpoint_warning</varname> (<type>integer</type>)</term>
1603 <indexterm>
1604 <primary><varname>checkpoint_warning</> configuration parameter</primary>
1605 </indexterm>
1606 <listitem>
1607 <para>
1608 Write a message to the server log if checkpoints caused by
1609 the filling of checkpoint segment files happen closer together
1610 than this many seconds (which suggests that
1611 <varname>checkpoint_segments</> ought to be raised). The default is
1612 30 seconds (<literal>30s</>). Zero disables the warning.
1613 This parameter can only be set in the <filename>postgresql.conf</>
1614 file or on the server command line.
1615 </para>
1616 </listitem>
1617 </varlistentry>
1619 </variablelist>
1620 </sect2>
1621 <sect2 id="runtime-config-wal-archiving">
1622 <title>Archiving</title>
1624 <variablelist>
1625 <varlistentry id="guc-archive-mode" xreflabel="archive_mode">
1626 <term><varname>archive_mode</varname> (<type>boolean</type>)</term>
1627 <indexterm>
1628 <primary><varname>archive_mode</> configuration parameter</primary>
1629 </indexterm>
1630 <listitem>
1631 <para>
1632 When <varname>archive_mode</> is enabled, completed WAL segments
1633 can be sent to archive storage by setting
1634 <xref linkend="guc-archive-command">.
1635 <varname>archive_mode</> and <varname>archive_command</> are
1636 separate variables so that <varname>archive_command</> can be
1637 changed without leaving archiving mode.
1638 This parameter can only be set at server start.
1639 </para>
1640 </listitem>
1641 </varlistentry>
1643 <varlistentry id="guc-archive-command" xreflabel="archive_command">
1644 <term><varname>archive_command</varname> (<type>string</type>)</term>
1645 <indexterm>
1646 <primary><varname>archive_command</> configuration parameter</primary>
1647 </indexterm>
1648 <listitem>
1649 <para>
1650 The shell command to execute to archive a completed segment of
1651 the WAL file series. Any <literal>%p</> in the string is
1652 replaced by the path name of the file to archive, and any
1653 <literal>%f</> is replaced by the file name only.
1654 (The path name is relative to the working directory of the server,
1655 i.e., the cluster's data directory.)
1656 Use <literal>%%</> to embed an actual <literal>%</> character in the
1657 command. For more information see <xref
1658 linkend="backup-archiving-wal">.
1659 This parameter can only be set in the <filename>postgresql.conf</>
1660 file or on the server command line. It is ignored unless
1661 <varname>archive_mode</> was enabled at server start.
1662 If <varname>archive_command</> is an empty string (the default) while
1663 <varname>archive_mode</> is enabled, then WAL archiving is temporarily
1664 disabled, but the server continues to accumulate WAL segment files in
1665 the expectation that a command will soon be provided.
1666 </para>
1667 <para>
1668 It is important for the command to return a zero exit status if
1669 and only if it succeeds. Examples:
1670 <programlisting>
1671 archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
1672 archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"' # Windows
1673 </programlisting>
1674 </para>
1675 </listitem>
1676 </varlistentry>
1678 <varlistentry id="guc-archive-timeout" xreflabel="archive_timeout">
1679 <term><varname>archive_timeout</varname> (<type>integer</type>)</term>
1680 <indexterm>
1681 <primary><varname>archive_timeout</> configuration parameter</primary>
1682 </indexterm>
1683 <listitem>
1684 <para>
1685 The <xref linkend="guc-archive-command"> is only invoked on
1686 completed WAL segments. Hence, if your server generates little WAL
1687 traffic (or has slack periods where it does so), there could be a
1688 long delay between the completion of a transaction and its safe
1689 recording in archive storage. To put a limit on how old unarchived
1690 data can be, you can set <varname>archive_timeout</> to force the
1691 server to switch to a new WAL segment file periodically. When this
1692 parameter is greater than zero, the server will switch to a new
1693 segment file whenever this many seconds have elapsed since the last
1694 segment file switch. Note that archived files that are closed early
1695 due to a forced switch are still the same length as completely full
1696 files. Therefore, it is unwise to use a very short
1697 <varname>archive_timeout</> &mdash; it will bloat your archive
1698 storage. <varname>archive_timeout</> settings of a minute or so are
1699 usually reasonable. This parameter can only be set in the
1700 <filename>postgresql.conf</> file or on the server command line.
1701 </para>
1702 </listitem>
1703 </varlistentry>
1705 </variablelist>
1706 </sect2>
1707 </sect1>
1709 <sect1 id="runtime-config-query">
1710 <title>Query Planning</title>
1712 <sect2 id="runtime-config-query-enable">
1713 <title>Planner Method Configuration</title>
1715 <para>
1716 These configuration parameters provide a crude method of
1717 influencing the query plans chosen by the query optimizer. If
1718 the default plan chosen by the optimizer for a particular query
1719 is not optimal, a temporary solution can be found by using one
1720 of these configuration parameters to force the optimizer to
1721 choose a different plan. Turning one of these settings off
1722 permanently is seldom a good idea, however.
1723 Better ways to improve the quality of the
1724 plans chosen by the optimizer include adjusting the <xref
1725 linkend="runtime-config-query-constants"
1726 endterm="runtime-config-query-constants-title">, running <xref
1727 linkend="sql-analyze" endterm="sql-analyze-title"> more
1728 frequently, increasing the value of the <xref
1729 linkend="guc-default-statistics-target"> configuration parameter,
1730 and increasing the amount of statistics collected for
1731 specific columns using <command>ALTER TABLE SET
1732 STATISTICS</command>.
1733 </para>
1735 <variablelist>
1736 <varlistentry id="guc-enable-bitmapscan" xreflabel="enable_bitmapscan">
1737 <term><varname>enable_bitmapscan</varname> (<type>boolean</type>)</term>
1738 <indexterm>
1739 <primary>bitmap scan</primary>
1740 </indexterm>
1741 <indexterm>
1742 <primary><varname>enable_bitmapscan</> configuration parameter</primary>
1743 </indexterm>
1744 <listitem>
1745 <para>
1746 Enables or disables the query planner's use of bitmap-scan plan
1747 types. The default is <literal>on</>.
1748 </para>
1749 </listitem>
1750 </varlistentry>
1752 <varlistentry id="guc-enable-hashagg" xreflabel="enable_hashagg">
1753 <term><varname>enable_hashagg</varname> (<type>boolean</type>)</term>
1754 <indexterm>
1755 <primary><varname>enable_hashagg</> configuration parameter</primary>
1756 </indexterm>
1757 <listitem>
1758 <para>
1759 Enables or disables the query planner's use of hashed
1760 aggregation plan types. The default is <literal>on</>.
1761 </para>
1762 </listitem>
1763 </varlistentry>
1765 <varlistentry id="guc-enable-hashjoin" xreflabel="enable_hashjoin">
1766 <term><varname>enable_hashjoin</varname> (<type>boolean</type>)</term>
1767 <indexterm>
1768 <primary><varname>enable_hashjoin</> configuration parameter</primary>
1769 </indexterm>
1770 <listitem>
1771 <para>
1772 Enables or disables the query planner's use of hash-join plan
1773 types. The default is <literal>on</>.
1774 </para>
1775 </listitem>
1776 </varlistentry>
1778 <varlistentry id="guc-enable-indexscan" xreflabel="enable_indexscan">
1779 <term><varname>enable_indexscan</varname> (<type>boolean</type>)</term>
1780 <indexterm>
1781 <primary>index scan</primary>
1782 </indexterm>
1783 <indexterm>
1784 <primary><varname>enable_indexscan</> configuration parameter</primary>
1785 </indexterm>
1786 <listitem>
1787 <para>
1788 Enables or disables the query planner's use of index-scan plan
1789 types. The default is <literal>on</>.
1790 </para>
1791 </listitem>
1792 </varlistentry>
1794 <varlistentry id="guc-enable-mergejoin" xreflabel="enable_mergejoin">
1795 <term><varname>enable_mergejoin</varname> (<type>boolean</type>)</term>
1796 <indexterm>
1797 <primary><varname>enable_mergejoin</> configuration parameter</primary>
1798 </indexterm>
1799 <listitem>
1800 <para>
1801 Enables or disables the query planner's use of merge-join plan
1802 types. The default is <literal>on</>.
1803 </para>
1804 </listitem>
1805 </varlistentry>
1807 <varlistentry id="guc-enable-nestloop" xreflabel="enable_nestloop">
1808 <term><varname>enable_nestloop</varname> (<type>boolean</type>)</term>
1809 <indexterm>
1810 <primary><varname>enable_nestloop</> configuration parameter</primary>
1811 </indexterm>
1812 <listitem>
1813 <para>
1814 Enables or disables the query planner's use of nested-loop join
1815 plans. It's not possible to suppress nested-loop joins entirely,
1816 but turning this variable off discourages the planner from using
1817 one if there are other methods available. The default is
1818 <literal>on</>.
1819 </para>
1820 </listitem>
1821 </varlistentry>
1823 <varlistentry id="guc-enable-seqscan" xreflabel="enable_seqscan">
1824 <term><varname>enable_seqscan</varname> (<type>boolean</type>)</term>
1825 <indexterm>
1826 <primary>sequential scan</primary>
1827 </indexterm>
1828 <indexterm>
1829 <primary><varname>enable_seqscan</> configuration parameter</primary>
1830 </indexterm>
1831 <listitem>
1832 <para>
1833 Enables or disables the query planner's use of sequential scan
1834 plan types. It's not possible to suppress sequential scans
1835 entirely, but turning this variable off discourages the planner
1836 from using one if there are other methods available. The
1837 default is <literal>on</>.
1838 </para>
1839 </listitem>
1840 </varlistentry>
1842 <varlistentry id="guc-enable-sort" xreflabel="enable_sort">
1843 <term><varname>enable_sort</varname> (<type>boolean</type>)</term>
1844 <indexterm>
1845 <primary><varname>enable_sort</> configuration parameter</primary>
1846 </indexterm>
1847 <listitem>
1848 <para>
1849 Enables or disables the query planner's use of explicit sort
1850 steps. It's not possible to suppress explicit sorts entirely,
1851 but turning this variable off discourages the planner from
1852 using one if there are other methods available. The default
1853 is <literal>on</>.
1854 </para>
1855 </listitem>
1856 </varlistentry>
1858 <varlistentry id="guc-enable-tidscan" xreflabel="enable_tidscan">
1859 <term><varname>enable_tidscan</varname> (<type>boolean</type>)</term>
1860 <indexterm>
1861 <primary><varname>enable_tidscan</> configuration parameter</primary>
1862 </indexterm>
1863 <listitem>
1864 <para>
1865 Enables or disables the query planner's use of <acronym>TID</>
1866 scan plan types. The default is <literal>on</>.
1867 </para>
1868 </listitem>
1869 </varlistentry>
1871 </variablelist>
1872 </sect2>
1873 <sect2 id="runtime-config-query-constants">
1874 <title id="runtime-config-query-constants-title">
1875 Planner Cost Constants
1876 </title>
1878 <para>
1879 The <firstterm>cost</> variables described in this section are measured
1880 on an arbitrary scale. Only their relative values matter, hence
1881 scaling them all up or down by the same factor will result in no change
1882 in the planner's choices. Traditionally, these variables have been
1883 referenced to sequential page fetches as the unit of cost; that is,
1884 <varname>seq_page_cost</> is conventionally set to <literal>1.0</>
1885 and the other cost variables are set with reference to that. But
1886 you can use a different scale if you prefer, such as actual execution
1887 times in milliseconds on a particular machine.
1888 </para>
1890 <note>
1891 <para>
1892 Unfortunately, there is no well-defined method for determining ideal
1893 values for the cost variables. They are best treated as averages over
1894 the entire mix of queries that a particular installation will get. This
1895 means that changing them on the basis of just a few experiments is very
1896 risky.
1897 </para>
1898 </note>
1900 <variablelist>
1902 <varlistentry id="guc-seq-page-cost" xreflabel="seq_page_cost">
1903 <term><varname>seq_page_cost</varname> (<type>floating point</type>)</term>
1904 <indexterm>
1905 <primary><varname>seq_page_cost</> configuration parameter</primary>
1906 </indexterm>
1907 <listitem>
1908 <para>
1909 Sets the planner's estimate of the cost of a disk page fetch
1910 that is part of a series of sequential fetches. The default is 1.0.
1911 </para>
1912 </listitem>
1913 </varlistentry>
1915 <varlistentry id="guc-random-page-cost" xreflabel="random_page_cost">
1916 <term><varname>random_page_cost</varname> (<type>floating point</type>)</term>
1917 <indexterm>
1918 <primary><varname>random_page_cost</> configuration parameter</primary>
1919 </indexterm>
1920 <listitem>
1921 <para>
1922 Sets the planner's estimate of the cost of a
1923 non-sequentially-fetched disk page. The default is 4.0.
1924 Reducing this value relative to <varname>seq_page_cost</>
1925 will cause the system to prefer index scans; raising it will
1926 make index scans look relatively more expensive. You can raise
1927 or lower both values together to change the importance of disk I/O
1928 costs relative to CPU costs, which are described by the following
1929 parameters.
1930 </para>
1932 <tip>
1933 <para>
1934 Although the system will let you set <varname>random_page_cost</> to
1935 less than <varname>seq_page_cost</>, it is not physically sensible
1936 to do so. However, setting them equal makes sense if the database
1937 is entirely cached in RAM, since in that case there is no penalty
1938 for touching pages out of sequence. Also, in a heavily-cached
1939 database you should lower both values relative to the CPU parameters,
1940 since the cost of fetching a page already in RAM is much smaller
1941 than it would normally be.
1942 </para>
1943 </tip>
1944 </listitem>
1945 </varlistentry>
1947 <varlistentry id="guc-cpu-tuple-cost" xreflabel="cpu_tuple_cost">
1948 <term><varname>cpu_tuple_cost</varname> (<type>floating point</type>)</term>
1949 <indexterm>
1950 <primary><varname>cpu_tuple_cost</> configuration parameter</primary>
1951 </indexterm>
1952 <listitem>
1953 <para>
1954 Sets the planner's estimate of the cost of processing
1955 each row during a query.
1956 The default is 0.01.
1957 </para>
1958 </listitem>
1959 </varlistentry>
1961 <varlistentry id="guc-cpu-index-tuple-cost" xreflabel="cpu_index_tuple_cost">
1962 <term><varname>cpu_index_tuple_cost</varname> (<type>floating point</type>)</term>
1963 <indexterm>
1964 <primary><varname>cpu_index_tuple_cost</> configuration parameter</primary>
1965 </indexterm>
1966 <listitem>
1967 <para>
1968 Sets the planner's estimate of the cost of processing
1969 each index entry during an index scan.
1970 The default is 0.005.
1971 </para>
1972 </listitem>
1973 </varlistentry>
1975 <varlistentry id="guc-cpu-operator-cost" xreflabel="cpu_operator_cost">
1976 <term><varname>cpu_operator_cost</varname> (<type>floating point</type>)</term>
1977 <indexterm>
1978 <primary><varname>cpu_operator_cost</> configuration parameter</primary>
1979 </indexterm>
1980 <listitem>
1981 <para>
1982 Sets the planner's estimate of the cost of processing each
1983 operator or function executed during a query.
1984 The default is 0.0025.
1985 </para>
1986 </listitem>
1987 </varlistentry>
1989 <varlistentry id="guc-effective-cache-size" xreflabel="effective_cache_size">
1990 <term><varname>effective_cache_size</varname> (<type>integer</type>)</term>
1991 <indexterm>
1992 <primary><varname>effective_cache_size</> configuration parameter</primary>
1993 </indexterm>
1994 <listitem>
1995 <para>
1996 Sets the planner's assumption about the effective size of the
1997 disk cache that is available to a single query. This is
1998 factored into estimates of the cost of using an index; a
1999 higher value makes it more likely index scans will be used, a
2000 lower value makes it more likely sequential scans will be
2001 used. When setting this parameter you should consider both
2002 <productname>PostgreSQL</productname>'s shared buffers and the
2003 portion of the kernel's disk cache that will be used for
2004 <productname>PostgreSQL</productname> data files. Also, take
2005 into account the expected number of concurrent queries on different
2006 tables, since they will have to share the available
2007 space. This parameter has no effect on the size of shared
2008 memory allocated by <productname>PostgreSQL</productname>, nor
2009 does it reserve kernel disk cache; it is used only for estimation
2010 purposes. The default is 128 megabytes (<literal>128MB</>).
2011 </para>
2012 </listitem>
2013 </varlistentry>
2015 </variablelist>
2017 </sect2>
2018 <sect2 id="runtime-config-query-geqo">
2019 <title>Genetic Query Optimizer</title>
2021 <variablelist>
2023 <varlistentry id="guc-geqo" xreflabel="geqo">
2024 <indexterm>
2025 <primary>genetic query optimization</primary>
2026 </indexterm>
2027 <indexterm>
2028 <primary>GEQO</primary>
2029 <see>genetic query optimization</see>
2030 </indexterm>
2031 <indexterm>
2032 <primary><varname>geqo</> configuration parameter</primary>
2033 </indexterm>
2034 <term><varname>geqo</varname> (<type>boolean</type>)</term>
2035 <listitem>
2036 <para>
2037 Enables or disables genetic query optimization, which is an
2038 algorithm that attempts to do query planning without
2039 exhaustive searching. This is on by default. The
2040 <varname>geqo_threshold</varname> variable provides a more
2041 granular way to disable GEQO for certain classes of queries.
2042 </para>
2043 </listitem>
2044 </varlistentry>
2046 <varlistentry id="guc-geqo-threshold" xreflabel="geqo_threshold">
2047 <term><varname>geqo_threshold</varname> (<type>integer</type>)</term>
2048 <indexterm>
2049 <primary><varname>geqo_threshold</> configuration parameter</primary>
2050 </indexterm>
2051 <listitem>
2052 <para>
2053 Use genetic query optimization to plan queries with at least
2054 this many <literal>FROM</> items involved. (Note that a
2055 <literal>FULL OUTER JOIN</> construct counts as only one <literal>FROM</>
2056 item.) The default is 12. For simpler queries it is usually best
2057 to use the deterministic, exhaustive planner, but for queries with
2058 many tables the deterministic planner takes too long.
2059 </para>
2060 </listitem>
2061 </varlistentry>
2063 <varlistentry id="guc-geqo-effort" xreflabel="geqo_effort">
2064 <term><varname>geqo_effort</varname>
2065 (<type>integer</type>)</term>
2066 <indexterm>
2067 <primary><varname>geqo_effort</> configuration parameter</primary>
2068 </indexterm>
2069 <listitem>
2070 <para>
2071 Controls the trade off between planning time and query plan
2072 efficiency in GEQO. This variable must be an integer in the
2073 range from 1 to 10. The default value is five. Larger values
2074 increase the time spent doing query planning, but also
2075 increase the likelihood that an efficient query plan will be
2076 chosen.
2077 </para>
2079 <para>
2080 <varname>geqo_effort</varname> doesn't actually do anything
2081 directly; it is only used to compute the default values for
2082 the other variables that influence GEQO behavior (described
2083 below). If you prefer, you can set the other parameters by
2084 hand instead.
2085 </para>
2086 </listitem>
2087 </varlistentry>
2089 <varlistentry id="guc-geqo-pool-size" xreflabel="geqo_pool_size">
2090 <term><varname>geqo_pool_size</varname> (<type>integer</type>)</term>
2091 <indexterm>
2092 <primary><varname>geqo_pool_size</> configuration parameter</primary>
2093 </indexterm>
2094 <listitem>
2095 <para>
2096 Controls the pool size used by GEQO. The pool size is the
2097 number of individuals in the genetic population. It must be
2098 at least two, and useful values are typically 100 to 1000. If
2099 it is set to zero (the default setting) then a suitable
2100 default is chosen based on <varname>geqo_effort</varname> and
2101 the number of tables in the query.
2102 </para>
2103 </listitem>
2104 </varlistentry>
2106 <varlistentry id="guc-geqo-generations" xreflabel="geqo_generations">
2107 <term><varname>geqo_generations</varname> (<type>integer</type>)</term>
2108 <indexterm>
2109 <primary><varname>geqo_generations</> configuration parameter</primary>
2110 </indexterm>
2111 <listitem>
2112 <para>
2113 Controls the number of generations used by GEQO. Generations
2114 specifies the number of iterations of the algorithm. It must
2115 be at least one, and useful values are in the same range as
2116 the pool size. If it is set to zero (the default setting)
2117 then a suitable default is chosen based on
2118 <varname>geqo_pool_size</varname>.
2119 </para>
2120 </listitem>
2121 </varlistentry>
2123 <varlistentry id="guc-geqo-selection-bias" xreflabel="geqo_selection_bias">
2124 <term><varname>geqo_selection_bias</varname> (<type>floating point</type>)</term>
2125 <indexterm>
2126 <primary><varname>geqo_selection_bias</> configuration parameter</primary>
2127 </indexterm>
2128 <listitem>
2129 <para>
2130 Controls the selection bias used by GEQO. The selection bias
2131 is the selective pressure within the population. Values can be
2132 from 1.50 to 2.00; the latter is the default.
2133 </para>
2134 </listitem>
2135 </varlistentry>
2137 </variablelist>
2138 </sect2>
2139 <sect2 id="runtime-config-query-other">
2140 <title>Other Planner Options</title>
2142 <variablelist>
2144 <varlistentry id="guc-default-statistics-target" xreflabel="default_statistics_target">
2145 <term><varname>default_statistics_target</varname> (<type>integer</type>)</term>
2146 <indexterm>
2147 <primary><varname>default_statistics_target</> configuration parameter</primary>
2148 </indexterm>
2149 <listitem>
2150 <para>
2151 Sets the default statistics target for table columns that have
2152 not had a column-specific target set via <command>ALTER TABLE
2153 SET STATISTICS</>. Larger values increase the time needed to
2154 do <command>ANALYZE</>, but might improve the quality of the
2155 planner's estimates. The default is 100. For more information
2156 on the use of statistics by the <productname>PostgreSQL</>
2157 query planner, refer to <xref linkend="planner-stats">.
2158 </para>
2159 </listitem>
2160 </varlistentry>
2162 <varlistentry id="guc-constraint-exclusion" xreflabel="constraint_exclusion">
2163 <term><varname>constraint_exclusion</varname> (<type>enum</type>)</term>
2164 <indexterm>
2165 <primary>constraint exclusion</primary>
2166 </indexterm>
2167 <indexterm>
2168 <primary><varname>constraint_exclusion</> configuration parameter</primary>
2169 </indexterm>
2170 <listitem>
2171 <para>
2172 Enables or disables the query planner's use of table constraints to
2173 optimize queries.
2174 The allowed values of <varname>constraint_exclusion</> are
2175 <literal>on</> (examine constraints for all tables),
2176 <literal>off</> (never examine constraints), and
2177 <literal>partition</> (examine constraints only for inheritance child
2178 tables and <literal>UNION ALL</> subqueries).
2179 <literal>partition</> is the default setting.
2180 </para>
2182 <para>
2183 When this parameter allows it for a particular table, the planner
2184 compares query conditions with the table's <literal>CHECK</>
2185 constraints, and omits scanning tables for which the conditions
2186 contradict the constraints. For example:
2188 <programlisting>
2189 CREATE TABLE parent(key integer, ...);
2190 CREATE TABLE child1000(check (key between 1000 and 1999)) INHERITS(parent);
2191 CREATE TABLE child2000(check (key between 2000 and 2999)) INHERITS(parent);
2193 SELECT * FROM parent WHERE key = 2400;
2194 </programlisting>
2196 With constraint exclusion enabled, this <command>SELECT</>
2197 will not scan <structname>child1000</> at all. This can
2198 improve performance when inheritance is used to build
2199 partitioned tables.
2200 </para>
2202 <para>
2203 Currently, constraint exclusion is enabled by default
2204 only for cases that are often used to implement table partitioning.
2205 Turning it on for all tables imposes extra planning overhead that is
2206 quite noticeable on simple queries, and most often will yield no
2207 benefit for simple queries. If you have no partitioned tables
2208 you might prefer to turn it off entirely.
2209 </para>
2211 <para>
2212 Refer to <xref linkend="ddl-partitioning-constraint-exclusion"> for
2213 more information on using constraint exclusion and partitioning.
2214 </para>
2215 </listitem>
2216 </varlistentry>
2218 <varlistentry id="guc-cursor-tuple-fraction" xreflabel="cursor_tuple_fraction">
2219 <term><varname>cursor_tuple_fraction</varname> (<type>floating point</type>)</term>
2220 <indexterm>
2221 <primary><varname>cursor_tuple_fraction</> configuration parameter</primary>
2222 </indexterm>
2223 <listitem>
2224 <para>
2225 Sets the planner's estimate of the fraction of a cursor's rows that
2226 will be retrieved. The default is 0.1. Smaller values of this
2227 setting bias the planner towards using <quote>fast start</> plans
2228 for cursors, which will retrieve the first few rows quickly while
2229 perhaps taking a long time to fetch all rows. Larger values
2230 put more emphasis on the total estimated time. At the maximum
2231 setting of 1.0, cursors are planned exactly like regular queries,
2232 considering only the total estimated time and not how soon the
2233 first rows might be delivered.
2234 </para>
2235 </listitem>
2236 </varlistentry>
2238 <varlistentry id="guc-from-collapse-limit" xreflabel="from_collapse_limit">
2239 <term><varname>from_collapse_limit</varname> (<type>integer</type>)</term>
2240 <indexterm>
2241 <primary><varname>from_collapse_limit</> configuration parameter</primary>
2242 </indexterm>
2243 <listitem>
2244 <para>
2245 The planner will merge sub-queries into upper queries if the
2246 resulting <literal>FROM</literal> list would have no more than
2247 this many items. Smaller values reduce planning time but might
2248 yield inferior query plans. The default is eight. It is usually
2249 wise to keep this less than <xref linkend="guc-geqo-threshold">.
2250 For more information see <xref linkend="explicit-joins">.
2251 </para>
2252 </listitem>
2253 </varlistentry>
2255 <varlistentry id="guc-join-collapse-limit" xreflabel="join_collapse_limit">
2256 <term><varname>join_collapse_limit</varname> (<type>integer</type>)</term>
2257 <indexterm>
2258 <primary><varname>join_collapse_limit</> configuration parameter</primary>
2259 </indexterm>
2260 <listitem>
2261 <para>
2262 The planner will rewrite explicit <literal>JOIN</>
2263 constructs (except <literal>FULL JOIN</>s) into lists of
2264 <literal>FROM</> items whenever a list of no more than this many items
2265 would result. Smaller values reduce planning time but might
2266 yield inferior query plans.
2267 </para>
2269 <para>
2270 By default, this variable is set the same as
2271 <varname>from_collapse_limit</varname>, which is appropriate
2272 for most uses. Setting it to 1 prevents any reordering of
2273 explicit <literal>JOIN</>s. Thus, the explicit join order
2274 specified in the query will be the actual order in which the
2275 relations are joined. The query planner does not always choose
2276 the optimal join order; advanced users can elect to
2277 temporarily set this variable to 1, and then specify the join
2278 order they desire explicitly.
2279 For more information see <xref linkend="explicit-joins">.
2280 </para>
2281 </listitem>
2282 </varlistentry>
2284 </variablelist>
2285 </sect2>
2286 </sect1>
2288 <sect1 id="runtime-config-logging">
2289 <title>Error Reporting and Logging</title>
2291 <indexterm zone="runtime-config-logging">
2292 <primary>server log</primary>
2293 </indexterm>
2295 <sect2 id="runtime-config-logging-where">
2296 <title>Where To Log</title>
2298 <indexterm zone="runtime-config-logging-where">
2299 <primary>where to log</primary>
2300 </indexterm>
2302 <variablelist>
2304 <varlistentry id="guc-log-destination" xreflabel="log_destination">
2305 <term><varname>log_destination</varname> (<type>string</type>)</term>
2306 <indexterm>
2307 <primary><varname>log_destination</> configuration parameter</primary>
2308 </indexterm>
2309 <listitem>
2310 <para>
2311 <productname>PostgreSQL</productname> supports several methods
2312 for logging server messages, including
2313 <systemitem>stderr</systemitem>, <systemitem>csvlog</systemitem> and
2314 <systemitem>syslog</systemitem>. On Windows,
2315 <systemitem>eventlog</systemitem> is also supported. Set this
2316 parameter to a list of desired log destinations separated by
2317 commas. The default is to log to <systemitem>stderr</systemitem>
2318 only.
2319 This parameter can only be set in the <filename>postgresql.conf</>
2320 file or on the server command line.
2321 </para>
2322 <para>
2323 If <systemitem>csvlog</> is included in <varname>log_destination</>,
2324 log entries are output in <quote>comma separated
2325 value</> format, which is convenient for loading them into programs.
2326 See <xref linkend="runtime-config-logging-csvlog"> for details.
2327 <varname>logging_collector</varname> must be enabled to generate
2328 CSV-format log output.
2329 </para>
2331 <note>
2332 <para>
2333 On most Unix systems, you will need to alter the configuration of
2334 your system's <application>syslog</application> daemon in order
2335 to make use of the <systemitem>syslog</systemitem> option for
2336 <varname>log_destination</>. <productname>PostgreSQL</productname>
2337 can log to <application>syslog</application> facilities
2338 <literal>LOCAL0</> through <literal>LOCAL7</> (see <xref
2339 linkend="guc-syslog-facility">), but the default
2340 <application>syslog</application> configuration on most platforms
2341 will discard all such messages. You will need to add something like
2342 <programlisting>
2343 local0.* /var/log/postgresql
2344 </programlisting>
2345 to the <application>syslog</application> daemon's configuration file
2346 to make it work.
2347 </para>
2348 </note>
2349 </listitem>
2350 </varlistentry>
2352 <varlistentry id="guc-logging-collector" xreflabel="logging_collector">
2353 <term><varname>logging_collector</varname> (<type>boolean</type>)</term>
2354 <indexterm>
2355 <primary><varname>logging_collector</> configuration parameter</primary>
2356 </indexterm>
2357 <listitem>
2358 <para>
2359 This parameter allows messages sent to <application>stderr</>,
2360 and CSV-format log output, to be
2361 captured and redirected into log files.
2362 This approach is often more useful than
2363 logging to <application>syslog</>, since some types of messages
2364 might not appear in <application>syslog</> output (a common example
2365 is dynamic-linker failure messages).
2366 This parameter can only be set at server start.
2367 </para>
2368 </listitem>
2369 </varlistentry>
2371 <varlistentry id="guc-log-directory" xreflabel="log_directory">
2372 <term><varname>log_directory</varname> (<type>string</type>)</term>
2373 <indexterm>
2374 <primary><varname>log_directory</> configuration parameter</primary>
2375 </indexterm>
2376 <listitem>
2377 <para>
2378 When <varname>logging_collector</> is enabled,
2379 this parameter determines the directory in which log files will be created.
2380 It can be specified as an absolute path, or relative to the
2381 cluster data directory.
2382 This parameter can only be set in the <filename>postgresql.conf</>
2383 file or on the server command line.
2384 </para>
2385 </listitem>
2386 </varlistentry>
2388 <varlistentry id="guc-log-filename" xreflabel="log_filename">
2389 <term><varname>log_filename</varname> (<type>string</type>)</term>
2390 <indexterm>
2391 <primary><varname>log_filename</> configuration parameter</primary>
2392 </indexterm>
2393 <listitem>
2394 <para>
2395 When <varname>logging_collector</varname> is enabled,
2396 this parameter sets the file names of the created log files. The value
2397 is treated as a <systemitem>strftime</systemitem> pattern,
2398 so <literal>%</literal>-escapes can be used to specify time-varying
2399 file names. (Note that if there are
2400 any time-zone-dependent <literal>%</literal>-escapes, the computation
2401 is done in the zone specified by <xref linkend="guc-log-timezone">.)
2402 If no <literal>%</literal>-escapes are present,
2403 <productname>PostgreSQL</productname> will append the epoch of the new
2404 log file's creation time. For example, if
2405 <varname>log_filename</varname> were <literal>server_log</literal>,
2406 then the chosen file name would be <literal>server_log.1093827753</>
2407 for a log starting at Sun Aug 29 19:02:33 2004 MST.
2408 Note that the system's <systemitem>strftime</systemitem> is not used
2409 directly, so platform-specific (nonstandard) extensions do not work.
2410 </para>
2411 <para>
2412 If CSV-format output is enabled in <varname>log_destination</>,
2413 <literal>.csv</> will be appended to the timestamped
2414 log file name to create the file name for CSV-format output.
2415 (If <varname>log_filename</> ends in <literal>.log</>, the suffix is
2416 replaced instead.)
2417 In the case of the example above, the CSV
2418 file name will be <literal>server_log.1093827753.csv</literal>.
2419 </para>
2420 <para>
2421 This parameter can only be set in the <filename>postgresql.conf</>
2422 file or on the server command line.
2423 </para>
2424 </listitem>
2425 </varlistentry>
2427 <varlistentry id="guc-log-rotation-age" xreflabel="log_rotation_age">
2428 <term><varname>log_rotation_age</varname> (<type>integer</type>)</term>
2429 <indexterm>
2430 <primary><varname>log_rotation_age</> configuration parameter</primary>
2431 </indexterm>
2432 <listitem>
2433 <para>
2434 When <varname>logging_collector</varname> is enabled,
2435 this parameter determines the maximum lifetime of an individual log file.
2436 After this many minutes have elapsed, a new log file will
2437 be created. Set to zero to disable time-based creation of
2438 new log files.
2439 This parameter can only be set in the <filename>postgresql.conf</>
2440 file or on the server command line.
2441 </para>
2442 </listitem>
2443 </varlistentry>
2445 <varlistentry id="guc-log-rotation-size" xreflabel="log_rotation_size">
2446 <term><varname>log_rotation_size</varname> (<type>integer</type>)</term>
2447 <indexterm>
2448 <primary><varname>log_rotation_size</> configuration parameter</primary>
2449 </indexterm>
2450 <listitem>
2451 <para>
2452 When <varname>logging_collector</varname> is enabled,
2453 this parameter determines the maximum size of an individual log file.
2454 After this many kilobytes have been emitted into a log file,
2455 a new log file will be created. Set to zero to disable size-based
2456 creation of new log files.
2457 This parameter can only be set in the <filename>postgresql.conf</>
2458 file or on the server command line.
2459 </para>
2460 </listitem>
2461 </varlistentry>
2463 <varlistentry id="guc-log-truncate-on-rotation" xreflabel="log_truncate_on_rotation">
2464 <term><varname>log_truncate_on_rotation</varname> (<type>boolean</type>)</term>
2465 <indexterm>
2466 <primary><varname>log_truncate_on_rotation</> configuration parameter</primary>
2467 </indexterm>
2468 <listitem>
2469 <para>
2470 When <varname>logging_collector</varname> is enabled,
2471 this parameter will cause <productname>PostgreSQL</productname> to truncate (overwrite),
2472 rather than append to, any existing log file of the same name.
2473 However, truncation will occur only when a new file is being opened
2474 due to time-based rotation, not during server startup or size-based
2475 rotation. When off, pre-existing files will be appended to in
2476 all cases. For example, using this setting in combination with
2477 a <varname>log_filename</varname> like <literal>postgresql-%H.log</literal>
2478 would result in generating twenty-four hourly log files and then
2479 cyclically overwriting them.
2480 This parameter can only be set in the <filename>postgresql.conf</>
2481 file or on the server command line.
2482 </para>
2483 <para>
2484 Example: To keep 7 days of logs, one log file per day named
2485 <literal>server_log.Mon</literal>, <literal>server_log.Tue</literal>,
2486 etc, and automatically overwrite last week's log with this week's log,
2487 set <varname>log_filename</varname> to <literal>server_log.%a</literal>,
2488 <varname>log_truncate_on_rotation</varname> to <literal>on</literal>, and
2489 <varname>log_rotation_age</varname> to <literal>1440</literal>.
2490 </para>
2491 <para>
2492 Example: To keep 24 hours of logs, one log file per hour, but
2493 also rotate sooner if the log file size exceeds 1GB, set
2494 <varname>log_filename</varname> to <literal>server_log.%H%M</literal>,
2495 <varname>log_truncate_on_rotation</varname> to <literal>on</literal>,
2496 <varname>log_rotation_age</varname> to <literal>60</literal>, and
2497 <varname>log_rotation_size</varname> to <literal>1000000</literal>.
2498 Including <literal>%M</> in <varname>log_filename</varname> allows
2499 any size-driven rotations that might occur to select a file name
2500 different from the hour's initial file name.
2501 </para>
2502 </listitem>
2503 </varlistentry>
2505 <varlistentry id="guc-syslog-facility" xreflabel="syslog_facility">
2506 <term><varname>syslog_facility</varname> (<type>enum</type>)</term>
2507 <indexterm>
2508 <primary><varname>syslog_facility</> configuration parameter</primary>
2509 </indexterm>
2510 <listitem>
2511 <para>
2512 When logging to <application>syslog</> is enabled, this parameter
2513 determines the <application>syslog</application>
2514 <quote>facility</quote> to be used. You can choose
2515 from <literal>LOCAL0</>, <literal>LOCAL1</>,
2516 <literal>LOCAL2</>, <literal>LOCAL3</>, <literal>LOCAL4</>,
2517 <literal>LOCAL5</>, <literal>LOCAL6</>, <literal>LOCAL7</>;
2518 the default is <literal>LOCAL0</>. See also the
2519 documentation of your system's
2520 <application>syslog</application> daemon.
2521 This parameter can only be set in the <filename>postgresql.conf</>
2522 file or on the server command line.
2523 </para>
2524 </listitem>
2525 </varlistentry>
2527 <varlistentry id="guc-syslog-ident" xreflabel="syslog_ident">
2528 <term><varname>syslog_ident</varname> (<type>string</type>)</term>
2529 <indexterm>
2530 <primary><varname>syslog_identity</> configuration parameter</primary>
2531 </indexterm>
2532 <listitem>
2533 <para>
2534 When logging to <application>syslog</> is enabled, this parameter
2535 determines the program name used to identify
2536 <productname>PostgreSQL</productname> messages in
2537 <application>syslog</application> logs. The default is
2538 <literal>postgres</literal>.
2539 This parameter can only be set in the <filename>postgresql.conf</>
2540 file or on the server command line.
2541 </para>
2542 </listitem>
2543 </varlistentry>
2545 </variablelist>
2546 </sect2>
2547 <sect2 id="runtime-config-logging-when">
2548 <title>When To Log</title>
2550 <variablelist>
2552 <varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
2553 <term><varname>client_min_messages</varname> (<type>enum</type>)</term>
2554 <indexterm>
2555 <primary><varname>client_min_messages</> configuration parameter</primary>
2556 </indexterm>
2557 <listitem>
2558 <para>
2559 Controls which message levels are sent to the client.
2560 Valid values are <literal>DEBUG5</>,
2561 <literal>DEBUG4</>, <literal>DEBUG3</>, <literal>DEBUG2</>,
2562 <literal>DEBUG1</>, <literal>LOG</>, <literal>NOTICE</>,
2563 <literal>WARNING</>, <literal>ERROR</>, <literal>FATAL</>,
2564 and <literal>PANIC</>. Each level
2565 includes all the levels that follow it. The later the level,
2566 the fewer messages are sent. The default is
2567 <literal>NOTICE</>. Note that <literal>LOG</> has a different
2568 rank here than in <varname>log_min_messages</>.
2569 </para>
2570 </listitem>
2571 </varlistentry>
2573 <varlistentry id="guc-log-min-messages" xreflabel="log_min_messages">
2574 <term><varname>log_min_messages</varname> (<type>enum</type>)</term>
2575 <indexterm>
2576 <primary><varname>log_min_messages</> configuration parameter</primary>
2577 </indexterm>
2578 <listitem>
2579 <para>
2580 Controls which message levels are written to the server log.
2581 Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
2582 <literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>,
2583 <literal>INFO</>, <literal>NOTICE</>, <literal>WARNING</>,
2584 <literal>ERROR</>, <literal>LOG</>, <literal>FATAL</>, and
2585 <literal>PANIC</>. Each level includes all the levels that
2586 follow it. The later the level, the fewer messages are sent
2587 to the log. The default is <literal>WARNING</>. Note that
2588 <literal>LOG</> has a different rank here than in
2589 <varname>client_min_messages</>.
2590 Only superusers can change this setting.
2591 </para>
2592 </listitem>
2593 </varlistentry>
2595 <varlistentry id="guc-log-error-verbosity" xreflabel="log_error_verbosity">
2596 <term><varname>log_error_verbosity</varname> (<type>enum</type>)</term>
2597 <indexterm>
2598 <primary><varname>log_error_verbosity</> configuration parameter</primary>
2599 </indexterm>
2600 <listitem>
2601 <para>
2602 Controls the amount of detail written in the server log for each
2603 message that is logged. Valid values are <literal>TERSE</>,
2604 <literal>DEFAULT</>, and <literal>VERBOSE</>, each adding more
2605 fields to displayed messages.
2606 Only superusers can change this setting.
2607 </para>
2608 </listitem>
2609 </varlistentry>
2611 <varlistentry id="guc-log-min-error-statement" xreflabel="log_min_error_statement">
2612 <term><varname>log_min_error_statement</varname> (<type>enum</type>)</term>
2613 <indexterm>
2614 <primary><varname>log_min_error_statement</> configuration parameter</primary>
2615 </indexterm>
2616 <listitem>
2617 <para>
2618 Controls whether or not the SQL statement that causes an error
2619 condition will be recorded in the server log. The current
2620 SQL statement is included in the log entry for any message of
2621 the specified severity or higher.
2622 Valid values are <literal>DEBUG5</literal>,
2623 <literal>DEBUG4</literal>, <literal>DEBUG3</literal>,
2624 <literal>DEBUG2</literal>, <literal>DEBUG1</literal>,
2625 <literal>INFO</literal>, <literal>NOTICE</literal>,
2626 <literal>WARNING</literal>, <literal>ERROR</literal>,
2627 <literal>LOG</literal>,
2628 <literal>FATAL</literal>, and <literal>PANIC</literal>.
2629 The default is <literal>ERROR</literal>, which means statements
2630 causing errors, log messages, fatal errors, or panics will be logged.
2631 To effectively turn off logging of failing statements,
2632 set this parameter to <literal>PANIC</literal>.
2633 Only superusers can change this setting.
2634 </para>
2635 </listitem>
2636 </varlistentry>
2638 <varlistentry id="guc-log-min-duration-statement" xreflabel="log_min_duration_statement">
2639 <term><varname>log_min_duration_statement</varname> (<type>integer</type>)</term>
2640 <indexterm>
2641 <primary><varname>log_min_duration_statement</> configuration parameter</primary>
2642 </indexterm>
2643 <listitem>
2644 <para>
2645 Causes the duration of each completed statement to be logged
2646 if the statement ran for at least the specified number of
2647 milliseconds. Setting this to zero prints all statement durations.
2648 Minus-one (the default) disables logging statement durations.
2649 For example, if you set it to <literal>250ms</literal>
2650 then all SQL statements that run 250ms or longer will be
2651 logged. Enabling this parameter can be helpful in tracking down
2652 unoptimized queries in your applications.
2653 Only superusers can change this setting.
2654 </para>
2656 <para>
2657 For clients using extended query protocol, durations of the Parse,
2658 Bind, and Execute steps are logged independently.
2659 </para>
2661 <note>
2662 <para>
2663 When using this option together with
2664 <xref linkend="guc-log-statement">,
2665 the text of statements that are logged because of
2666 <varname>log_statement</> will not be repeated in the
2667 duration log message.
2668 If you are not using <application>syslog</>, it is recommended
2669 that you log the PID or session ID using
2670 <xref linkend="guc-log-line-prefix">
2671 so that you can link the statement message to the later
2672 duration message using the process ID or session ID.
2673 </para>
2674 </note>
2675 </listitem>
2676 </varlistentry>
2678 <varlistentry id="guc-silent-mode" xreflabel="silent_mode">
2679 <term><varname>silent_mode</varname> (<type>boolean</type>)</term>
2680 <indexterm>
2681 <primary><varname>silent_mode</> configuration parameter</primary>
2682 </indexterm>
2683 <listitem>
2684 <para>
2685 Runs the server silently. If this parameter is set, the server
2686 will automatically run in background and any controlling
2687 terminals are disassociated.
2688 The server's standard output and standard error are redirected
2689 to <literal>/dev/null</>, so any messages sent to them will be lost.
2690 Unless <application>syslog</> logging is selected or
2691 <varname>logging_collector</> is enabled, using this parameter
2692 is discouraged because it makes it impossible to see error messages.
2693 This parameter can only be set at server start.
2694 </para>
2695 </listitem>
2696 </varlistentry>
2698 </variablelist>
2700 <para>
2701 <xref linkend="runtime-config-severity-levels"> explains the message
2702 severity levels used by <productname>PostgreSQL</>. If logging output
2703 is sent to <systemitem>syslog</systemitem> or Windows'
2704 <systemitem>eventlog</systemitem>, the severity levels are translated
2705 as shown in the table.
2706 </para>
2708 <table id="runtime-config-severity-levels">
2709 <title>Message severity levels</title>
2710 <tgroup cols="4">
2711 <thead>
2712 <row>
2713 <entry>Severity</entry>
2714 <entry>Usage</entry>
2715 <entry><systemitem>syslog</></entry>
2716 <entry><systemitem>eventlog</></entry>
2717 </row>
2718 </thead>
2720 <tbody>
2721 <row>
2722 <entry><literal>DEBUG1..DEBUG5</></entry>
2723 <entry>Provides successively-more-detailed information for use by
2724 developers.</entry>
2725 <entry><literal>DEBUG</></entry>
2726 <entry><literal>INFORMATION</></entry>
2727 </row>
2729 <row>
2730 <entry><literal>INFO</></entry>
2731 <entry>Provides information implicitly requested by the user,
2732 e.g., output from <command>VACUUM VERBOSE</>.</entry>
2733 <entry><literal>INFO</></entry>
2734 <entry><literal>INFORMATION</></entry>
2735 </row>
2737 <row>
2738 <entry><literal>NOTICE</></entry>
2739 <entry>Provides information that might be helpful to users, e.g.,
2740 notice of truncation of long identifiers.</entry>
2741 <entry><literal>NOTICE</></entry>
2742 <entry><literal>INFORMATION</></entry>
2743 </row>
2745 <row>
2746 <entry><literal>WARNING</></entry>
2747 <entry>Provides warnings of likely problems, e.g., <command>COMMIT</>
2748 outside a transaction block.</entry>
2749 <entry><literal>NOTICE</></entry>
2750 <entry><literal>WARNING</></entry>
2751 </row>
2753 <row>
2754 <entry><literal>ERROR</></entry>
2755 <entry>Reports an error that caused the current command to
2756 abort.</entry>
2757 <entry><literal>WARNING</></entry>
2758 <entry><literal>ERROR</></entry>
2759 </row>
2761 <row>
2762 <entry><literal>LOG</></entry>
2763 <entry>Reports information of interest to administrators, e.g.,
2764 checkpoint activity.</entry>
2765 <entry><literal>INFO</></entry>
2766 <entry><literal>INFORMATION</></entry>
2767 </row>
2769 <row>
2770 <entry><literal>FATAL</></entry>
2771 <entry>Reports an error that caused the current session to
2772 abort.</entry>
2773 <entry><literal>ERR</></entry>
2774 <entry><literal>ERROR</></entry>
2775 </row>
2777 <row>
2778 <entry><literal>PANIC</></entry>
2779 <entry>Reports an error that caused all database sessions to abort.</entry>
2780 <entry><literal>CRIT</></entry>
2781 <entry><literal>ERROR</></entry>
2782 </row>
2783 </tbody>
2784 </tgroup>
2785 </table>
2787 </sect2>
2788 <sect2 id="runtime-config-logging-what">
2789 <title>What To Log</title>
2791 <variablelist>
2793 <varlistentry>
2794 <term><varname>debug_print_parse</varname> (<type>boolean</type>)</term>
2795 <term><varname>debug_print_rewritten</varname> (<type>boolean</type>)</term>
2796 <term><varname>debug_print_plan</varname> (<type>boolean</type>)</term>
2797 <indexterm>
2798 <primary><varname>debug_print_parse</> configuration parameter</primary>
2799 </indexterm>
2800 <indexterm>
2801 <primary><varname>debug_print_rewritten</> configuration parameter</primary>
2802 </indexterm>
2803 <indexterm>
2804 <primary><varname>debug_print_plan</> configuration parameter</primary>
2805 </indexterm>
2806 <listitem>
2807 <para>
2808 These parameters enable various debugging output to be emitted.
2809 When set, they print the resulting parse tree, the query rewriter
2810 output, or the execution plan for each executed query.
2811 These messages are emitted at <literal>LOG</> message level, so by
2812 default they will appear in the server log but will not be sent to the
2813 client. You can change that by adjusting
2814 <xref linkend="guc-client-min-messages"> and/or
2815 <xref linkend="guc-log-min-messages">.
2816 These parameters are off by default.
2817 </para>
2818 </listitem>
2819 </varlistentry>
2821 <varlistentry>
2822 <term><varname>debug_pretty_print</varname> (<type>boolean</type>)</term>
2823 <indexterm>
2824 <primary><varname>debug_pretty_print</> configuration parameter</primary>
2825 </indexterm>
2826 <listitem>
2827 <para>
2828 When set, <varname>debug_pretty_print</varname> indents the messages
2829 produced by <varname>debug_print_parse</varname>,
2830 <varname>debug_print_rewritten</varname>, or
2831 <varname>debug_print_plan</varname>. This results in more readable
2832 but much longer output than the <quote>compact</> format used when
2833 it is off. It is on by default.
2834 </para>
2835 </listitem>
2836 </varlistentry>
2838 <varlistentry id="guc-log-checkpoints" xreflabel="log_checkpoints">
2839 <term><varname>log_checkpoints</varname> (<type>boolean</type>)</term>
2840 <indexterm>
2841 <primary><varname>log_checkpoints</> configuration parameter</primary>
2842 </indexterm>
2843 <listitem>
2844 <para>
2845 Causes checkpoints to be logged in the server log. Some
2846 statistics about each checkpoint are included in the log messages,
2847 including the number of buffers written and the time spent writing
2848 them.
2849 This parameter can only be set in the <filename>postgresql.conf</>
2850 file or on the server command line. The default is off.
2851 </para>
2852 </listitem>
2853 </varlistentry>
2855 <varlistentry id="guc-log-connections" xreflabel="log_connections">
2856 <term><varname>log_connections</varname> (<type>boolean</type>)</term>
2857 <indexterm>
2858 <primary><varname>log_connections</> configuration parameter</primary>
2859 </indexterm>
2860 <listitem>
2861 <para>
2862 Causes each attempted connection to the server to be logged,
2863 as well as successful completion of client authentication.
2864 This parameter can only be set in the <filename>postgresql.conf</>
2865 file or on the server command line. The default is off.
2866 </para>
2868 <note>
2869 <para>
2870 Some client programs, like <application>psql</>, attempt
2871 to connect twice while determining if a password is required, so
2872 duplicate <quote>connection received</> messages do not
2873 necessarily indicate a problem.
2874 </para>
2875 </note>
2876 </listitem>
2877 </varlistentry>
2879 <varlistentry id="guc-log-disconnections" xreflabel="log_disconnections">
2880 <term><varname>log_disconnections</varname> (<type>boolean</type>)</term>
2881 <indexterm>
2882 <primary><varname>log_disconnections</> configuration parameter</primary>
2883 </indexterm>
2884 <listitem>
2885 <para>
2886 This outputs a line in the server log similar to
2887 <varname>log_connections</varname> but at session termination,
2888 and includes the duration of the session. This is off by
2889 default.
2890 This parameter can only be set in the <filename>postgresql.conf</>
2891 file or on the server command line.
2892 </para>
2893 </listitem>
2894 </varlistentry>
2897 <varlistentry id="guc-log-duration" xreflabel="log_duration">
2898 <term><varname>log_duration</varname> (<type>boolean</type>)</term>
2899 <indexterm>
2900 <primary><varname>log_duration</> configuration parameter</primary>
2901 </indexterm>
2902 <listitem>
2903 <para>
2904 Causes the duration of every completed statement to be logged.
2905 The default is <literal>off</>.
2906 Only superusers can change this setting.
2907 </para>
2909 <para>
2910 For clients using extended query protocol, durations of the Parse,
2911 Bind, and Execute steps are logged independently.
2912 </para>
2914 <note>
2915 <para>
2916 The difference between setting this option and setting
2917 <xref linkend="guc-log-min-duration-statement"> to zero is that
2918 exceeding <varname>log_min_duration_statement</> forces the text of
2919 the query to be logged, but this option doesn't. Thus, if
2920 <varname>log_duration</> is <literal>on</> and
2921 <varname>log_min_duration_statement</> has a positive value, all
2922 durations are logged but the query text is included only for
2923 statements exceeding the threshold. This behavior can be useful for
2924 gathering statistics in high-load installations.
2925 </para>
2926 </note>
2927 </listitem>
2928 </varlistentry>
2930 <varlistentry id="guc-log-hostname" xreflabel="log_hostname">
2931 <term><varname>log_hostname</varname> (<type>boolean</type>)</term>
2932 <indexterm>
2933 <primary><varname>log_hostname</> configuration parameter</primary>
2934 </indexterm>
2935 <listitem>
2936 <para>
2937 By default, connection log messages only show the IP address of the
2938 connecting host. Turning on this parameter causes logging of the
2939 host name as well. Note that depending on your host name resolution
2940 setup this might impose a non-negligible performance penalty.
2941 This parameter can only be set in the <filename>postgresql.conf</>
2942 file or on the server command line.
2943 </para>
2944 </listitem>
2945 </varlistentry>
2947 <varlistentry id="guc-log-line-prefix" xreflabel="log_line_prefix">
2948 <term><varname>log_line_prefix</varname> (<type>string</type>)</term>
2949 <indexterm>
2950 <primary><varname>log_line_prefix</> configuration parameter</primary>
2951 </indexterm>
2952 <listitem>
2953 <para>
2954 This is a <function>printf</>-style string that is output at the
2955 beginning of each log line.
2956 <literal>%</> characters begin <quote>escape sequences</>
2957 that are replaced with status information as outlined below.
2958 Unrecognized escapes are ignored. Other
2959 characters are copied straight to the log line. Some escapes are
2960 only recognized by session processes, and do not apply to
2961 background processes such as the main server process.
2962 This parameter can only be set in the <filename>postgresql.conf</>
2963 file or on the server command line. The default is an empty string.
2965 <informaltable>
2966 <tgroup cols="3">
2967 <thead>
2968 <row>
2969 <entry>Escape</entry>
2970 <entry>Effect</entry>
2971 <entry>Session only</entry>
2972 </row>
2973 </thead>
2974 <tbody>
2975 <row>
2976 <entry><literal>%u</literal></entry>
2977 <entry>User name</entry>
2978 <entry>yes</entry>
2979 </row>
2980 <row>
2981 <entry><literal>%d</literal></entry>
2982 <entry>Database name</entry>
2983 <entry>yes</entry>
2984 </row>
2985 <row>
2986 <entry><literal>%r</literal></entry>
2987 <entry>Remote host name or IP address, and remote port</entry>
2988 <entry>yes</entry>
2989 </row>
2990 <row>
2991 <entry><literal>%h</literal></entry>
2992 <entry>Remote host name or IP address</entry>
2993 <entry>yes</entry>
2994 </row>
2995 <row>
2996 <entry><literal>%p</literal></entry>
2997 <entry>Process ID</entry>
2998 <entry>no</entry>
2999 </row>
3000 <row>
3001 <entry><literal>%t</literal></entry>
3002 <entry>Time stamp without milliseconds</entry>
3003 <entry>no</entry>
3004 </row>
3005 <row>
3006 <entry><literal>%m</literal></entry>
3007 <entry>Time stamp with milliseconds</entry>
3008 <entry>no</entry>
3009 </row>
3010 <row>
3011 <entry><literal>%i</literal></entry>
3012 <entry>Command tag: type of session's current command</entry>
3013 <entry>yes</entry>
3014 </row>
3015 <row>
3016 <entry><literal>%c</literal></entry>
3017 <entry>Session ID: see below</entry>
3018 <entry>no</entry>
3019 </row>
3020 <row>
3021 <entry><literal>%l</literal></entry>
3022 <entry>Number of the log line for each session or process, starting at 1</entry>
3023 <entry>no</entry>
3024 </row>
3025 <row>
3026 <entry><literal>%s</literal></entry>
3027 <entry>Process start time stamp</entry>
3028 <entry>no</entry>
3029 </row>
3030 <row>
3031 <entry><literal>%v</literal></entry>
3032 <entry>Virtual transaction ID (backendID/localXID)</entry>
3033 <entry>no</entry>
3034 </row>
3035 <row>
3036 <entry><literal>%x</literal></entry>
3037 <entry>Transaction ID (0 if none is assigned)</entry>
3038 <entry>no</entry>
3039 </row>
3040 <row>
3041 <entry><literal>%q</literal></entry>
3042 <entry>Produces no output, but tells non-session
3043 processes to stop at this point in the string; ignored by
3044 session processes</entry>
3045 <entry>no</entry>
3046 </row>
3047 <row>
3048 <entry><literal>%%</literal></entry>
3049 <entry>Literal <literal>%</></entry>
3050 <entry>no</entry>
3051 </row>
3052 </tbody>
3053 </tgroup>
3054 </informaltable>
3056 The <literal>%c</> escape prints a quasi-unique session identifier,
3057 consisting of two 4-byte hexadecimal numbers (without leading zeros)
3058 separated by a dot. The numbers are the process start time and the
3059 process ID, so <literal>%c</> can also be used as a space saving way
3060 of printing those items.
3061 </para>
3063 <tip>
3064 <para>
3065 If you set a nonempty value for <varname>log_line_prefix</>,
3066 you should usually make its last character be a space, to provide
3067 visual separation from the rest of the log line. A punctuation
3068 character could be used too.
3069 </para>
3070 </tip>
3072 <tip>
3073 <para>
3074 <application>Syslog</> produces its own
3075 time stamp and process ID information, so you probably do not want to
3076 use those escapes if you are logging to <application>syslog</>.
3077 </para>
3078 </tip>
3079 </listitem>
3080 </varlistentry>
3082 <varlistentry id="guc-log-lock-waits" xreflabel="log_lock_waits">
3083 <term><varname>log_lock_waits</varname> (<type>boolean</type>)</term>
3084 <indexterm>
3085 <primary><varname>log_lock_waits</> configuration parameter</primary>
3086 </indexterm>
3087 <listitem>
3088 <para>
3089 Controls whether a log message is produced when a session waits
3090 longer than <xref linkend="guc-deadlock-timeout"> to acquire a
3091 lock. This is useful in determining if lock waits are causing
3092 poor performance. The default is <literal>off</>.
3093 </para>
3094 </listitem>
3095 </varlistentry>
3097 <varlistentry id="guc-log-statement" xreflabel="log_statement">
3098 <term><varname>log_statement</varname> (<type>enum</type>)</term>
3099 <indexterm>
3100 <primary><varname>log_statement</> configuration parameter</primary>
3101 </indexterm>
3102 <listitem>
3103 <para>
3104 Controls which SQL statements are logged. Valid values are
3105 <literal>none</>, <literal>ddl</>, <literal>mod</>, and
3106 <literal>all</>. <literal>ddl</> logs all data definition
3107 statements, such as <command>CREATE</>, <command>ALTER</>, and
3108 <command>DROP</> statements. <literal>mod</> logs all
3109 <literal>ddl</> statements, plus data-modifying statements
3110 such as <command>INSERT</>,
3111 <command>UPDATE</>, <command>DELETE</>, <command>TRUNCATE</>,
3112 and <command>COPY FROM</>.
3113 <command>PREPARE</>, <command>EXECUTE</>, and
3114 <command>EXPLAIN ANALYZE</> statements are also logged if their
3115 contained command is of an appropriate type. For clients using
3116 extended query protocol, logging occurs when an Execute message
3117 is received, and values of the Bind parameters are included
3118 (with any embedded single-quote marks doubled).
3119 </para>
3121 <para>
3122 The default is <literal>none</>. Only superusers can change this
3123 setting.
3124 </para>
3126 <note>
3127 <para>
3128 Statements that contain simple syntax errors are not logged
3129 even by the <varname>log_statement</> = <literal>all</> setting,
3130 because the log message is emitted only after basic parsing has
3131 been done to determine the statement type. In the case of extended
3132 query protocol, this setting likewise does not log statements that
3133 fail before the Execute phase (i.e., during parse analysis or
3134 planning). Set <varname>log_min_error_statement</> to
3135 <literal>ERROR</> (or lower) to log such statements.
3136 </para>
3137 </note>
3138 </listitem>
3139 </varlistentry>
3141 <varlistentry id="guc-log-temp-files" xreflabel="log_temp_files">
3142 <term><varname>log_temp_files</varname> (<type>integer</type>)</term>
3143 <indexterm>
3144 <primary><varname>log_temp_files</> configuration parameter</primary>
3145 </indexterm>
3146 <listitem>
3147 <para>
3148 Controls whether temporary files are logged when deleted.
3149 Temporary files can be
3150 created for sorts, hashes, and temporary query results.
3151 A value of zero logs all temporary files, and positive
3152 values log only files whose size is equal or greater than
3153 the specified number of kilobytes. The
3154 default is <literal>-1</>, which disables this logging.
3155 Only superusers can change this setting.
3156 </para>
3157 </listitem>
3158 </varlistentry>
3160 <varlistentry id="guc-log-timezone" xreflabel="log_timezone">
3161 <term><varname>log_timezone</varname> (<type>string</type>)</term>
3162 <indexterm>
3163 <primary><varname>log_timezone</> configuration parameter</primary>
3164 </indexterm>
3165 <listitem>
3166 <para>
3167 Sets the time zone used for timestamps written in the log.
3168 Unlike <xref linkend="guc-timezone">, this value is cluster-wide,
3169 so that all sessions will report timestamps consistently.
3170 The default is <literal>unknown</>, which means to use whatever
3171 the system environment specifies as the time zone. See <xref
3172 linkend="datatype-timezones"> for more information.
3173 This parameter can only be set in the <filename>postgresql.conf</>
3174 file or on the server command line.
3175 </para>
3176 </listitem>
3177 </varlistentry>
3179 </variablelist>
3180 </sect2>
3181 <sect2 id="runtime-config-logging-csvlog">
3182 <title>Using CSV-Format Log Output</title>
3184 <para>
3185 Including <literal>csvlog</> in the <varname>log_destination</> list
3186 provides a convenient way to import log files into a database table.
3187 This option emits log lines in comma-separated-value format,
3188 with these columns: timestamp with milliseconds, user name, database
3189 name, process ID, host:port number, session ID, per-session or -process line
3190 number, command tag, session start time, virtual transaction ID,
3191 regular transaction id, error severity, SQL state code, error message,
3192 error message detail, hint, internal query that led to the error (if
3193 any), character count of the error position thereof, error context,
3194 user query that led to the error (if any and enabled by
3195 <varname>log_min_error_statement</>), character count of the error
3196 position thereof, location of the error in the PostgreSQL source code
3197 (if <varname>log_error_verbosity</> is set to <literal>verbose</>).
3198 Here is a sample table definition for storing CSV-format log output:
3200 <programlisting>
3201 CREATE TABLE postgres_log
3203 log_time timestamp(3) with time zone,
3204 user_name text,
3205 database_name text,
3206 process_id integer,
3207 connection_from text,
3208 session_id text,
3209 session_line_num bigint,
3210 command_tag text,
3211 session_start_time timestamp with time zone,
3212 virtual_transaction_id text,
3213 transaction_id bigint,
3214 error_severity text,
3215 sql_state_code text,
3216 message text,
3217 detail text,
3218 hint text,
3219 internal_query text,
3220 internal_query_pos integer,
3221 context text,
3222 query text,
3223 query_pos integer,
3224 location text,
3225 PRIMARY KEY (session_id, session_line_num)
3227 </programlisting>
3228 </para>
3230 <para>
3231 To import a log file into this table, use the <command>COPY FROM</>
3232 command:
3234 <programlisting>
3235 COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
3236 </programlisting>
3237 </para>
3239 <para>
3240 There are a few things you need to do to simplify importing CSV log
3241 files easily and automatically:
3243 <orderedlist>
3244 <listitem>
3245 <para>
3246 Set <varname>log_filename</varname> and
3247 <varname>log_rotation_age</> to provide a consistent,
3248 predictable naming scheme for your log files. This lets you
3249 predict what the file name will be and know when an individual log
3250 file is complete and therefore ready to be imported.
3251 </para>
3252 </listitem>
3254 <listitem>
3255 <para>
3256 Set <varname>log_rotation_size</varname> to 0 to disable
3257 size-based log rotation, as it makes the log file name difficult
3258 to predict.
3259 </para>
3260 </listitem>
3262 <listitem>
3263 <para>
3264 Set <varname>log_truncate_on_rotation</varname> to <literal>on</> so
3265 that old log data isn't mixed with the new in the same file.
3266 </para>
3267 </listitem>
3269 <listitem>
3270 <para>
3271 The table definition above includes a primary key specification.
3272 This is useful to protect against accidentally importing the same
3273 information twice. The <command>COPY</> command commits all of the
3274 data it imports at one time, so any error will cause the entire
3275 import to fail. If you import a partial log file and later import
3276 the file again when it is complete, the primary key violation will
3277 cause the import to fail. Wait until the log is complete and
3278 closed before importing. This procedure will also protect against
3279 accidentally importing a partial line that hasn't been completely
3280 written, which would also cause <command>COPY</> to fail.
3281 </para>
3282 </listitem>
3283 </orderedlist>
3284 </para>
3286 </sect2>
3287 </sect1>
3289 <sect1 id="runtime-config-statistics">
3290 <title>Run-Time Statistics</title>
3292 <sect2 id="runtime-config-statistics-collector">
3293 <title>Query and Index Statistics Collector</title>
3295 <para>
3296 These parameters control server-wide statistics collection features.
3297 When statistics collection is enabled, the data that is produced can be
3298 accessed via the <structname>pg_stat</structname> and
3299 <structname>pg_statio</structname> family of system views.
3300 Refer to <xref linkend="monitoring"> for more information.
3301 </para>
3303 <variablelist>
3305 <varlistentry id="guc-track-activities" xreflabel="track_activities">
3306 <term><varname>track_activities</varname> (<type>boolean</type>)</term>
3307 <indexterm>
3308 <primary><varname>track_activities</> configuration parameter</primary>
3309 </indexterm>
3310 <listitem>
3311 <para>
3312 Enables the collection of information on the currently
3313 executing command of each session, along with the time at
3314 which that command began execution. This parameter is on by
3315 default. Note that even when enabled, this information is not
3316 visible to all users, only to superusers and the user owning
3317 the session being reported on; so it should not represent a
3318 security risk.
3319 Only superusers can change this setting.
3320 </para>
3321 </listitem>
3322 </varlistentry>
3324 <varlistentry id="guc-track-activity-query-size" xreflabel="track_activity_query_size">
3325 <term><varname>track_activity_query_size</varname> (<type>integer</type>)</term>
3326 <indexterm>
3327 <primary><varname>track_activity_query_size</> configuration parameter</primary>
3328 </indexterm>
3329 <listitem>
3330 <para>
3331 Specifies the number of bytes reserved to track the currently
3332 executing command for each active session, for the
3333 <structname>pg_stat_activity</>.<structfield>current_query</> field.
3334 The default value is 1024. This parameter can only be set at server
3335 start.
3336 </para>
3337 </listitem>
3338 </varlistentry>
3340 <varlistentry id="guc-track-counts" xreflabel="track_counts">
3341 <term><varname>track_counts</varname> (<type>boolean</type>)</term>
3342 <indexterm>
3343 <primary><varname>track_counts</> configuration parameter</primary>
3344 </indexterm>
3345 <listitem>
3346 <para>
3347 Enables collection of statistics on database activity.
3348 This parameter is on by default, because the autovacuum
3349 daemon needs the collected information.
3350 Only superusers can change this setting.
3351 </para>
3352 </listitem>
3353 </varlistentry>
3355 <varlistentry id="guc-track-functions" xreflabel="track_functions">
3356 <term><varname>track_functions</varname> (<type>enum</type>)</term>
3357 <indexterm>
3358 <primary><varname>track_functions</> configuration parameter</primary>
3359 </indexterm>
3360 <listitem>
3361 <para>
3362 Enables tracking of function call counts and time used. Specify
3363 <literal>pl</literal> to count only procedural language functions,
3364 <literal>all</literal> to also track SQL and C language functions.
3365 The default is <literal>none</literal>.
3366 Only superusers can change this setting.
3367 </para>
3368 </listitem>
3369 </varlistentry>
3371 <varlistentry id="guc-update-process-title" xreflabel="update_process_title">
3372 <term><varname>update_process_title</varname> (<type>boolean</type>)</term>
3373 <indexterm>
3374 <primary><varname>update_process_title</> configuration parameter</primary>
3375 </indexterm>
3376 <listitem>
3377 <para>
3378 Enables updating of the process title every time a new SQL command
3379 is received by the server. The process title is typically viewed
3380 by the <command>ps</> command,
3381 or in Windows by using the <application>Process Explorer</>.
3382 Only superusers can change this setting.
3383 </para>
3384 </listitem>
3385 </varlistentry>
3387 <varlistentry id="guc-stats-temp-directory" xreflabel="stats_temp_directory">
3388 <term><varname>stats_temp_directory</varname> (<type>string</type>)</term>
3389 <indexterm>
3390 <primary><varname>stats_temp_directory</> configuration parameter</primary>
3391 </indexterm>
3392 <listitem>
3393 <para>
3394 Sets the directory to store temporary statistics data in. This can be
3395 a path relative to the data directory or an absolute path. The default
3396 is <filename>pg_stat_tmp</filename>. Pointing this at a RAM based
3397 filesystem will decrease physical I/O requirements and can lead to
3398 improved performance.
3399 This parameter can only be set in the <filename>postgresql.conf</>
3400 file or on the server command line.
3401 </para>
3402 </listitem>
3403 </varlistentry>
3405 </variablelist>
3406 </sect2>
3408 <sect2 id="runtime-config-statistics-monitor">
3409 <title>Statistics Monitoring</title>
3410 <variablelist>
3412 <varlistentry>
3413 <term><varname>log_statement_stats</varname> (<type>boolean</type>)</term>
3414 <term><varname>log_parser_stats</varname> (<type>boolean</type>)</term>
3415 <term><varname>log_planner_stats</varname> (<type>boolean</type>)</term>
3416 <term><varname>log_executor_stats</varname> (<type>boolean</type>)</term>
3417 <indexterm>
3418 <primary><varname>log_statement_stats</> configuration parameter</primary>
3419 </indexterm>
3420 <indexterm>
3421 <primary><varname>log_parser_stats</> configuration parameter</primary>
3422 </indexterm>
3423 <indexterm>
3424 <primary><varname>log_planner_stats</> configuration parameter</primary>
3425 </indexterm>
3426 <indexterm>
3427 <primary><varname>log_executor_stats</> configuration parameter</primary>
3428 </indexterm>
3429 <listitem>
3430 <para>
3431 For each query, write performance statistics of the respective
3432 module to the server log. This is a crude profiling
3433 instrument. <varname>log_statement_stats</varname> reports total
3434 statement statistics, while the others report per-module statistics.
3435 <varname>log_statement_stats</varname> cannot be enabled together with
3436 any of the per-module options. All of these options are disabled by
3437 default. Only superusers can change these settings.
3438 </para>
3439 </listitem>
3440 </varlistentry>
3442 </variablelist>
3444 </sect2>
3445 </sect1>
3447 <sect1 id="runtime-config-autovacuum">
3448 <title>Automatic Vacuuming</title>
3450 <indexterm>
3451 <primary>autovacuum</primary>
3452 <secondary>configuration parameters</secondary>
3453 </indexterm>
3455 <para>
3456 These settings control the behavior of the <firstterm>autovacuum</>
3457 feature. Refer to <xref linkend="autovacuum"> for
3458 more information.
3459 </para>
3461 <variablelist>
3463 <varlistentry id="guc-autovacuum" xreflabel="autovacuum">
3464 <term><varname>autovacuum</varname> (<type>boolean</type>)</term>
3465 <indexterm>
3466 <primary><varname>autovacuum</> configuration parameter</primary>
3467 </indexterm>
3468 <listitem>
3469 <para>
3470 Controls whether the server should run the
3471 autovacuum launcher daemon. This is on by default; however,
3472 <xref linkend="guc-track-counts"> must also be turned on for
3473 autovacuum to work.
3474 This parameter can only be set in the <filename>postgresql.conf</>
3475 file or on the server command line.
3476 </para>
3477 <para>
3478 Note that even when this parameter is disabled, the system
3479 will launch autovacuum processes if necessary to
3480 prevent transaction ID wraparound. See <xref
3481 linkend="vacuum-for-wraparound"> for more information.
3482 </para>
3483 </listitem>
3484 </varlistentry>
3486 <varlistentry id="guc-log-autovacuum-min-duration" xreflabel="log_autovacuum_min_duration">
3487 <term><varname>log_autovacuum_min_duration</varname> (<type>integer</type>)</term>
3488 <indexterm>
3489 <primary><varname>log_autovacuum_min_duration</> configuration parameter</primary>
3490 </indexterm>
3491 <listitem>
3492 <para>
3493 Causes each action executed by autovacuum to be logged if it ran for at
3494 least the specified number of milliseconds. Setting this to zero logs
3495 all autovacuum actions. Minus-one (the default) disables logging
3496 autovacuum actions. For example, if you set this to
3497 <literal>250ms</literal> then all automatic vacuums and analyzes that run
3498 250ms or longer will be logged. Enabling this parameter can be helpful
3499 in tracking autovacuum activity. This setting can only be set in
3500 the <filename>postgresql.conf</> file or on the server command line.
3501 </para>
3502 </listitem>
3503 </varlistentry>
3505 <varlistentry id="guc-autovacuum-max-workers" xreflabel="autovacuum_max_workers">
3506 <term><varname>autovacuum_max_workers</varname> (<type>integer</type>)</term>
3507 <indexterm>
3508 <primary><varname>autovacuum_max_workers</> configuration parameter</primary>
3509 </indexterm>
3510 <listitem>
3511 <para>
3512 Specifies the maximum number of autovacuum processes (other than the
3513 autovacuum launcher) which may be running at any one time. The default
3514 is three. This parameter can only be set in
3515 the <filename>postgresql.conf</> file or on the server command line.
3516 </para>
3517 </listitem>
3518 </varlistentry>
3520 <varlistentry id="guc-autovacuum-naptime" xreflabel="autovacuum_naptime">
3521 <term><varname>autovacuum_naptime</varname> (<type>integer</type>)</term>
3522 <indexterm>
3523 <primary><varname>autovacuum_naptime</> configuration parameter</primary>
3524 </indexterm>
3525 <listitem>
3526 <para>
3527 Specifies the minimum delay between autovacuum runs on any given
3528 database. In each round the daemon examines the
3529 database and issues <command>VACUUM</> and <command>ANALYZE</> commands
3530 as needed for tables in that database. The delay is measured
3531 in seconds, and the default is one minute (<literal>1m</>).
3532 This parameter can only be set in the <filename>postgresql.conf</>
3533 file or on the server command line.
3534 </para>
3535 </listitem>
3536 </varlistentry>
3538 <varlistentry id="guc-autovacuum-vacuum-threshold" xreflabel="autovacuum_vacuum_threshold">
3539 <term><varname>autovacuum_vacuum_threshold</varname> (<type>integer</type>)</term>
3540 <indexterm>
3541 <primary><varname>autovacuum_vacuum_threshold</> configuration parameter</primary>
3542 </indexterm>
3543 <listitem>
3544 <para>
3545 Specifies the minimum number of updated or deleted tuples needed
3546 to trigger a <command>VACUUM</> in any one table.
3547 The default is 50 tuples.
3548 This parameter can only be set in the <filename>postgresql.conf</>
3549 file or on the server command line.
3550 This setting can be overridden for individual tables by entries in
3551 <structname>pg_autovacuum</>.
3552 </para>
3553 </listitem>
3554 </varlistentry>
3556 <varlistentry id="guc-autovacuum-analyze-threshold" xreflabel="autovacuum_analyze_threshold">
3557 <term><varname>autovacuum_analyze_threshold</varname> (<type>integer</type>)</term>
3558 <indexterm>
3559 <primary><varname>autovacuum_analyze_threshold</> configuration parameter</primary>
3560 </indexterm>
3561 <listitem>
3562 <para>
3563 Specifies the minimum number of inserted, updated or deleted tuples
3564 needed to trigger an <command>ANALYZE</> in any one table.
3565 The default is 50 tuples.
3566 This parameter can only be set in the <filename>postgresql.conf</>
3567 file or on the server command line.
3568 This setting can be overridden for individual tables by entries in
3569 <structname>pg_autovacuum</>.
3570 </para>
3571 </listitem>
3572 </varlistentry>
3574 <varlistentry id="guc-autovacuum-vacuum-scale-factor" xreflabel="autovacuum_vacuum_scale_factor">
3575 <term><varname>autovacuum_vacuum_scale_factor</varname> (<type>floating point</type>)</term>
3576 <indexterm>
3577 <primary><varname>autovacuum_vacuum_scale_factor</> configuration parameter</primary>
3578 </indexterm>
3579 <listitem>
3580 <para>
3581 Specifies a fraction of the table size to add to
3582 <varname>autovacuum_vacuum_threshold</varname>
3583 when deciding whether to trigger a <command>VACUUM</>.
3584 The default is 0.2 (20% of table size).
3585 This parameter can only be set in the <filename>postgresql.conf</>
3586 file or on the server command line.
3587 This setting can be overridden for individual tables by entries in
3588 <structname>pg_autovacuum</>.
3589 </para>
3590 </listitem>
3591 </varlistentry>
3593 <varlistentry id="guc-autovacuum-analyze-scale-factor" xreflabel="autovacuum_analyze_scale_factor">
3594 <term><varname>autovacuum_analyze_scale_factor</varname> (<type>floating point</type>)</term>
3595 <indexterm>
3596 <primary><varname>autovacuum_analyze_scale_factor</> configuration parameter</primary>
3597 </indexterm>
3598 <listitem>
3599 <para>
3600 Specifies a fraction of the table size to add to
3601 <varname>autovacuum_analyze_threshold</varname>
3602 when deciding whether to trigger an <command>ANALYZE</>.
3603 The default is 0.1 (10% of table size).
3604 This parameter can only be set in the <filename>postgresql.conf</>
3605 file or on the server command line.
3606 This setting can be overridden for individual tables by entries in
3607 <structname>pg_autovacuum</>.
3608 </para>
3609 </listitem>
3610 </varlistentry>
3612 <varlistentry id="guc-autovacuum-freeze-max-age" xreflabel="autovacuum_freeze_max_age">
3613 <term><varname>autovacuum_freeze_max_age</varname> (<type>integer</type>)</term>
3614 <indexterm>
3615 <primary><varname>autovacuum_freeze_max_age</> configuration parameter</primary>
3616 </indexterm>
3617 <listitem>
3618 <para>
3619 Specifies the maximum age (in transactions) that a table's
3620 <structname>pg_class</>.<structfield>relfrozenxid</> field can
3621 attain before a <command>VACUUM</> operation is forced to prevent
3622 transaction ID wraparound within the table. Note that the system
3623 will launch autovacuum processes to prevent wraparound even when
3624 autovacuum is otherwise disabled.
3625 The default is 200 million transactions.
3626 This parameter can only be set at server start, but the setting
3627 can be reduced for individual tables by entries in
3628 <structname>pg_autovacuum</>.
3629 For more information see <xref linkend="vacuum-for-wraparound">.
3630 </para>
3631 </listitem>
3632 </varlistentry>
3634 <varlistentry id="guc-autovacuum-vacuum-cost-delay" xreflabel="autovacuum_vacuum_cost_delay">
3635 <term><varname>autovacuum_vacuum_cost_delay</varname> (<type>integer</type>)</term>
3636 <indexterm>
3637 <primary><varname>autovacuum_vacuum_cost_delay</> configuration parameter</primary>
3638 </indexterm>
3639 <listitem>
3640 <para>
3641 Specifies the cost delay value that will be used in automatic
3642 <command>VACUUM</> operations. If <literal>-1</> is
3643 specified, the regular
3644 <xref linkend="guc-vacuum-cost-delay"> value will be used.
3645 The default value is 20 milliseconds.
3646 This parameter can only be set in the <filename>postgresql.conf</>
3647 file or on the server command line.
3648 This setting can be overridden for individual tables by entries in
3649 <structname>pg_autovacuum</>.
3650 </para>
3651 </listitem>
3652 </varlistentry>
3654 <varlistentry id="guc-autovacuum-vacuum-cost-limit" xreflabel="autovacuum_vacuum_cost_limit">
3655 <term><varname>autovacuum_vacuum_cost_limit</varname> (<type>integer</type>)</term>
3656 <indexterm>
3657 <primary><varname>autovacuum_vacuum_cost_limit</> configuration parameter</primary>
3658 </indexterm>
3659 <listitem>
3660 <para>
3661 Specifies the cost limit value that will be used in automatic
3662 <command>VACUUM</> operations. If <literal>-1</> is specified (which is the
3663 default), the regular
3664 <xref linkend="guc-vacuum-cost-limit"> value will be used. Note that
3665 the value is distributed proportionally among the running autovacuum
3666 workers, if there is more than one, so that the sum of the limits of
3667 each worker never exceeds the limit on this variable.
3668 This parameter can only be set in the <filename>postgresql.conf</>
3669 file or on the server command line.
3670 This setting can be overridden for individual tables by entries in
3671 <structname>pg_autovacuum</>.
3672 </para>
3673 </listitem>
3674 </varlistentry>
3676 </variablelist>
3677 </sect1>
3679 <sect1 id="runtime-config-client">
3680 <title>Client Connection Defaults</title>
3682 <sect2 id="runtime-config-client-statement">
3683 <title>Statement Behavior</title>
3684 <variablelist>
3686 <varlistentry id="guc-search-path" xreflabel="search_path">
3687 <term><varname>search_path</varname> (<type>string</type>)</term>
3688 <indexterm>
3689 <primary><varname>search_path</> configuration parameter</primary>
3690 </indexterm>
3691 <indexterm><primary>path</><secondary>for schemas</></>
3692 <listitem>
3693 <para>
3694 This variable specifies the order in which schemas are searched
3695 when an object (table, data type, function, etc.) is referenced by a
3696 simple name with no schema component. When there are objects of
3697 identical names in different schemas, the one found first
3698 in the search path is used. An object that is not in any of the
3699 schemas in the search path can only be referenced by specifying
3700 its containing schema with a qualified (dotted) name.
3701 </para>
3703 <para>
3704 The value for <varname>search_path</varname> has to be a comma-separated
3705 list of schema names. If one of the list items is
3706 the special value <literal>$user</literal>, then the schema
3707 having the name returned by <function>SESSION_USER</> is substituted, if there
3708 is such a schema. (If not, <literal>$user</literal> is ignored.)
3709 </para>
3711 <para>
3712 The system catalog schema, <literal>pg_catalog</>, is always
3713 searched, whether it is mentioned in the path or not. If it is
3714 mentioned in the path then it will be searched in the specified
3715 order. If <literal>pg_catalog</> is not in the path then it will
3716 be searched <emphasis>before</> searching any of the path items.
3717 </para>
3719 <para>
3720 Likewise, the current session's temporary-table schema,
3721 <literal>pg_temp_<replaceable>nnn</></>, is always searched if it
3722 exists. It can be explicitly listed in the path by using the
3723 alias <literal>pg_temp</>. If it is not listed in the path then
3724 it is searched first (before even <literal>pg_catalog</>). However,
3725 the temporary schema is only searched for relation (table, view,
3726 sequence, etc) and data type names. It will never be searched for
3727 function or operator names.
3728 </para>
3730 <para>
3731 When objects are created without specifying a particular target
3732 schema, they will be placed in the first schema listed
3733 in the search path. An error is reported if the search path is
3734 empty.
3735 </para>
3737 <para>
3738 The default value for this parameter is
3739 <literal>'"$user", public'</literal> (where the second part will be
3740 ignored if there is no schema named <literal>public</>).
3741 This supports shared use of a database (where no users
3742 have private schemas, and all share use of <literal>public</>),
3743 private per-user schemas, and combinations of these. Other
3744 effects can be obtained by altering the default search path
3745 setting, either globally or per-user.
3746 </para>
3748 <para>
3749 The current effective value of the search path can be examined
3750 via the <acronym>SQL</acronym> function
3751 <function>current_schemas()</>. This is not quite the same as
3752 examining the value of <varname>search_path</varname>, since
3753 <function>current_schemas()</> shows how the requests
3754 appearing in <varname>search_path</varname> were resolved.
3755 </para>
3757 <para>
3758 For more information on schema handling, see <xref linkend="ddl-schemas">.
3759 </para>
3760 </listitem>
3761 </varlistentry>
3763 <varlistentry id="guc-default-tablespace" xreflabel="default_tablespace">
3764 <term><varname>default_tablespace</varname> (<type>string</type>)</term>
3765 <indexterm>
3766 <primary><varname>default_tablespace</> configuration parameter</primary>
3767 </indexterm>
3768 <indexterm><primary>tablespace</><secondary>default</></>
3769 <listitem>
3770 <para>
3771 This variable specifies the default tablespace in which to create
3772 objects (tables and indexes) when a <command>CREATE</> command does
3773 not explicitly specify a tablespace.
3774 </para>
3776 <para>
3777 The value is either the name of a tablespace, or an empty string
3778 to specify using the default tablespace of the current database.
3779 If the value does not match the name of any existing tablespace,
3780 <productname>PostgreSQL</> will automatically use the default
3781 tablespace of the current database. If a nondefault tablespace
3782 is specified, the user must have <literal>CREATE</> privilege
3783 for it, or creation attempts will fail.
3784 </para>
3786 <para>
3787 This variable is not used for temporary tables; for them,
3788 <xref linkend="guc-temp-tablespaces"> is consulted instead.
3789 </para>
3791 <para>
3792 For more information on tablespaces,
3793 see <xref linkend="manage-ag-tablespaces">.
3794 </para>
3795 </listitem>
3796 </varlistentry>
3798 <varlistentry id="guc-temp-tablespaces" xreflabel="temp_tablespaces">
3799 <term><varname>temp_tablespaces</varname> (<type>string</type>)</term>
3800 <indexterm>
3801 <primary><varname>temp_tablespaces</> configuration parameter</primary>
3802 </indexterm>
3803 <indexterm><primary>tablespace</><secondary>temporary</></>
3804 <listitem>
3805 <para>
3806 This variable specifies tablespace(s) in which to create temporary
3807 objects (temp tables and indexes on temp tables) when a
3808 <command>CREATE</> command does not explicitly specify a tablespace.
3809 Temporary files for purposes such as sorting large data sets
3810 are also created in these tablespace(s).
3811 </para>
3813 <para>
3814 The value is a list of names of tablespaces. When there is more than
3815 one name in the list, <productname>PostgreSQL</> chooses a random
3816 member of the list each time a temporary object is to be created;
3817 except that within a transaction, successively created temporary
3818 objects are placed in successive tablespaces from the list.
3819 If the selected element of the list is an empty string,
3820 <productname>PostgreSQL</> will automatically use the default
3821 tablespace of the current database instead.
3822 </para>
3824 <para>
3825 When <varname>temp_tablespaces</> is set interactively, specifying a
3826 nonexistent tablespace is an error, as is specifying a tablespace for
3827 which the user does not have <literal>CREATE</> privilege. However,
3828 when using a previously set value, nonexistent tablespaces are
3829 ignored, as are tablespaces for which the user lacks
3830 <literal>CREATE</> privilege. In particular, this rule applies when
3831 using a value set in <filename>postgresql.conf</>.
3832 </para>
3834 <para>
3835 The default value is an empty string, which results in all temporary
3836 objects being created in the default tablespace of the current
3837 database.
3838 </para>
3840 <para>
3841 See also <xref linkend="guc-default-tablespace">.
3842 </para>
3843 </listitem>
3844 </varlistentry>
3846 <varlistentry id="guc-check-function-bodies" xreflabel="check_function_bodies">
3847 <term><varname>check_function_bodies</varname> (<type>boolean</type>)</term>
3848 <indexterm>
3849 <primary><varname>check_function_bodies</> configuration parameter</primary>
3850 </indexterm>
3851 <listitem>
3852 <para>
3853 This parameter is normally on. When set to <literal>off</>, it
3854 disables validation of the function body string during <xref
3855 linkend="sql-createfunction"
3856 endterm="sql-createfunction-title">. Disabling validation is
3857 occasionally useful to avoid problems such as forward references
3858 when restoring function definitions from a dump.
3859 </para>
3860 </listitem>
3861 </varlistentry>
3863 <varlistentry id="guc-default-transaction-isolation" xreflabel="default_transaction_isolation">
3864 <indexterm>
3865 <primary>transaction isolation level</primary>
3866 </indexterm>
3867 <indexterm>
3868 <primary><varname>default_transaction_isolation</> configuration parameter</primary>
3869 </indexterm>
3870 <term><varname>default_transaction_isolation</varname> (<type>enum</type>)</term>
3871 <listitem>
3872 <para>
3873 Each SQL transaction has an isolation level, which can be
3874 either <quote>read uncommitted</quote>, <quote>read
3875 committed</quote>, <quote>repeatable read</quote>, or
3876 <quote>serializable</quote>. This parameter controls the
3877 default isolation level of each new transaction. The default
3878 is <quote>read committed</quote>.
3879 </para>
3881 <para>
3882 Consult <xref linkend="mvcc"> and <xref
3883 linkend="sql-set-transaction"
3884 endterm="sql-set-transaction-title"> for more information.
3885 </para>
3886 </listitem>
3887 </varlistentry>
3889 <varlistentry id="guc-default-transaction-read-only" xreflabel="default_transaction_read_only">
3890 <indexterm>
3891 <primary>read-only transaction</primary>
3892 </indexterm>
3893 <indexterm>
3894 <primary><varname>default_transaction_read_only</> configuration parameter</primary>
3895 </indexterm>
3897 <term><varname>default_transaction_read_only</varname> (<type>boolean</type>)</term>
3898 <listitem>
3899 <para>
3900 A read-only SQL transaction cannot alter non-temporary tables.
3901 This parameter controls the default read-only status of each new
3902 transaction. The default is <literal>off</> (read/write).
3903 </para>
3905 <para>
3906 Consult <xref linkend="sql-set-transaction"
3907 endterm="sql-set-transaction-title"> for more information.
3908 </para>
3909 </listitem>
3910 </varlistentry>
3912 <varlistentry id="guc-session-replication-role" xreflabel="session_replication_role">
3913 <term><varname>session_replication_role</varname> (<type>enum</type>)</term>
3914 <indexterm>
3915 <primary><varname>session_replication_role</> configuration parameter</primary>
3916 </indexterm>
3917 <listitem>
3918 <para>
3919 Controls firing of replication-related triggers and rules for the
3920 current session. Setting this variable requires
3921 superuser privilege and results in discarding any previously cached
3922 query plans. Possible values are <literal>origin</> (the default),
3923 <literal>replica</> and <literal>local</>.
3924 See <xref linkend="sql-altertable" endterm="sql-altertable-title"> for
3925 more information.
3926 </para>
3927 </listitem>
3928 </varlistentry>
3930 <varlistentry id="guc-statement-timeout" xreflabel="statement_timeout">
3931 <term><varname>statement_timeout</varname> (<type>integer</type>)</term>
3932 <indexterm>
3933 <primary><varname>statement_timeout</> configuration parameter</primary>
3934 </indexterm>
3935 <listitem>
3936 <para>
3937 Abort any statement that takes over the specified number of
3938 milliseconds, starting from the time the command arrives at the server
3939 from the client. If <varname>log_min_error_statement</> is set to
3940 <literal>ERROR</> or lower, the statement that timed out will also be
3941 logged. A value of zero (the default) turns off the
3942 limitation.
3943 </para>
3945 <para>
3946 Setting <varname>statement_timeout</> in
3947 <filename>postgresql.conf</> is not recommended because it
3948 affects all sessions.
3949 </para>
3950 </listitem>
3951 </varlistentry>
3953 <varlistentry id="guc-vacuum-freeze-table-age" xreflabel="vacuum_freeze_table_age">
3954 <term><varname>vacuum_freeze_table_age</varname> (<type>integer</type>)</term>
3955 <indexterm>
3956 <primary><varname>vacuum_freeze_table_age</> configuration parameter</primary>
3957 </indexterm>
3958 <listitem>
3959 <para>
3960 <command>VACUUM</> performs a whole-table scan if the table's
3961 <structname>pg_class</>.<structfield>relfrozenxid</> field has reached
3962 the age specified by this setting. The default is 150 million
3963 transactions. Although users can set this value anywhere from zero to
3964 one billion, <command>VACUUM</> will silently limit the effective value
3965 to 95% of <xref linkend="guc-autovacuum-freeze-max-age">, so that a
3966 periodical manual <command>VACUUM</> has a chance to run before an
3967 anti-wraparound autovacuum is launched for the table. For more
3968 information see
3969 <xref linkend="vacuum-for-wraparound">.
3970 </para>
3971 </listitem>
3972 </varlistentry>
3974 <varlistentry id="guc-vacuum-freeze-min-age" xreflabel="vacuum_freeze_min_age">
3975 <term><varname>vacuum_freeze_min_age</varname> (<type>integer</type>)</term>
3976 <indexterm>
3977 <primary><varname>vacuum_freeze_min_age</> configuration parameter</primary>
3978 </indexterm>
3979 <listitem>
3980 <para>
3981 Specifies the cutoff age (in transactions) that <command>VACUUM</>
3982 should use to decide whether to replace transaction IDs with
3983 <literal>FrozenXID</> while scanning a table.
3984 The default is 50 million transactions. Although
3985 users can set this value anywhere from zero to one billion,
3986 <command>VACUUM</> will silently limit the effective value to half
3987 the value of <xref linkend="guc-autovacuum-freeze-max-age">, so
3988 that there is not an unreasonably short time between forced
3989 autovacuums. For more information see <xref
3990 linkend="vacuum-for-wraparound">.
3991 </para>
3992 </listitem>
3993 </varlistentry>
3995 <varlistentry id="guc-xmlbinary" xreflabel="xmlbinary">
3996 <term><varname>xmlbinary</varname> (<type>enum</type>)</term>
3997 <indexterm>
3998 <primary><varname>xmlbinary</> configuration parameter</primary>
3999 </indexterm>
4000 <listitem>
4001 <para>
4002 Sets how binary values are to be encoded in XML. This applies
4003 for example when <type>bytea</type> values are converted to
4004 XML by the functions <function>xmlelement</function> or
4005 <function>xmlforest</function>. Possible values are
4006 <literal>base64</literal> and <literal>hex</literal>, which
4007 are both defined in the XML Schema standard. The default is
4008 <literal>base64</literal>. For further information about
4009 XML-related functions, see <xref linkend="functions-xml">.
4010 </para>
4012 <para>
4013 The actual choice here is mostly a matter of taste,
4014 constrained only by possible restrictions in client
4015 applications. Both methods support all possible values,
4016 although the hex encoding will be somewhat larger than the
4017 base64 encoding.
4018 </para>
4019 </listitem>
4020 </varlistentry>
4022 <varlistentry id="guc-xmloption" xreflabel="xmloption">
4023 <term><varname>xmloption</varname> (<type>enum</type>)</term>
4024 <indexterm>
4025 <primary><varname>xmloption</> configuration parameter</primary>
4026 </indexterm>
4027 <indexterm>
4028 <primary><varname>SET XML OPTION</></primary>
4029 </indexterm>
4030 <indexterm>
4031 <primary>XML option</primary>
4032 </indexterm>
4033 <listitem>
4034 <para>
4035 Sets whether <literal>DOCUMENT</literal> or
4036 <literal>CONTENT</literal> is implicit when converting between
4037 XML and character string values. See <xref
4038 linkend="datatype-xml"> for a description of this. Valid
4039 values are <literal>DOCUMENT</literal> and
4040 <literal>CONTENT</literal>. The default is
4041 <literal>CONTENT</literal>.
4042 </para>
4044 <para>
4045 According to the SQL standard, the command to set this option is
4046 <synopsis>
4047 SET XML OPTION { DOCUMENT | CONTENT };
4048 </synopsis>
4049 This syntax is also available in PostgreSQL.
4050 </para>
4051 </listitem>
4052 </varlistentry>
4054 </variablelist>
4055 </sect2>
4056 <sect2 id="runtime-config-client-format">
4057 <title>Locale and Formatting</title>
4059 <variablelist>
4061 <varlistentry id="guc-datestyle" xreflabel="DateStyle">
4062 <term><varname>DateStyle</varname> (<type>string</type>)</term>
4063 <indexterm>
4064 <primary><varname>DateStyle</> configuration parameter</primary>
4065 </indexterm>
4066 <listitem>
4067 <para>
4068 Sets the display format for date and time values, as well as the
4069 rules for interpreting ambiguous date input values. For
4070 historical reasons, this variable contains two independent
4071 components: the output format specification (<literal>ISO</>,
4072 <literal>Postgres</>, <literal>SQL</>, or <literal>German</>)
4073 and the input/output specification for year/month/day ordering
4074 (<literal>DMY</>, <literal>MDY</>, or <literal>YMD</>). These
4075 can be set separately or together. The keywords <literal>Euro</>
4076 and <literal>European</> are synonyms for <literal>DMY</>; the
4077 keywords <literal>US</>, <literal>NonEuro</>, and
4078 <literal>NonEuropean</> are synonyms for <literal>MDY</>. See
4079 <xref linkend="datatype-datetime"> for more information. The
4080 built-in default is <literal>ISO, MDY</>, but
4081 <application>initdb</application> will initialize the
4082 configuration file with a setting that corresponds to the
4083 behavior of the chosen <varname>lc_time</varname> locale.
4084 </para>
4085 </listitem>
4086 </varlistentry>
4088 <varlistentry id="guc-intervalstyle" xreflabel="IntervalStyle">
4089 <term><varname>IntervalStyle</varname> (<type>enum</type>)</term>
4090 <indexterm>
4091 <primary><varname>IntervalStyle</> configuration parameter</primary>
4092 </indexterm>
4093 <listitem>
4094 <para>
4095 Sets the display format for interval values.
4096 The value <literal>sql_standard</> will produce
4097 output matching <acronym>SQL</acronym> standard interval literals.
4098 The value <literal>postgres</> (which is the default) will produce
4099 output matching <productname>PostgreSQL</> releases prior to 8.4
4100 when the <xref linkend="guc-datestyle">
4101 parameter was set to <literal>ISO</>.
4102 The value <literal>postgres_verbose</> will produce output
4103 matching <productname>PostgreSQL</> releases prior to 8.4
4104 when the <varname>DateStyle</>
4105 parameter was set to non-<literal>ISO</> output.
4106 The value <literal>iso_8601</> will produce output matching the time
4107 interval <quote>format with designators</> defined in section
4108 4.4.3.2 of ISO 8601.
4109 </para>
4110 <para>
4111 The <varname>IntervalStyle</> parameter also affects the
4112 interpretation of ambiguous interval input. See
4113 <xref linkend="datatype-interval-input"> for more information.
4114 </para>
4115 </listitem>
4116 </varlistentry>
4118 <varlistentry id="guc-timezone" xreflabel="timezone">
4119 <term><varname>timezone</varname> (<type>string</type>)</term>
4120 <indexterm>
4121 <primary><varname>timezone</> configuration parameter</primary>
4122 </indexterm>
4123 <indexterm><primary>time zone</></>
4124 <listitem>
4125 <para>
4126 Sets the time zone for displaying and interpreting time stamps.
4127 The default is <literal>unknown</>, which means to use whatever
4128 the system environment specifies as the time zone. See <xref
4129 linkend="datatype-timezones"> for more
4130 information.
4131 </para>
4132 </listitem>
4133 </varlistentry>
4135 <varlistentry id="guc-timezone-abbreviations" xreflabel="timezone_abbreviations">
4136 <term><varname>timezone_abbreviations</varname> (<type>string</type>)</term>
4137 <indexterm>
4138 <primary><varname>timezone_abbreviations</> configuration parameter</primary>
4139 </indexterm>
4140 <indexterm><primary>time zone names</></>
4141 <listitem>
4142 <para>
4143 Sets the collection of time zone abbreviations that will be accepted
4144 by the server for datetime input. The default is <literal>'Default'</>,
4145 which is a collection that works in most of the world; there are
4146 also 'Australia' and 'India', and other collections can be defined
4147 for a particular installation. See <xref
4148 linkend="datetime-appendix"> for more information.
4149 </para>
4150 </listitem>
4151 </varlistentry>
4153 <varlistentry id="guc-extra-float-digits" xreflabel="extra_float_digits">
4154 <indexterm>
4155 <primary>significant digits</primary>
4156 </indexterm>
4157 <indexterm>
4158 <primary>floating-point</primary>
4159 <secondary>display</secondary>
4160 </indexterm>
4161 <indexterm>
4162 <primary><varname>extra_float_digits</> configuration parameter</primary>
4163 </indexterm>
4165 <term><varname>extra_float_digits</varname> (<type>integer</type>)</term>
4166 <listitem>
4167 <para>
4168 This parameter adjusts the number of digits displayed for
4169 floating-point values, including <type>float4</>, <type>float8</>,
4170 and geometric data types. The parameter value is added to the
4171 standard number of digits (<literal>FLT_DIG</> or <literal>DBL_DIG</>
4172 as appropriate). The value can be set as high as 2, to include
4173 partially-significant digits; this is especially useful for dumping
4174 float data that needs to be restored exactly. Or it can be set
4175 negative to suppress unwanted digits.
4176 </para>
4177 </listitem>
4178 </varlistentry>
4180 <varlistentry id="guc-client-encoding" xreflabel="client_encoding">
4181 <term><varname>client_encoding</varname> (<type>string</type>)</term>
4182 <indexterm>
4183 <primary><varname>client_encoding</> configuration parameter</primary>
4184 </indexterm>
4185 <indexterm><primary>character set</></>
4186 <listitem>
4187 <para>
4188 Sets the client-side encoding (character set).
4189 The default is to use the database encoding.
4190 </para>
4191 </listitem>
4192 </varlistentry>
4194 <varlistentry id="guc-lc-messages" xreflabel="lc_messages">
4195 <term><varname>lc_messages</varname> (<type>string</type>)</term>
4196 <indexterm>
4197 <primary><varname>lc_messages</> configuration parameter</primary>
4198 </indexterm>
4199 <listitem>
4200 <para>
4201 Sets the language in which messages are displayed. Acceptable
4202 values are system-dependent; see <xref linkend="locale"> for
4203 more information. If this variable is set to the empty string
4204 (which is the default) then the value is inherited from the
4205 execution environment of the server in a system-dependent way.
4206 </para>
4208 <para>
4209 On some systems, this locale category does not exist. Setting
4210 this variable will still work, but there will be no effect.
4211 Also, there is a chance that no translated messages for the
4212 desired language exist. In that case you will continue to see
4213 the English messages.
4214 </para>
4216 <para>
4217 Only superusers can change this setting, because it affects the
4218 messages sent to the server log as well as to the client.
4219 </para>
4220 </listitem>
4221 </varlistentry>
4223 <varlistentry id="guc-lc-monetary" xreflabel="lc_monetary">
4224 <term><varname>lc_monetary</varname> (<type>string</type>)</term>
4225 <indexterm>
4226 <primary><varname>lc_monetary</> configuration parameter</primary>
4227 </indexterm>
4228 <listitem>
4229 <para>
4230 Sets the locale to use for formatting monetary amounts, for
4231 example with the <function>to_char</function> family of
4232 functions. Acceptable values are system-dependent; see <xref
4233 linkend="locale"> for more information. If this variable is
4234 set to the empty string (which is the default) then the value
4235 is inherited from the execution environment of the server in a
4236 system-dependent way.
4237 </para>
4238 </listitem>
4239 </varlistentry>
4241 <varlistentry id="guc-lc-numeric" xreflabel="lc_numeric">
4242 <term><varname>lc_numeric</varname> (<type>string</type>)</term>
4243 <indexterm>
4244 <primary><varname>lc_numeric</> configuration parameter</primary>
4245 </indexterm>
4246 <listitem>
4247 <para>
4248 Sets the locale to use for formatting numbers, for example
4249 with the <function>to_char</function> family of
4250 functions. Acceptable values are system-dependent; see <xref
4251 linkend="locale"> for more information. If this variable is
4252 set to the empty string (which is the default) then the value
4253 is inherited from the execution environment of the server in a
4254 system-dependent way.
4255 </para>
4256 </listitem>
4257 </varlistentry>
4259 <varlistentry id="guc-lc-time" xreflabel="lc_time">
4260 <term><varname>lc_time</varname> (<type>string</type>)</term>
4261 <indexterm>
4262 <primary><varname>lc_time</> configuration parameter</primary>
4263 </indexterm>
4264 <listitem>
4265 <para>
4266 Sets the locale to use for formatting dates and times, for example
4267 with the <function>to_char</function> family of
4268 functions. Acceptable values are system-dependent; see <xref
4269 linkend="locale"> for more information. If this variable is
4270 set to the empty string (which is the default) then the value
4271 is inherited from the execution environment of the server in a
4272 system-dependent way.
4273 </para>
4274 </listitem>
4275 </varlistentry>
4277 <varlistentry id="guc-default-text-search-config" xreflabel="default_text_search_config">
4278 <term><varname>default_text_search_config</varname> (<type>string</type>)</term>
4279 <indexterm>
4280 <primary><varname>default_text_search_config</> configuration parameter</primary>
4281 </indexterm>
4282 <listitem>
4283 <para>
4284 Selects the text search configuration that is used by those variants
4285 of the text search functions that do not have an explicit argument
4286 specifying the configuration.
4287 See <xref linkend="textsearch"> for further information.
4288 The built-in default is <literal>pg_catalog.simple</>, but
4289 <application>initdb</application> will initialize the
4290 configuration file with a setting that corresponds to the
4291 chosen <varname>lc_ctype</varname> locale, if a configuration
4292 matching that locale can be identified.
4293 </para>
4294 </listitem>
4295 </varlistentry>
4297 </variablelist>
4299 </sect2>
4300 <sect2 id="runtime-config-client-other">
4301 <title>Other Defaults</title>
4303 <variablelist>
4305 <varlistentry id="guc-dynamic-library-path" xreflabel="dynamic_library_path">
4306 <term><varname>dynamic_library_path</varname> (<type>string</type>)</term>
4307 <indexterm>
4308 <primary><varname>dynamic_library_path</> configuration parameter</primary>
4309 </indexterm>
4310 <indexterm><primary>dynamic loading</></>
4311 <listitem>
4312 <para>
4313 If a dynamically loadable module needs to be opened and the
4314 file name specified in the <command>CREATE FUNCTION</command> or
4315 <command>LOAD</command> command
4316 does not have a directory component (i.e. the
4317 name does not contain a slash), the system will search this
4318 path for the required file.
4319 </para>
4321 <para>
4322 The value for <varname>dynamic_library_path</varname> has to be a
4323 list of absolute directory paths separated by colons (or semi-colons
4324 on Windows). If a list element starts
4325 with the special string <literal>$libdir</literal>, the
4326 compiled-in <productname>PostgreSQL</productname> package
4327 library directory is substituted for <literal>$libdir</literal>. This
4328 is where the modules provided by the standard
4329 <productname>PostgreSQL</productname> distribution are installed.
4330 (Use <literal>pg_config --pkglibdir</literal> to find out the name of
4331 this directory.) For example:
4332 <programlisting>
4333 dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
4334 </programlisting>
4335 or, in a Windows environment:
4336 <programlisting>
4337 dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
4338 </programlisting>
4339 </para>
4341 <para>
4342 The default value for this parameter is
4343 <literal>'$libdir'</literal>. If the value is set to an empty
4344 string, the automatic path search is turned off.
4345 </para>
4347 <para>
4348 This parameter can be changed at run time by superusers, but a
4349 setting done that way will only persist until the end of the
4350 client connection, so this method should be reserved for
4351 development purposes. The recommended way to set this parameter
4352 is in the <filename>postgresql.conf</filename> configuration
4353 file.
4354 </para>
4355 </listitem>
4356 </varlistentry>
4358 <varlistentry id="guc-gin-fuzzy-search-limit" xreflabel="gin_fuzzy_search_limit">
4359 <term><varname>gin_fuzzy_search_limit</varname> (<type>integer</type>)</term>
4360 <indexterm>
4361 <primary><varname>gin_fuzzy_search_limit</> configuration parameter</primary>
4362 </indexterm>
4363 <listitem>
4364 <para>
4365 Soft upper limit of the size of the set returned by GIN index. For more
4366 information see <xref linkend="gin-tips">.
4367 </para>
4368 </listitem>
4369 </varlistentry>
4371 <varlistentry id="guc-local-preload-libraries" xreflabel="local_preload_libraries">
4372 <term><varname>local_preload_libraries</varname> (<type>string</type>)</term>
4373 <indexterm>
4374 <primary><varname>local_preload_libraries</> configuration parameter</primary>
4375 </indexterm>
4376 <indexterm>
4377 <primary><filename>$libdir/plugins</></primary>
4378 </indexterm>
4379 <listitem>
4380 <para>
4381 This variable specifies one or more shared libraries that are
4382 to be preloaded at connection start. If more than one library
4383 is to be loaded, separate their names with commas.
4384 This parameter cannot be changed after the start of a particular
4385 session.
4386 </para>
4388 <para>
4389 Because this is not a superuser-only option, the libraries
4390 that can be loaded are restricted to those appearing in the
4391 <filename>plugins</> subdirectory of the installation's
4392 standard library directory. (It is the database administrator's
4393 responsibility to ensure that only <quote>safe</> libraries
4394 are installed there.) Entries in <varname>local_preload_libraries</>
4395 can specify this directory explicitly, for example
4396 <literal>$libdir/plugins/mylib</literal>, or just specify
4397 the library name &mdash; <literal>mylib</literal> would have
4398 the same effect as <literal>$libdir/plugins/mylib</literal>.
4399 </para>
4401 <para>
4402 There is no performance advantage to loading a library at session
4403 start rather than when it is first used. Rather, the intent of
4404 this feature is to allow debugging or performance-measurement
4405 libraries to be loaded into specific sessions without an explicit
4406 <command>LOAD</> command being given. For example, debugging could
4407 be enabled for all sessions under a given user name by setting
4408 this parameter with <command>ALTER USER SET</>.
4409 </para>
4411 <para>
4412 If a specified library is not found,
4413 the connection attempt will fail.
4414 </para>
4416 <para>
4417 Every PostgreSQL-supported library has a <quote>magic
4418 block</> that is checked to guarantee compatibility.
4419 For this reason, non-PostgreSQL libraries cannot be
4420 loaded in this way.
4421 </para>
4422 </listitem>
4423 </varlistentry>
4425 </variablelist>
4426 </sect2>
4427 </sect1>
4429 <sect1 id="runtime-config-locks">
4430 <title>Lock Management</title>
4432 <variablelist>
4434 <varlistentry id="guc-deadlock-timeout" xreflabel="deadlock_timeout">
4435 <indexterm>
4436 <primary>deadlock</primary>
4437 <secondary>timeout during</secondary>
4438 </indexterm>
4439 <indexterm>
4440 <primary>timeout</primary>
4441 <secondary>deadlock</secondary>
4442 </indexterm>
4443 <indexterm>
4444 <primary><varname>deadlock_timeout</> configuration parameter</primary>
4445 </indexterm>
4447 <term><varname>deadlock_timeout</varname> (<type>integer</type>)</term>
4448 <listitem>
4449 <para>
4450 This is the amount of time, in milliseconds, to wait on a lock
4451 before checking to see if there is a deadlock condition. The
4452 check for deadlock is relatively slow, so the server doesn't run
4453 it every time it waits for a lock. We optimistically assume
4454 that deadlocks are not common in production applications and
4455 just wait on the lock for a while before starting the check for a
4456 deadlock. Increasing this value reduces the amount of time
4457 wasted in needless deadlock checks, but slows down reporting of
4458 real deadlock errors. The default is one second (<literal>1s</>),
4459 which is probably about the smallest value you would want in
4460 practice. On a heavily loaded server you might want to raise it.
4461 Ideally the setting should exceed your typical transaction time,
4462 so as to improve the odds that a lock will be released before
4463 the waiter decides to check for deadlock.
4464 </para>
4466 <para>
4467 When <xref linkend="guc-log-lock-waits"> is set,
4468 this parameter also determines the length of time to wait before
4469 a log message is issued about the lock wait. If you are trying
4470 to investigate locking delays you might want to set a shorter than
4471 normal <varname>deadlock_timeout</varname>.
4472 </para>
4473 </listitem>
4474 </varlistentry>
4476 <varlistentry id="guc-max-locks-per-transaction" xreflabel="max_locks_per_transaction">
4477 <term><varname>max_locks_per_transaction</varname> (<type>integer</type>)</term>
4478 <indexterm>
4479 <primary><varname>max_locks_per_transaction</> configuration parameter</primary>
4480 </indexterm>
4481 <listitem>
4482 <para>
4483 The shared lock table is created to track locks on
4484 <varname>max_locks_per_transaction</varname> * (<xref
4485 linkend="guc-max-connections"> + <xref
4486 linkend="guc-max-prepared-transactions">) objects (e.g. tables);
4487 hence, no more than this many distinct objects can be locked at
4488 any one time. This parameter controls the average number of object
4489 locks allocated for each transaction; individual transactions
4490 can lock more objects as long as the locks of all transactions
4491 fit in the lock table. This is <emphasis>not</> the number of
4492 rows that can be locked; that value is unlimited. The default,
4493 64, has historically proven sufficient, but you might need to
4494 raise this value if you have clients that touch many different
4495 tables in a single transaction. This parameter can only be set at
4496 server start.
4497 </para>
4499 <para>
4500 Increasing this parameter might cause <productname>PostgreSQL</>
4501 to request more <systemitem class="osname">System V</> shared
4502 memory than your operating system's default configuration
4503 allows. See <xref linkend="sysvipc"> for information on how to
4504 adjust those parameters, if necessary.
4505 </para>
4506 </listitem>
4507 </varlistentry>
4509 </variablelist>
4510 </sect1>
4512 <sect1 id="runtime-config-compatible">
4513 <title>Version and Platform Compatibility</title>
4515 <sect2 id="runtime-config-compatible-version">
4516 <title>Previous PostgreSQL Versions</title>
4518 <variablelist>
4520 <varlistentry id="guc-add-missing-from" xreflabel="add_missing_from">
4521 <term><varname>add_missing_from</varname> (<type>boolean</type>)</term>
4522 <indexterm><primary>FROM</><secondary>missing</></>
4523 <indexterm>
4524 <primary><varname>add_missing_from</> configuration parameter</primary>
4525 </indexterm>
4526 <listitem>
4527 <para>
4528 When on, tables that are referenced by a query will be
4529 automatically added to the <literal>FROM</> clause if not
4530 already present. This behavior does not comply with the SQL
4531 standard and many people dislike it because it can mask mistakes
4532 (such as referencing a table where you should have referenced
4533 its alias). The default is <literal>off</>. This variable can be
4534 enabled for compatibility with releases of
4535 <productname>PostgreSQL</> prior to 8.1, where this behavior was
4536 allowed by default.
4537 </para>
4539 <para>
4540 Note that even when this variable is enabled, a warning
4541 message will be emitted for each implicit <literal>FROM</>
4542 entry referenced by a query. Users are encouraged to update
4543 their applications to not rely on this behavior, by adding all
4544 tables referenced by a query to the query's <literal>FROM</>
4545 clause (or its <literal>USING</> clause in the case of
4546 <command>DELETE</>).
4547 </para>
4548 </listitem>
4549 </varlistentry>
4551 <varlistentry id="guc-array-nulls" xreflabel="array_nulls">
4552 <term><varname>array_nulls</varname> (<type>boolean</type>)</term>
4553 <indexterm>
4554 <primary><varname>array_nulls</> configuration parameter</primary>
4555 </indexterm>
4556 <listitem>
4557 <para>
4558 This controls whether the array input parser recognizes
4559 unquoted <literal>NULL</> as specifying a null array element.
4560 By default, this is <literal>on</>, allowing array values containing
4561 null values to be entered. However, <productname>PostgreSQL</> versions
4562 before 8.2 did not support null values in arrays, and therefore would
4563 treat <literal>NULL</> as specifying a normal array element with
4564 the string value <quote>NULL</>. For backwards compatibility with
4565 applications that require the old behavior, this variable can be
4566 turned <literal>off</>.
4567 </para>
4569 <para>
4570 Note that it is possible to create array values containing null values
4571 even when this variable is <literal>off</>.
4572 </para>
4573 </listitem>
4574 </varlistentry>
4576 <varlistentry id="guc-backslash-quote" xreflabel="backslash_quote">
4577 <term><varname>backslash_quote</varname> (<type>enum</type>)</term>
4578 <indexterm><primary>strings</><secondary>backslash quotes</></>
4579 <indexterm>
4580 <primary><varname>backslash_quote</> configuration parameter</primary>
4581 </indexterm>
4582 <listitem>
4583 <para>
4584 This controls whether a quote mark can be represented by
4585 <literal>\'</> in a string literal. The preferred, SQL-standard way
4586 to represent a quote mark is by doubling it (<literal>''</>) but
4587 <productname>PostgreSQL</> has historically also accepted
4588 <literal>\'</>. However, use of <literal>\'</> creates security risks
4589 because in some client character set encodings, there are multibyte
4590 characters in which the last byte is numerically equivalent to ASCII
4591 <literal>\</>. If client-side code does escaping incorrectly then a
4592 SQL-injection attack is possible. This risk can be prevented by
4593 making the server reject queries in which a quote mark appears to be
4594 escaped by a backslash.
4595 The allowed values of <varname>backslash_quote</> are
4596 <literal>on</> (allow <literal>\'</> always),
4597 <literal>off</> (reject always), and
4598 <literal>safe_encoding</> (allow only if client encoding does not
4599 allow ASCII <literal>\</> within a multibyte character).
4600 <literal>safe_encoding</> is the default setting.
4601 </para>
4603 <para>
4604 Note that in a standard-conforming string literal, <literal>\</> just
4605 means <literal>\</> anyway. This parameter affects the handling of
4606 non-standard-conforming literals, including
4607 escape string syntax (<literal>E'...'</>).
4608 </para>
4609 </listitem>
4610 </varlistentry>
4612 <varlistentry id="guc-default-with-oids" xreflabel="default_with_oids">
4613 <term><varname>default_with_oids</varname> (<type>boolean</type>)</term>
4614 <indexterm>
4615 <primary><varname>default_with_oids</> configuration parameter</primary>
4616 </indexterm>
4617 <listitem>
4618 <para>
4619 This controls whether <command>CREATE TABLE</command> and
4620 <command>CREATE TABLE AS</command> include an OID column in
4621 newly-created tables, if neither <literal>WITH OIDS</literal>
4622 nor <literal>WITHOUT OIDS</literal> is specified. It also
4623 determines whether OIDs will be included in tables created by
4624 <command>SELECT INTO</command>. In <productname>PostgreSQL</>
4625 8.1 <varname>default_with_oids</> is <literal>off</> by default; in
4626 prior versions of <productname>PostgreSQL</productname>, it
4627 was on by default.
4628 </para>
4630 <para>
4631 The use of OIDs in user tables is considered deprecated, so
4632 most installations should leave this variable disabled.
4633 Applications that require OIDs for a particular table should
4634 specify <literal>WITH OIDS</literal> when creating the
4635 table. This variable can be enabled for compatibility with old
4636 applications that do not follow this behavior.
4637 </para>
4638 </listitem>
4639 </varlistentry>
4641 <varlistentry id="guc-escape-string-warning" xreflabel="escape_string_warning">
4642 <term><varname>escape_string_warning</varname> (<type>boolean</type>)</term>
4643 <indexterm><primary>strings</><secondary>escape warning</></>
4644 <indexterm>
4645 <primary><varname>escape_string_warning</> configuration parameter</primary>
4646 </indexterm>
4647 <listitem>
4648 <para>
4649 When on, a warning is issued if a backslash (<literal>\</>)
4650 appears in an ordinary string literal (<literal>'...'</>
4651 syntax) and <varname>standard_conforming_strings</varname> is off.
4652 The default is <literal>on</>.
4653 </para>
4654 <para>
4655 Applications that wish to use backslash as escape should be
4656 modified to use escape string syntax (<literal>E'...'</>),
4657 because the default behavior of ordinary strings will change
4658 in a future release for SQL compatibility. This variable can
4659 be enabled to help detect applications that will break.
4660 </para>
4661 </listitem>
4662 </varlistentry>
4664 <varlistentry id="guc-regex-flavor" xreflabel="regex_flavor">
4665 <term><varname>regex_flavor</varname> (<type>enum</type>)</term>
4666 <indexterm><primary>regular expressions</></>
4667 <indexterm>
4668 <primary><varname>regex_flavor</> configuration parameter</primary>
4669 </indexterm>
4670 <listitem>
4671 <para>
4672 The regular expression <quote>flavor</> can be set to
4673 <literal>advanced</>, <literal>extended</>, or <literal>basic</>.
4674 The default is <literal>advanced</>. The <literal>extended</>
4675 setting might be useful for exact backwards compatibility with
4676 pre-7.4 releases of <productname>PostgreSQL</>. See
4677 <xref linkend="posix-syntax-details"> for details.
4678 </para>
4679 </listitem>
4680 </varlistentry>
4682 <varlistentry id="guc-sql-inheritance" xreflabel="sql_inheritance">
4683 <term><varname>sql_inheritance</varname> (<type>boolean</type>)</term>
4684 <indexterm>
4685 <primary><varname>sql_inheritance</> configuration parameter</primary>
4686 </indexterm>
4687 <indexterm><primary>inheritance</></>
4688 <listitem>
4689 <para>
4690 This controls the inheritance semantics. If turned <literal>off</>,
4691 subtables are not included by various commands by default; basically
4692 an implied <literal>ONLY</literal> key word. This was added for
4693 compatibility with releases prior to 7.1. See
4694 <xref linkend="ddl-inherit"> for more information.
4695 </para>
4696 </listitem>
4697 </varlistentry>
4699 <varlistentry id="guc-standard-conforming-strings" xreflabel="standard_conforming_strings">
4700 <term><varname>standard_conforming_strings</varname> (<type>boolean</type>)</term>
4701 <indexterm><primary>strings</><secondary>standard conforming</></>
4702 <indexterm>
4703 <primary><varname>standard_conforming_strings</> configuration parameter</primary>
4704 </indexterm>
4705 <listitem>
4706 <para>
4707 This controls whether ordinary string literals
4708 (<literal>'...'</>) treat backslashes literally, as specified in
4709 the SQL standard.
4710 The default is currently <literal>off</>, causing
4711 <productname>PostgreSQL</productname> to have its historical
4712 behavior of treating backslashes as escape characters.
4713 The default will change to <literal>on</> in a future release
4714 to improve compatibility with the standard.
4715 Applications can check this
4716 parameter to determine how string literals will be processed.
4717 The presence of this parameter can also be taken as an indication
4718 that the escape string syntax (<literal>E'...'</>) is supported.
4719 Escape string syntax should be used if an application desires
4720 backslashes to be treated as escape characters.
4721 </para>
4722 </listitem>
4723 </varlistentry>
4725 <varlistentry id="guc-synchronize-seqscans" xreflabel="synchronize_seqscans">
4726 <term><varname>synchronize_seqscans</varname> (<type>boolean</type>)</term>
4727 <indexterm>
4728 <primary><varname>synchronize_seqscans</> configuration parameter</primary>
4729 </indexterm>
4730 <listitem>
4731 <para>
4732 This allows sequential scans of large tables to synchronize with each
4733 other, so that concurrent scans read the same block at about the
4734 same time and hence share the I/O workload. When this is enabled,
4735 a scan might start in the middle of the table and then <quote>wrap
4736 around</> the end to cover all rows, so as to synchronize with the
4737 activity of scans already in progress. This can result in
4738 unpredictable changes in the row ordering returned by queries that
4739 have no <literal>ORDER BY</> clause. Setting this parameter to
4740 <literal>off</> ensures the pre-8.3 behavior in which a sequential
4741 scan always starts from the beginning of the table. The default
4742 is <literal>on</>.
4743 </para>
4744 </listitem>
4745 </varlistentry>
4747 </variablelist>
4748 </sect2>
4750 <sect2 id="runtime-config-compatible-clients">
4751 <title>Platform and Client Compatibility</title>
4752 <variablelist>
4754 <varlistentry id="guc-transform-null-equals" xreflabel="transform_null_equals">
4755 <term><varname>transform_null_equals</varname> (<type>boolean</type>)</term>
4756 <indexterm><primary>IS NULL</></>
4757 <indexterm>
4758 <primary><varname>transform_null_equals</> configuration parameter</primary>
4759 </indexterm>
4760 <listitem>
4761 <para>
4762 When on, expressions of the form <literal><replaceable>expr</> =
4763 NULL</literal> (or <literal>NULL =
4764 <replaceable>expr</></literal>) are treated as
4765 <literal><replaceable>expr</> IS NULL</literal>, that is, they
4766 return true if <replaceable>expr</> evaluates to the null value,
4767 and false otherwise. The correct SQL-spec-compliant behavior of
4768 <literal><replaceable>expr</> = NULL</literal> is to always
4769 return null (unknown). Therefore this parameter defaults to
4770 <literal>off</>.
4771 </para>
4773 <para>
4774 However, filtered forms in <productname>Microsoft
4775 Access</productname> generate queries that appear to use
4776 <literal><replaceable>expr</> = NULL</literal> to test for
4777 null values, so if you use that interface to access the database you
4778 might want to turn this option on. Since expressions of the
4779 form <literal><replaceable>expr</> = NULL</literal> always
4780 return the null value (using the correct interpretation) they are not
4781 very useful and do not appear often in normal applications, so
4782 this option does little harm in practice. But new users are
4783 frequently confused about the semantics of expressions
4784 involving null values, so this option is not on by default.
4785 </para>
4787 <para>
4788 Note that this option only affects the exact form <literal>= NULL</>,
4789 not other comparison operators or other expressions
4790 that are computationally equivalent to some expression
4791 involving the equals operator (such as <literal>IN</literal>).
4792 Thus, this option is not a general fix for bad programming.
4793 </para>
4795 <para>
4796 Refer to <xref linkend="functions-comparison"> for related information.
4797 </para>
4798 </listitem>
4799 </varlistentry>
4801 </variablelist>
4802 </sect2>
4803 </sect1>
4805 <sect1 id="runtime-config-preset">
4806 <title>Preset Options</title>
4808 <para>
4809 The following <quote>parameters</> are read-only, and are determined
4810 when <productname>PostgreSQL</productname> is compiled or when it is
4811 installed. As such, they have been excluded from the sample
4812 <filename>postgresql.conf</> file. These options report
4813 various aspects of <productname>PostgreSQL</productname> behavior
4814 that might be of interest to certain applications, particularly
4815 administrative front-ends.
4816 </para>
4818 <variablelist>
4820 <varlistentry id="guc-block-size" xreflabel="block_size">
4821 <term><varname>block_size</varname> (<type>integer</type>)</term>
4822 <indexterm>
4823 <primary><varname>block_size</> configuration parameter</primary>
4824 </indexterm>
4825 <listitem>
4826 <para>
4827 Reports the size of a disk block. It is determined by the value
4828 of <literal>BLCKSZ</> when building the server. The default
4829 value is 8192 bytes. The meaning of some configuration
4830 variables (such as <xref linkend="guc-shared-buffers">) is
4831 influenced by <varname>block_size</varname>. See <xref
4832 linkend="runtime-config-resource"> for information.
4833 </para>
4834 </listitem>
4835 </varlistentry>
4837 <varlistentry id="guc-integer-datetimes" xreflabel="integer_datetimes">
4838 <term><varname>integer_datetimes</varname> (<type>boolean</type>)</term>
4839 <indexterm>
4840 <primary><varname>integer_datetimes</> configuration parameter</primary>
4841 </indexterm>
4842 <listitem>
4843 <para>
4844 Reports whether <productname>PostgreSQL</> was built with
4845 support for 64-bit-integer dates and times. This can be
4846 disabled by configuring with <literal>--disable-integer-datetimes</>
4847 when building <productname>PostgreSQL</>. The default value is
4848 <literal>on</literal>.
4849 </para>
4850 </listitem>
4851 </varlistentry>
4853 <varlistentry id="guc-lc-collate" xreflabel="lc_collate">
4854 <term><varname>lc_collate</varname> (<type>string</type>)</term>
4855 <indexterm>
4856 <primary><varname>lc_collate</> configuration parameter</primary>
4857 </indexterm>
4858 <listitem>
4859 <para>
4860 Reports the locale in which sorting of textual data is done.
4861 See <xref linkend="locale"> for more information.
4862 The value is determined when the database cluster is initialized.
4863 </para>
4864 </listitem>
4865 </varlistentry>
4867 <varlistentry id="guc-lc-ctype" xreflabel="lc_ctype">
4868 <term><varname>lc_ctype</varname> (<type>string</type>)</term>
4869 <indexterm>
4870 <primary><varname>lc_ctype</> configuration parameter</primary>
4871 </indexterm>
4872 <listitem>
4873 <para>
4874 Reports the locale that determines character classifications.
4875 See <xref linkend="locale"> for more information.
4876 The value is determined when the database cluster is initialized.
4877 Ordinarily this will be the same as <varname>lc_collate</varname>,
4878 but for special applications it might be set differently.
4879 </para>
4880 </listitem>
4881 </varlistentry>
4883 <varlistentry id="guc-max-function-args" xreflabel="max_function_args">
4884 <term><varname>max_function_args</varname> (<type>integer</type>)</term>
4885 <indexterm>
4886 <primary><varname>max_function_args</> configuration parameter</primary>
4887 </indexterm>
4888 <listitem>
4889 <para>
4890 Reports the maximum number of function arguments. It is determined by
4891 the value of <literal>FUNC_MAX_ARGS</> when building the server. The
4892 default value is 100 arguments.
4893 </para>
4894 </listitem>
4895 </varlistentry>
4897 <varlistentry id="guc-max-identifier-length" xreflabel="max_identifier_length">
4898 <term><varname>max_identifier_length</varname> (<type>integer</type>)</term>
4899 <indexterm>
4900 <primary><varname>max_identifier_length</> configuration parameter</primary>
4901 </indexterm>
4902 <listitem>
4903 <para>
4904 Reports the maximum identifier length. It is determined as one
4905 less than the value of <literal>NAMEDATALEN</> when building
4906 the server. The default value of <literal>NAMEDATALEN</> is
4907 64; therefore the default
4908 <varname>max_identifier_length</varname> is 63 bytes.
4909 </para>
4910 </listitem>
4911 </varlistentry>
4913 <varlistentry id="guc-max-index-keys" xreflabel="max_index_keys">
4914 <term><varname>max_index_keys</varname> (<type>integer</type>)</term>
4915 <indexterm>
4916 <primary><varname>max_index_keys</> configuration parameter</primary>
4917 </indexterm>
4918 <listitem>
4919 <para>
4920 Reports the maximum number of index keys. It is determined by
4921 the value of <literal>INDEX_MAX_KEYS</> when building the server. The
4922 default value is 32 keys.
4923 </para>
4924 </listitem>
4925 </varlistentry>
4927 <varlistentry id="guc-segment-size" xreflabel="segment_size">
4928 <term><varname>segment_size</varname> (<type>integer</type>)</term>
4929 <indexterm>
4930 <primary><varname>segment_size</> configuration parameter</primary>
4931 </indexterm>
4932 <listitem>
4933 <para>
4934 Reports the number of blocks (pages) that can be stored within a file
4935 segment. It is determined by the value of <literal>RELSEG_SIZE</>
4936 when building the server. The maximum size of a segment file in bytes
4937 is equal to <varname>segment_size</> multiplied by
4938 <varname>block_size</>; by default this is 1GB.
4939 </para>
4940 </listitem>
4941 </varlistentry>
4943 <varlistentry id="guc-server-encoding" xreflabel="server_encoding">
4944 <term><varname>server_encoding</varname> (<type>string</type>)</term>
4945 <indexterm>
4946 <primary><varname>server_encoding</> configuration parameter</primary>
4947 </indexterm>
4948 <indexterm><primary>character set</></>
4949 <listitem>
4950 <para>
4951 Reports the database encoding (character set).
4952 It is determined when the database is created. Ordinarily,
4953 clients need only be concerned with the value of <xref
4954 linkend="guc-client-encoding">.
4955 </para>
4956 </listitem>
4957 </varlistentry>
4959 <varlistentry id="guc-server-version" xreflabel="server_version">
4960 <term><varname>server_version</varname> (<type>string</type>)</term>
4961 <indexterm>
4962 <primary><varname>server_version</> configuration parameter</primary>
4963 </indexterm>
4964 <listitem>
4965 <para>
4966 Reports the version number of the server. It is determined by the
4967 value of <literal>PG_VERSION</> when building the server.
4968 </para>
4969 </listitem>
4970 </varlistentry>
4972 <varlistentry id="guc-server-version-num" xreflabel="server_version_num">
4973 <term><varname>server_version_num</varname> (<type>integer</type>)</term>
4974 <indexterm>
4975 <primary><varname>server_version_num</> configuration parameter</primary>
4976 </indexterm>
4977 <listitem>
4978 <para>
4979 Reports the version number of the server as an integer. It is determined
4980 by the value of <literal>PG_VERSION_NUM</> when building the server.
4981 </para>
4982 </listitem>
4983 </varlistentry>
4985 <varlistentry id="guc-wal-block-size" xreflabel="wal_block_size">
4986 <term><varname>wal_block_size</varname> (<type>integer</type>)</term>
4987 <indexterm>
4988 <primary><varname>wal_block_size</> configuration parameter</primary>
4989 </indexterm>
4990 <listitem>
4991 <para>
4992 Reports the size of a WAL disk block. It is determined by the value
4993 of <literal>XLOG_BLCKSZ</> when building the server. The default value
4994 is 8192 bytes.
4995 </para>
4996 </listitem>
4997 </varlistentry>
4999 <varlistentry id="guc-wal-segment-size" xreflabel="wal_segment_size">
5000 <term><varname>wal_segment_size</varname> (<type>integer</type>)</term>
5001 <indexterm>
5002 <primary><varname>wal_segment_size</> configuration parameter</primary>
5003 </indexterm>
5004 <listitem>
5005 <para>
5006 Reports the number of blocks (pages) in a WAL segment file.
5007 The total size of a WAL segment file in bytes is equal to
5008 <varname>wal_segment_size</> multiplied by <varname>wal_block_size</>;
5009 by default this is 16MB. See <xref linkend="wal-configuration"> for
5010 more information.
5011 </para>
5012 </listitem>
5013 </varlistentry>
5015 </variablelist>
5016 </sect1>
5018 <sect1 id="runtime-config-custom">
5019 <title>Customized Options</title>
5021 <para>
5022 This feature was designed to allow parameters not normally known to
5023 <productname>PostgreSQL</productname> to be added by add-on modules
5024 (such as procedural languages). This allows add-on modules to be
5025 configured in the standard ways.
5026 </para>
5028 <variablelist>
5030 <varlistentry id="guc-custom-variable-classes" xreflabel="custom_variable_classes">
5031 <term><varname>custom_variable_classes</varname> (<type>string</type>)</term>
5032 <indexterm>
5033 <primary><varname>custom_variable_classes</> configuration parameter</primary>
5034 </indexterm>
5035 <listitem>
5036 <para>
5037 This variable specifies one or several class names to be used for
5038 custom variables, in the form of a comma-separated list. A custom
5039 variable is a variable not normally known
5040 to <productname>PostgreSQL</productname> proper but used by some
5041 add-on module. Such variables must have names consisting of a class
5042 name, a dot, and a variable name. <varname>custom_variable_classes</>
5043 specifies all the class names in use in a particular installation.
5044 This parameter can only be set in the <filename>postgresql.conf</>
5045 file or on the server command line.
5046 </para>
5048 </listitem>
5049 </varlistentry>
5050 </variablelist>
5052 <para>
5053 The difficulty with setting custom variables in
5054 <filename>postgresql.conf</> is that the file must be read before add-on
5055 modules have been loaded, and so custom variables would ordinarily be
5056 rejected as unknown. When <varname>custom_variable_classes</> is set,
5057 the server will accept definitions of arbitrary variables within each
5058 specified class. These variables will be treated as placeholders and
5059 will have no function until the module that defines them is loaded. When a
5060 module for a specific class is loaded, it will add the proper variable
5061 definitions for its class name, convert any placeholder
5062 values according to those definitions, and issue warnings for any
5063 placeholders of its class that remain (which presumably would be
5064 misspelled configuration variables).
5065 </para>
5067 <para>
5068 Here is an example of what <filename>postgresql.conf</> might contain
5069 when using custom variables:
5071 <programlisting>
5072 custom_variable_classes = 'plr,plperl'
5073 plr.path = '/usr/lib/R'
5074 plperl.use_strict = true
5075 plruby.use_strict = true # generates error: unknown class name
5076 </programlisting>
5077 </para>
5078 </sect1>
5080 <sect1 id="runtime-config-developer">
5081 <title>Developer Options</title>
5083 <para>
5084 The following parameters are intended for work on the
5085 <productname>PostgreSQL</productname> source, and in some cases
5086 to assist with recovery of severely damaged databases. There
5087 should be no reason to use them in a production database setup.
5088 As such, they have been excluded from the sample
5089 <filename>postgresql.conf</> file. Note that many of these
5090 parameters require special source compilation flags to work at all.
5091 </para>
5093 <variablelist>
5094 <varlistentry id="guc-allow-system-table-mods" xreflabel="allow_system_table_mods">
5095 <term><varname>allow_system_table_mods</varname> (<type>boolean</type>)</term>
5096 <indexterm>
5097 <primary><varname>allow_system_table_mods</varname> configuration parameter</primary>
5098 </indexterm>
5099 <listitem>
5100 <para>
5101 Allows modification of the structure of system tables.
5102 This is used by <command>initdb</command>.
5103 This parameter can only be set at server start.
5104 </para>
5105 </listitem>
5106 </varlistentry>
5108 <varlistentry id="guc-debug-assertions" xreflabel="debug_assertions">
5109 <term><varname>debug_assertions</varname> (<type>boolean</type>)</term>
5110 <indexterm>
5111 <primary><varname>debug_assertions</> configuration parameter</primary>
5112 </indexterm>
5113 <listitem>
5114 <para>
5115 Turns on various assertion checks. This is a debugging aid. If
5116 you are experiencing strange problems or crashes you might want
5117 to turn this on, as it might expose programming mistakes. To use
5118 this parameter, the macro <symbol>USE_ASSERT_CHECKING</symbol>
5119 must be defined when <productname>PostgreSQL</productname> is
5120 built (accomplished by the <command>configure</command> option
5121 <option>--enable-cassert</option>). Note that
5122 <varname>debug_assertions</varname> defaults to <literal>on</>
5123 if <productname>PostgreSQL</productname> has been built with
5124 assertions enabled.
5125 </para>
5126 </listitem>
5127 </varlistentry>
5129 <varlistentry id="guc-ignore-system-indexes" xreflabel="ignore_system_indexes">
5130 <term><varname>ignore_system_indexes</varname> (<type>boolean</type>)</term>
5131 <indexterm>
5132 <primary><varname>ignore_system_indexes</varname> configuration parameter</primary>
5133 </indexterm>
5134 <listitem>
5135 <para>
5136 Ignore system indexes when reading system tables (but still
5137 update the indexes when modifying the tables). This is useful
5138 when recovering from damaged system indexes.
5139 This parameter cannot be changed after session start.
5140 </para>
5141 </listitem>
5142 </varlistentry>
5144 <varlistentry id="guc-post-auth-delay" xreflabel="post_auth_delay">
5145 <term><varname>post_auth_delay</varname> (<type>integer</type>)</term>
5146 <indexterm>
5147 <primary><varname>post_auth_delay</> configuration parameter</primary>
5148 </indexterm>
5149 <listitem>
5150 <para>
5151 If nonzero, a delay of this many seconds occurs when a new
5152 server process is started, after it conducts the
5153 authentication procedure. This is intended to give an
5154 opportunity to attach to the server process with a debugger.
5155 This parameter cannot be changed after session start.
5156 </para>
5157 </listitem>
5158 </varlistentry>
5160 <varlistentry id="guc-pre-auth-delay" xreflabel="pre_auth_delay">
5161 <term><varname>pre_auth_delay</varname> (<type>integer</type>)</term>
5162 <indexterm>
5163 <primary><varname>pre_auth_delay</> configuration parameter</primary>
5164 </indexterm>
5165 <listitem>
5166 <para>
5167 If nonzero, a delay of this many seconds occurs just after a
5168 new server process is forked, before it conducts the
5169 authentication procedure. This is intended to give an
5170 opportunity to attach to the server process with a debugger to
5171 trace down misbehavior in authentication.
5172 This parameter can only be set in the <filename>postgresql.conf</>
5173 file or on the server command line.
5174 </para>
5175 </listitem>
5176 </varlistentry>
5178 <varlistentry id="guc-trace-notify" xreflabel="trace_notify">
5179 <term><varname>trace_notify</varname> (<type>boolean</type>)</term>
5180 <indexterm>
5181 <primary><varname>trace_notify</> configuration parameter</primary>
5182 </indexterm>
5183 <listitem>
5184 <para>
5185 Generates a great amount of debugging output for the
5186 <command>LISTEN</command> and <command>NOTIFY</command>
5187 commands. <xref linkend="guc-client-min-messages"> or
5188 <xref linkend="guc-log-min-messages"> must be
5189 <literal>DEBUG1</literal> or lower to send this output to the
5190 client or server log, respectively.
5191 </para>
5192 </listitem>
5193 </varlistentry>
5195 <varlistentry id="guc-trace-sort" xreflabel="trace_sort">
5196 <term><varname>trace_sort</varname> (<type>boolean</type>)</term>
5197 <indexterm>
5198 <primary><varname>trace_sort</> configuration parameter</primary>
5199 </indexterm>
5200 <listitem>
5201 <para>
5202 If on, emit information about resource usage during sort operations.
5203 This parameter is only available if the <symbol>TRACE_SORT</symbol> macro
5204 was defined when <productname>PostgreSQL</productname> was compiled.
5205 (However, <symbol>TRACE_SORT</symbol> is currently defined by default.)
5206 </para>
5207 </listitem>
5208 </varlistentry>
5210 <varlistentry>
5211 <term><varname>trace_locks</varname> (<type>boolean</type>)</term>
5212 <indexterm>
5213 <primary><varname>trace_locks</> configuration parameter</primary>
5214 </indexterm>
5215 <listitem>
5216 <para>
5217 If on, emit information about lock usage. Information dumped
5218 includes the type of lock operation, the type of lock and the unique
5219 identifier of the object being locked or unlocked. Also included
5220 are bitmasks for the lock types already granted on this object as
5221 well as for the lock types awaited on this object. For each lock
5222 type a count of the number of granted locks and waiting locks is
5223 also dumped as well as the totals. An example of the log file output
5224 is shown here:
5225 </para>
5226 <para>
5227 LOG: LockAcquire: new: lock(0xb7acd844) id(24688,24696,0,0,0,1)
5228 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
5229 wait(0) type(AccessShareLock)
5230 </para>
5231 <para>
5232 LOG: GrantLock: lock(0xb7acd844) id(24688,24696,0,0,0,1)
5233 grantMask(2) req(1,0,0,0,0,0,0)=1 grant(1,0,0,0,0,0,0)=1
5234 wait(0) type(AccessShareLock)
5236 </para>
5237 <para>
5238 LOG: UnGrantLock: updated: lock(0xb7acd844) id(24688,24696,0,0,0,1)
5239 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
5240 wait(0) type(AccessShareLock)
5241 </para>
5242 <para>
5243 LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
5244 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
5245 wait(0) type(INVALID)
5246 </para>
5247 <para>
5248 Details of the structure being dumped may be found in
5249 src/include/storage/lock.h
5250 </para>
5251 <para>
5252 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5253 macro was defined when <productname>PostgreSQL</productname> was
5254 compiled.
5255 </para>
5256 </listitem>
5257 </varlistentry>
5259 <varlistentry>
5260 <term><varname>trace_lwlocks</varname> (<type>boolean</type>)</term>
5261 <indexterm>
5262 <primary><varname>trace_lwlocks</> configuration parameter</primary>
5263 </indexterm>
5264 <listitem>
5265 <para>
5266 If on, emit information about lightweight lock usage. Lightweight
5267 locks are intended primarily to provide mutual exclusion of access
5268 to shared-memory data structures.
5269 </para>
5270 <para>
5271 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5272 macro was defined when <productname>PostgreSQL</productname> was
5273 compiled.
5274 </para>
5275 </listitem>
5276 </varlistentry>
5278 <varlistentry>
5279 <term><varname>trace_userlocks</varname> (<type>boolean</type>)</term>
5280 <indexterm>
5281 <primary><varname>trace_userlocks</> configuration parameter</primary>
5282 </indexterm>
5283 <listitem>
5284 <para>
5285 If on, emit information about user lock usage. Output is the same
5286 as for <symbol>trace_locks</symbol>, only for user locks.
5287 </para>
5288 <para>
5289 User locks were removed as of PostgreSQL version 8.2. This option
5290 currently has no effect.
5291 </para>
5292 <para>
5293 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5294 macro was defined when <productname>PostgreSQL</productname> was
5295 compiled.
5296 </para>
5297 </listitem>
5298 </varlistentry>
5300 <varlistentry>
5301 <term><varname>trace_lock_oidmin</varname> (<type>integer</type>)</term>
5302 <indexterm>
5303 <primary><varname>trace_lock_oidmin</> configuration parameter</primary>
5304 </indexterm>
5305 <listitem>
5306 <para>
5307 If set, do not trace locks for tables below this OID. (use to avoid
5308 output on system tables)
5309 </para>
5310 <para>
5311 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5312 macro was defined when <productname>PostgreSQL</productname> was
5313 compiled.
5314 </para>
5315 </listitem>
5316 </varlistentry>
5318 <varlistentry>
5319 <term><varname>trace_lock_table</varname> (<type>integer</type>)</term>
5320 <indexterm>
5321 <primary><varname>trace_lock_table</> configuration parameter</primary>
5322 </indexterm>
5323 <listitem>
5324 <para>
5325 Unconditionally trace locks on this table (OID).
5326 </para>
5327 <para>
5328 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5329 macro was defined when <productname>PostgreSQL</productname> was
5330 compiled.
5331 </para>
5332 </listitem>
5333 </varlistentry>
5335 <varlistentry>
5336 <term><varname>debug_deadlocks</varname> (<type>boolean</type>)</term>
5337 <indexterm>
5338 <primary><varname>debug_deadlocks</> configuration parameter</primary>
5339 </indexterm>
5340 <listitem>
5341 <para>
5342 If set, dumps information about all current locks when a
5343 DeadLockTimeout occurs.
5344 </para>
5345 <para>
5346 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
5347 macro was defined when <productname>PostgreSQL</productname> was
5348 compiled.
5349 </para>
5350 </listitem>
5351 </varlistentry>
5353 <varlistentry>
5354 <term><varname>log_btree_build_stats</varname> (<type>boolean</type>)</term>
5355 <indexterm>
5356 <primary><varname>log_btree_build_stats</> configuration parameter</primary>
5357 </indexterm>
5358 <listitem>
5359 <para>
5360 If set, logs system resource usage statistics (memory and CPU) on
5361 various btree operations.
5362 </para>
5363 <para>
5364 This parameter is only available if the <symbol>BTREE_BUILD_STATS</symbol>
5365 macro was defined when <productname>PostgreSQL</productname> was
5366 compiled.
5367 </para>
5368 </listitem>
5369 </varlistentry>
5371 <varlistentry id="guc-wal-debug" xreflabel="wal_debug">
5372 <term><varname>wal_debug</varname> (<type>boolean</type>)</term>
5373 <indexterm>
5374 <primary><varname>wal_debug</> configuration parameter</primary>
5375 </indexterm>
5376 <listitem>
5377 <para>
5378 If on, emit WAL-related debugging output. This parameter is
5379 only available if the <symbol>WAL_DEBUG</symbol> macro was
5380 defined when <productname>PostgreSQL</productname> was
5381 compiled.
5382 </para>
5383 </listitem>
5384 </varlistentry>
5386 <varlistentry id="guc-zero-damaged-pages" xreflabel="zero_damaged_pages">
5387 <term><varname>zero_damaged_pages</varname> (<type>boolean</type>)</term>
5388 <indexterm>
5389 <primary><varname>zero_damaged_pages</> configuration parameter</primary>
5390 </indexterm>
5391 <listitem>
5392 <para>
5393 Detection of a damaged page header normally causes
5394 <productname>PostgreSQL</> to report an error, aborting the current
5395 command. Setting <varname>zero_damaged_pages</> to on causes
5396 the system to instead report a warning, zero out the damaged page,
5397 and continue processing. This behavior <emphasis>will destroy data</>,
5398 namely all the rows on the damaged page. But it allows you to get
5399 past the error and retrieve rows from any undamaged pages that might
5400 be present in the table. So it is useful for recovering data if
5401 corruption has occurred due to hardware or software error. You should
5402 generally not set this on until you have given up hope of recovering
5403 data from the damaged page(s) of a table. The
5404 default setting is <literal>off</>, and it can only be changed
5405 by a superuser.
5406 </para>
5407 </listitem>
5408 </varlistentry>
5409 </variablelist>
5410 </sect1>
5411 <sect1 id="runtime-config-short">
5412 <title>Short Options</title>
5414 <para>
5415 For convenience there are also single letter command-line option
5416 switches available for some parameters. They are described in
5417 <xref linkend="runtime-config-short-table">. Some of these
5418 options exist for historical reasons, and their presence as a
5419 single-letter option does not necessarily indicate an endorsement
5420 to use the option heavily.
5421 </para>
5423 <table id="runtime-config-short-table">
5424 <title>Short option key</title>
5425 <tgroup cols="2">
5426 <thead>
5427 <row>
5428 <entry>Short option</entry>
5429 <entry>Equivalent</entry>
5430 </row>
5431 </thead>
5433 <tbody>
5434 <row>
5435 <entry><option>-A <replaceable>x</replaceable></option></entry>
5436 <entry><literal>debug_assertions = <replaceable>x</replaceable></></entry>
5437 </row>
5438 <row>
5439 <entry><option>-B <replaceable>x</replaceable></option></entry>
5440 <entry><literal>shared_buffers = <replaceable>x</replaceable></></entry>
5441 </row>
5442 <row>
5443 <entry><option>-d <replaceable>x</replaceable></option></entry>
5444 <entry><literal>log_min_messages = DEBUG<replaceable>x</replaceable></></entry>
5445 </row>
5446 <row>
5447 <entry><option>-e</option></entry>
5448 <entry><literal>datestyle = euro</></entry>
5449 </row>
5450 <row>
5451 <entry>
5452 <option>-fb</option>, <option>-fh</option>, <option>-fi</option>,
5453 <option>-fm</option>, <option>-fn</option>,
5454 <option>-fs</option>, <option>-ft</option>
5455 </entry>
5456 <entry>
5457 <literal>enable_bitmapscan = off</>,
5458 <literal>enable_hashjoin = off</>,
5459 <literal>enable_indexscan = off</>,
5460 <literal>enable_mergejoin = off</>,
5461 <literal>enable_nestloop = off</>,
5462 <literal>enable_seqscan = off</>,
5463 <literal>enable_tidscan = off</>
5464 </entry>
5465 </row>
5466 <row>
5467 <entry><option>-F</option></entry>
5468 <entry><literal>fsync = off</></entry>
5469 </row>
5470 <row>
5471 <entry><option>-h <replaceable>x</replaceable></option></entry>
5472 <entry><literal>listen_addresses = <replaceable>x</replaceable></></entry>
5473 </row>
5474 <row>
5475 <entry><option>-i</option></entry>
5476 <entry><literal>listen_addresses = '*'</></entry>
5477 </row>
5478 <row>
5479 <entry><option>-k <replaceable>x</replaceable></option></entry>
5480 <entry><literal>unix_socket_directory = <replaceable>x</replaceable></></entry>
5481 </row>
5482 <row>
5483 <entry><option>-l</option></entry>
5484 <entry><literal>ssl = on</></entry>
5485 </row>
5486 <row>
5487 <entry><option>-N <replaceable>x</replaceable></option></entry>
5488 <entry><literal>max_connections = <replaceable>x</replaceable></></entry>
5489 </row>
5490 <row>
5491 <entry><option>-O</option></entry>
5492 <entry><literal>allow_system_table_mods = on</></entry>
5493 </row>
5494 <row>
5495 <entry><option>-p <replaceable>x</replaceable></option></entry>
5496 <entry><literal>port = <replaceable>x</replaceable></></entry>
5497 </row>
5498 <row>
5499 <entry><option>-P</option></entry>
5500 <entry><literal>ignore_system_indexes = on</></entry>
5501 </row>
5502 <row>
5503 <entry><option>-s</option></entry>
5504 <entry><literal>log_statement_stats = on</></entry>
5505 </row>
5506 <row>
5507 <entry><option>-S <replaceable>x</replaceable></option></entry>
5508 <entry><literal>work_mem = <replaceable>x</replaceable></></entry>
5509 </row>
5510 <row>
5511 <entry><option>-tpa</option>, <option>-tpl</option>, <option>-te</option></entry>
5512 <entry><literal>log_parser_stats = on</>,
5513 <literal>log_planner_stats = on</>,
5514 <literal>log_executor_stats = on</></entry>
5515 </row>
5516 <row>
5517 <entry><option>-W <replaceable>x</replaceable></option></entry>
5518 <entry><literal>post_auth_delay = <replaceable>x</replaceable></></entry>
5519 </row>
5520 </tbody>
5521 </tgroup>
5522 </table>
5524 </sect1>
5525 </chapter>