1 <!-- doc/src/sgml/config.sgml -->
3 <chapter id="runtime-config">
4 <title>Server Configuration</title>
7 <primary>configuration</primary>
8 <secondary>of the server</secondary>
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.
18 <sect1 id="config-setting">
19 <title>Setting Parameters</title>
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.
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</>.
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.
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
50 from <structname>pg_settings</>.<structfield>enumvals</>.
51 Enum parameter values are case-insensitive.
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. (A default copy is
58 installed there when the database cluster directory is
59 initialized.) An example of what this file might look like is:
63 log_destination = 'syslog'
64 search_path = '"$user", public'
65 shared_buffers = 128MB
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>) designate the rest of the
70 line as a comment. 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.
77 <primary><literal>include</></primary>
78 <secondary>in configuration file</secondary>
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:
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.
94 <primary><literal>include_if_exists</></primary>
95 <secondary>in configuration file</secondary>
97 Use the same approach as the <literal>include</> directive, continuing
98 normally if the file does not exist. A regular <literal>include</>
99 will stop with an error if the referenced file is missing, while
100 <literal>include_if_exists</> does not. A warning about the missing
106 <primary>SIGHUP</primary>
108 The configuration file is reread whenever the main server process receives a
109 <systemitem>SIGHUP</> signal (which is most easily sent by means
110 of <literal>pg_ctl reload</>). The main server process
111 also propagates this signal to all currently running server
112 processes so that existing sessions also get the new
113 value. Alternatively, you can send the signal to a single server
114 process directly. Some parameters can only be set at server start;
115 any changes to their entries in the configuration file will be ignored
116 until the server is restarted. Invalid parameter settings in the
117 configuration file are likewise ignored (but logged) during
118 <systemitem>SIGHUP</> processing.
122 A second way to set these configuration parameters is to give them
123 as a command-line option to the <command>postgres</command> command, such as:
125 postgres -c log_connections=yes -c log_destination='syslog'
127 Command-line options override any conflicting settings in
128 <filename>postgresql.conf</filename>. Note that this means you won't
129 be able to change the value on-the-fly by editing
130 <filename>postgresql.conf</filename>, so while the command-line
131 method might be convenient, it can cost you flexibility later.
135 Occasionally it is useful to give a command line option to
136 one particular session only. The environment variable
137 <envar>PGOPTIONS</envar> can be used for this purpose on the
140 env PGOPTIONS='-c geqo=off' psql
142 (This works for any <application>libpq</>-based client application, not
143 just <application>psql</application>.) Note that this won't work for
144 parameters that are fixed when the server is started or that must be
145 specified in <filename>postgresql.conf</filename>.
149 Furthermore, it is possible to assign a set of parameter settings to
150 a user or a database. Whenever a session is started, the default
151 settings for the user and database involved are loaded. The
152 commands <xref linkend="sql-alterrole">
153 and <xref linkend="sql-alterdatabase">,
154 respectively, are used to configure these settings. Per-database
155 settings override anything received from the
156 <command>postgres</command> command-line or the configuration
157 file, and in turn are overridden by per-user settings; both are
158 overridden by per-session settings.
162 Some parameters can be changed in individual <acronym>SQL</acronym>
163 sessions with the <xref linkend="SQL-SET">
164 command, for example:
166 SET ENABLE_SEQSCAN TO OFF;
168 If <command>SET</> is allowed, it overrides all other sources of
169 values for the parameter. Some parameters cannot be changed via
170 <command>SET</command>: for example, if they control behavior that
171 cannot be changed without restarting the entire
172 <productname>PostgreSQL</productname> server. Also,
173 some <command>SET</command> or <command>ALTER</> parameter modifications
174 require superuser permission.
178 The <xref linkend="SQL-SHOW">
179 command allows inspection of the current values of all parameters.
183 The virtual table <structname>pg_settings</structname> also allows
184 displaying and updating session run-time parameters; see <xref
185 linkend="view-pg-settings"> for details and a description of the
186 different variable types and when they can be changed.
187 <structname>pg_settings</structname> is equivalent to <command>SHOW</>
188 and <command>SET</>, but can be more convenient
189 to use because it can be joined with other tables, or selected from using
190 any desired selection condition. It also contains more information about
191 what values are allowed for the parameters.
195 <sect1 id="runtime-config-file-locations">
196 <title>File Locations</title>
199 In addition to the <filename>postgresql.conf</filename> file
200 already mentioned, <productname>PostgreSQL</productname> uses
201 two other manually-edited configuration files, which control
202 client authentication (their use is discussed in <xref
203 linkend="client-authentication">). By default, all three
204 configuration files are stored in the database cluster's data
205 directory. The parameters described in this section allow the
206 configuration files to be placed elsewhere. (Doing so can ease
207 administration. In particular it is often easier to ensure that
208 the configuration files are properly backed-up when they are
213 <varlistentry id="guc-data-directory" xreflabel="data_directory">
214 <term><varname>data_directory</varname> (<type>string</type>)</term>
216 <primary><varname>data_directory</> configuration parameter</primary>
220 Specifies the directory to use for data storage.
221 This parameter can only be set at server start.
226 <varlistentry id="guc-config-file" xreflabel="config_file">
227 <term><varname>config_file</varname> (<type>string</type>)</term>
229 <primary><varname>config_file</> configuration parameter</primary>
233 Specifies the main server configuration file
234 (customarily called <filename>postgresql.conf</>).
235 This parameter can only be set on the <command>postgres</command> command line.
240 <varlistentry id="guc-hba-file" xreflabel="hba_file">
241 <term><varname>hba_file</varname> (<type>string</type>)</term>
243 <primary><varname>hba_file</> configuration parameter</primary>
247 Specifies the configuration file for host-based authentication
248 (customarily called <filename>pg_hba.conf</>).
249 This parameter can only be set at server start.
254 <varlistentry id="guc-ident-file" xreflabel="ident_file">
255 <term><varname>ident_file</varname> (<type>string</type>)</term>
257 <primary><varname>ident_file</> configuration parameter</primary>
261 Specifies the configuration file for
262 <xref linkend="auth-username-maps"> user name mapping
263 (customarily called <filename>pg_ident.conf</>).
264 This parameter can only be set at server start.
269 <varlistentry id="guc-external-pid-file" xreflabel="external_pid_file">
270 <term><varname>external_pid_file</varname> (<type>string</type>)</term>
272 <primary><varname>external_pid_file</> configuration parameter</primary>
276 Specifies the name of an additional process-ID (PID) file that the
277 server should create for use by server administration programs.
278 This parameter can only be set at server start.
285 In a default installation, none of the above parameters are set
286 explicitly. Instead, the
287 data directory is specified by the <option>-D</option> command-line
288 option or the <envar>PGDATA</envar> environment variable, and the
289 configuration files are all found within the data directory.
293 If you wish to keep the configuration files elsewhere than the
294 data directory, the <command>postgres</command> <option>-D</option>
295 command-line option or <envar>PGDATA</envar> environment variable
296 must point to the directory containing the configuration files,
297 and the <varname>data_directory</> parameter must be set in
298 <filename>postgresql.conf</filename> (or on the command line) to show
299 where the data directory is actually located. Notice that
300 <varname>data_directory</> overrides <option>-D</option> and
301 <envar>PGDATA</envar> for the location
302 of the data directory, but not for the location of the configuration
307 If you wish, you can specify the configuration file names and locations
308 individually using the parameters <varname>config_file</>,
309 <varname>hba_file</> and/or <varname>ident_file</>.
310 <varname>config_file</> can only be specified on the
311 <command>postgres</command> command line, but the others can be
312 set within the main configuration file. If all three parameters plus
313 <varname>data_directory</> are explicitly set, then it is not necessary
314 to specify <option>-D</option> or <envar>PGDATA</envar>.
318 When setting any of these parameters, a relative path will be interpreted
319 with respect to the directory in which <command>postgres</command>
324 <sect1 id="runtime-config-connection">
325 <title>Connections and Authentication</title>
327 <sect2 id="runtime-config-connection-settings">
328 <title>Connection Settings</title>
332 <varlistentry id="guc-listen-addresses" xreflabel="listen_addresses">
333 <term><varname>listen_addresses</varname> (<type>string</type>)</term>
335 <primary><varname>listen_addresses</> configuration parameter</primary>
339 Specifies the TCP/IP address(es) on which the server is
340 to listen for connections from client applications.
341 The value takes the form of a comma-separated list of host names
342 and/or numeric IP addresses. The special entry <literal>*</>
343 corresponds to all available IP interfaces. The entry
344 <literal>0.0.0.0</> allows listening for all IPv4 addresses and
345 <literal>::</> allows listening for all IPv6 addresses.
346 If the list is empty, the server does not listen on any IP interface
347 at all, in which case only Unix-domain sockets can be used to connect
349 The default value is <systemitem class="systemname">localhost</>,
350 which allows only local TCP/IP <quote>loopback</> connections to be
351 made. While client authentication (<xref
352 linkend="client-authentication">) allows fine-grained control
353 over who can access the server, <varname>listen_addresses</varname>
354 controls which interfaces accept connection attempts, which
355 can help prevent repeated malicious connection requests on
356 insecure network interfaces. This parameter can only be set
362 <varlistentry id="guc-port" xreflabel="port">
363 <term><varname>port</varname> (<type>integer</type>)</term>
365 <primary><varname>port</> configuration parameter</primary>
369 The TCP port the server listens on; 5432 by default. Note that the
370 same port number is used for all IP addresses the server listens on.
371 This parameter can only be set at server start.
376 <varlistentry id="guc-max-connections" xreflabel="max_connections">
377 <term><varname>max_connections</varname> (<type>integer</type>)</term>
379 <primary><varname>max_connections</> configuration parameter</primary>
383 Determines the maximum number of concurrent connections to the
384 database server. The default is typically 100 connections, but
385 might be less if your kernel settings will not support it (as
386 determined during <application>initdb</>). This parameter can
387 only be set at server start.
391 Increasing this parameter might cause <productname>PostgreSQL</>
392 to request more <systemitem class="osname">System V</> shared
393 memory or semaphores than your operating system's default configuration
394 allows. See <xref linkend="sysvipc"> for information on how to
395 adjust those parameters, if necessary.
399 When running a standby server, you must set this parameter to the
400 same or higher value than on the master server. Otherwise, queries
401 will not be allowed in the standby server.
406 <varlistentry id="guc-superuser-reserved-connections"
407 xreflabel="superuser_reserved_connections">
408 <term><varname>superuser_reserved_connections</varname>
409 (<type>integer</type>)</term>
411 <primary><varname>superuser_reserved_connections</> configuration parameter</primary>
415 Determines the number of connection <quote>slots</quote> that
416 are reserved for connections by <productname>PostgreSQL</>
417 superusers. At most <xref linkend="guc-max-connections">
418 connections can ever be active simultaneously. Whenever the
419 number of active concurrent connections is at least
420 <varname>max_connections</> minus
421 <varname>superuser_reserved_connections</varname>, new
422 connections will be accepted only for superusers, and no
423 new replication connections will be accepted.
427 The default value is three connections. The value must be less
428 than the value of <varname>max_connections</varname>. This
429 parameter can only be set at server start.
434 <varlistentry id="guc-unix-socket-directory" xreflabel="unix_socket_directory">
435 <term><varname>unix_socket_directory</varname> (<type>string</type>)</term>
437 <primary><varname>unix_socket_directory</> configuration parameter</primary>
441 Specifies the directory of the Unix-domain socket on which the
442 server is to listen for
443 connections from client applications. The default is normally
444 <filename>/tmp</filename>, but can be changed at build time.
445 This parameter can only be set at server start.
449 In addition to the socket file itself, which is named
450 <literal>.s.PGSQL.<replaceable>nnnn</></literal> where
451 <replaceable>nnnn</> is the server's port number, an ordinary file
452 named <literal>.s.PGSQL.<replaceable>nnnn</>.lock</literal> will be
453 created in the <varname>unix_socket_directory</> directory. Neither
454 file should ever be removed manually.
458 This parameter is irrelevant on Windows, which does not have
464 <varlistentry id="guc-unix-socket-group" xreflabel="unix_socket_group">
465 <term><varname>unix_socket_group</varname> (<type>string</type>)</term>
467 <primary><varname>unix_socket_group</> configuration parameter</primary>
471 Sets the owning group of the Unix-domain socket. (The owning
472 user of the socket is always the user that starts the
473 server.) In combination with the parameter
474 <varname>unix_socket_permissions</varname> this can be used as
475 an additional access control mechanism for Unix-domain connections.
476 By default this is the empty string, which uses the default
477 group of the server user. This parameter can only be set at
482 This parameter is irrelevant on Windows, which does not have
488 <varlistentry id="guc-unix-socket-permissions" xreflabel="unix_socket_permissions">
489 <term><varname>unix_socket_permissions</varname> (<type>integer</type>)</term>
491 <primary><varname>unix_socket_permissions</> configuration parameter</primary>
495 Sets the access permissions of the Unix-domain socket. Unix-domain
496 sockets use the usual Unix file system permission set.
497 The parameter value is expected to be a numeric mode
498 specified in the format accepted by the
499 <function>chmod</function> and <function>umask</function>
500 system calls. (To use the customary octal format the number
501 must start with a <literal>0</literal> (zero).)
505 The default permissions are <literal>0777</literal>, meaning
506 anyone can connect. Reasonable alternatives are
507 <literal>0770</literal> (only user and group, see also
508 <varname>unix_socket_group</varname>) and <literal>0700</literal>
509 (only user). (Note that for a Unix-domain socket, only write
510 permission matters, so there is no point in setting or revoking
511 read or execute permissions.)
515 This access control mechanism is independent of the one
516 described in <xref linkend="client-authentication">.
520 This parameter can only be set at server start.
524 This parameter is irrelevant on Windows, which does not have
530 <varlistentry id="guc-bonjour" xreflabel="bonjour">
531 <term><varname>bonjour</varname> (<type>boolean</type>)</term>
533 <primary><varname>bonjour</> configuration parameter</primary>
537 Enables advertising the server's existence via
538 <productname>Bonjour</productname>. The default is off.
539 This parameter can only be set at server start.
544 <varlistentry id="guc-bonjour-name" xreflabel="bonjour_name">
545 <term><varname>bonjour_name</varname> (<type>string</type>)</term>
547 <primary><varname>bonjour_name</> configuration parameter</primary>
551 Specifies the <productname>Bonjour</productname> service
552 name. The computer name is used if this parameter is set to the
553 empty string <literal>''</> (which is the default). This parameter is
554 ignored if the server was not compiled with
555 <productname>Bonjour</productname> support.
556 This parameter can only be set at server start.
561 <varlistentry id="guc-tcp-keepalives-idle" xreflabel="tcp_keepalives_idle">
562 <term><varname>tcp_keepalives_idle</varname> (<type>integer</type>)</term>
564 <primary><varname>tcp_keepalives_idle</> configuration parameter</primary>
568 Specifies the number of seconds before sending a keepalive packet on
569 an otherwise idle connection. A value of 0 uses the system default.
570 This parameter is supported only on systems that support the
571 <symbol>TCP_KEEPIDLE</> or <symbol>TCP_KEEPALIVE</> symbols, and on
572 Windows; on other systems, it must be zero. This parameter is ignored
573 for connections made via a Unix-domain socket.
577 On Windows, a value of 0 will set this parameter to 2 hours,
578 since Windows does not provide a way to read the system default value.
584 <varlistentry id="guc-tcp-keepalives-interval" xreflabel="tcp_keepalives_interval">
585 <term><varname>tcp_keepalives_interval</varname> (<type>integer</type>)</term>
587 <primary><varname>tcp_keepalives_interval</> configuration parameter</primary>
591 Specifies the number of seconds between sending keepalives on an
592 otherwise idle connection. A value of 0 uses the system default.
593 This parameter is supported only on systems that support the
594 <symbol>TCP_KEEPINTVL</> symbol, and on Windows; on other systems, it
595 must be zero. This parameter is ignored for connections made via a
600 On Windows, a value of 0 will set this parameter to 1 second,
601 since Windows does not provide a way to read the system default value.
607 <varlistentry id="guc-tcp-keepalives-count" xreflabel="tcp_keepalives_count">
608 <term><varname>tcp_keepalives_count</varname> (<type>integer</type>)</term>
610 <primary><varname>tcp_keepalives_count</> configuration parameter</primary>
614 Specifies the number of keepalive packets to send on an otherwise idle
615 connection. A value of 0 uses the system default. This parameter is
616 supported only on systems that support the <symbol>TCP_KEEPCNT</>
617 symbol; on other systems, it must be zero. This parameter is ignored
618 for connections made via a Unix-domain socket.
622 This parameter is not supported on Windows, and must be zero.
630 <sect2 id="runtime-config-connection-security">
631 <title>Security and Authentication</title>
634 <varlistentry id="guc-authentication-timeout" xreflabel="authentication_timeout">
635 <term><varname>authentication_timeout</varname> (<type>integer</type>)</term>
636 <indexterm><primary>timeout</><secondary>client authentication</></indexterm>
637 <indexterm><primary>client authentication</><secondary>timeout during</></indexterm>
639 <primary><varname>authentication_timeout</> configuration parameter</primary>
644 Maximum time to complete client authentication, in seconds. If a
645 would-be client has not completed the authentication protocol in
646 this much time, the server closes the connection. This prevents
647 hung clients from occupying a connection indefinitely.
648 The default is one minute (<literal>1m</>).
649 This parameter can only be set in the <filename>postgresql.conf</>
650 file or on the server command line.
655 <varlistentry id="guc-ssl" xreflabel="ssl">
656 <term><varname>ssl</varname> (<type>boolean</type>)</term>
658 <primary><varname>ssl</> configuration parameter</primary>
662 Enables <acronym>SSL</> connections. Please read
663 <xref linkend="ssl-tcp"> before using this. The default
664 is <literal>off</>. This parameter can only be set at server
665 start. <acronym>SSL</> communication is only possible with
671 <varlistentry id="guc-ssl-renegotiation-limit" xreflabel="ssl_renegotiation_limit">
672 <term><varname>ssl_renegotiation_limit</varname> (<type>integer</type>)</term>
674 <primary><varname>ssl_renegotiation_limit</> configuration parameter</primary>
678 Specifies how much data can flow over an <acronym>SSL</>-encrypted
679 connection before renegotiation of the session keys will take
680 place. Renegotiation decreases an attacker's chances of doing
681 cryptanalysis when large amounts of traffic can be examined, but it
682 also carries a large performance penalty. The sum of sent and received
683 traffic is used to check the limit. If this parameter is set to 0,
684 renegotiation is disabled. The default is <literal>512MB</>.
688 SSL libraries from before November 2009 are insecure when using SSL
689 renegotiation, due to a vulnerability in the SSL protocol. As a
690 stop-gap fix for this vulnerability, some vendors shipped SSL
691 libraries incapable of doing renegotiation. If any such libraries
692 are in use on the client or server, SSL renegotiation should be
699 <varlistentry id="guc-ssl-ciphers" xreflabel="ssl_ciphers">
700 <term><varname>ssl_ciphers</varname> (<type>string</type>)</term>
702 <primary><varname>ssl_ciphers</> configuration parameter</primary>
706 Specifies a list of <acronym>SSL</> ciphers that are allowed to be
707 used on secure connections. See the <application>openssl</>
708 manual page for a list of supported ciphers.
713 <varlistentry id="guc-password-encryption" xreflabel="password_encryption">
714 <term><varname>password_encryption</varname> (<type>boolean</type>)</term>
716 <primary><varname>password_encryption</> configuration parameter</primary>
720 When a password is specified in <xref
721 linkend="sql-createuser"> or
722 <xref linkend="sql-alterrole">
723 without writing either <literal>ENCRYPTED</> or
724 <literal>UNENCRYPTED</>, this parameter determines whether the
725 password is to be encrypted. The default is <literal>on</>
726 (encrypt the password).
731 <varlistentry id="guc-krb-server-keyfile" xreflabel="krb_server_keyfile">
732 <term><varname>krb_server_keyfile</varname> (<type>string</type>)</term>
734 <primary><varname>krb_server_keyfile</> configuration parameter</primary>
738 Sets the location of the Kerberos server key file. See
739 <xref linkend="kerberos-auth"> or <xref linkend="gssapi-auth">
740 for details. This parameter can only be set in the
741 <filename>postgresql.conf</> file or on the server command line.
746 <varlistentry id="guc-krb-srvname" xreflabel="krb_srvname">
747 <term><varname>krb_srvname</varname> (<type>string</type>)</term>
749 <primary><varname>krb_srvname</> configuration parameter</primary>
753 Sets the Kerberos service name. See <xref linkend="kerberos-auth">
754 for details. This parameter can only be set in the
755 <filename>postgresql.conf</> file or on the server command line.
760 <varlistentry id="guc-krb-caseins-users" xreflabel="krb_caseins_users">
761 <term><varname>krb_caseins_users</varname> (<type>boolean</type>)</term>
763 <primary><varname>krb_caseins_users</varname> configuration parameter</primary>
767 Sets whether Kerberos and GSSAPI user names should be treated
769 The default is <literal>off</> (case sensitive). This parameter can only be
770 set in the <filename>postgresql.conf</> file or on the server command line.
775 <varlistentry id="guc-db-user-namespace" xreflabel="db_user_namespace">
776 <term><varname>db_user_namespace</varname> (<type>boolean</type>)</term>
778 <primary><varname>db_user_namespace</> configuration parameter</primary>
782 This parameter enables per-database user names. It is off by default.
783 This parameter can only be set in the <filename>postgresql.conf</>
784 file or on the server command line.
788 If this is on, you should create users as <literal>username@dbname</>.
789 When <literal>username</> is passed by a connecting client,
790 <literal>@</> and the database name are appended to the user
791 name and that database-specific user name is looked up by the
792 server. Note that when you create users with names containing
793 <literal>@</> within the SQL environment, you will need to
798 With this parameter enabled, you can still create ordinary global
799 users. Simply append <literal>@</> when specifying the user
800 name in the client, e.g. <literal>joe@</>. The <literal>@</>
801 will be stripped off before the user name is looked up by the
806 <varname>db_user_namespace</> causes the client's and
807 server's user name representation to differ.
808 Authentication checks are always done with the server's user name
809 so authentication methods must be configured for the
810 server's user name, not the client's. Because
811 <literal>md5</> uses the user name as salt on both the
812 client and server, <literal>md5</> cannot be used with
813 <varname>db_user_namespace</>.
818 This feature is intended as a temporary measure until a
819 complete solution is found. At that time, this option will
830 <sect1 id="runtime-config-resource">
831 <title>Resource Consumption</title>
833 <sect2 id="runtime-config-resource-memory">
834 <title>Memory</title>
837 <varlistentry id="guc-shared-buffers" xreflabel="shared_buffers">
838 <term><varname>shared_buffers</varname> (<type>integer</type>)</term>
840 <primary><varname>shared_buffers</> configuration parameter</primary>
844 Sets the amount of memory the database server uses for shared
845 memory buffers. The default is typically 32 megabytes
846 (<literal>32MB</>), but might be less if your kernel settings will
847 not support it (as determined during <application>initdb</>).
848 This setting must be at least 128 kilobytes. (Non-default
849 values of <symbol>BLCKSZ</symbol> change the minimum.) However,
850 settings significantly higher than the minimum are usually needed
851 for good performance. This parameter can only be set at server start.
855 If you have a dedicated database server with 1GB or more of RAM, a
856 reasonable starting value for <varname>shared_buffers</varname> is 25%
857 of the memory in your system. There are some workloads where even
858 large settings for <varname>shared_buffers</varname> are effective, but
859 because <productname>PostgreSQL</productname> also relies on the
860 operating system cache, it is unlikely that an allocation of more than
861 40% of RAM to <varname>shared_buffers</varname> will work better than a
862 smaller amount. Larger settings for <varname>shared_buffers</varname>
863 usually require a corresponding increase in
864 <varname>checkpoint_segments</varname>, in order to spread out the
865 process of writing large quantities of new or changed data over a
866 longer period of time.
870 On systems with less than 1GB of RAM, a smaller percentage of RAM is
871 appropriate, so as to leave adequate space for the operating system.
872 Also, on Windows, large values for <varname>shared_buffers</varname>
873 aren't as effective. You may find better results keeping the setting
874 relatively low and using the operating system cache more instead. The
875 useful range for <varname>shared_buffers</varname> on Windows systems
876 is generally from 64MB to 512MB.
880 Increasing this parameter might cause <productname>PostgreSQL</>
881 to request more <systemitem class="osname">System V</> shared
882 memory than your operating system's default configuration
883 allows. See <xref linkend="sysvipc"> for information on how to
884 adjust those parameters, if necessary.
889 <varlistentry id="guc-temp-buffers" xreflabel="temp_buffers">
890 <term><varname>temp_buffers</varname> (<type>integer</type>)</term>
892 <primary><varname>temp_buffers</> configuration parameter</primary>
896 Sets the maximum number of temporary buffers used by each database
897 session. These are session-local buffers used only for access to
898 temporary tables. The default is eight megabytes
899 (<literal>8MB</>). The setting can be changed within individual
900 sessions, but only before the first use of temporary tables
901 within the session; subsequent attempts to change the value will
902 have no effect on that session.
906 A session will allocate temporary buffers as needed up to the limit
907 given by <varname>temp_buffers</>. The cost of setting a large
908 value in sessions that do not actually need many temporary
909 buffers is only a buffer descriptor, or about 64 bytes, per
910 increment in <varname>temp_buffers</>. However if a buffer is
911 actually used an additional 8192 bytes will be consumed for it
912 (or in general, <symbol>BLCKSZ</symbol> bytes).
917 <varlistentry id="guc-max-prepared-transactions" xreflabel="max_prepared_transactions">
918 <term><varname>max_prepared_transactions</varname> (<type>integer</type>)</term>
920 <primary><varname>max_prepared_transactions</> configuration parameter</primary>
924 Sets the maximum number of transactions that can be in the
925 <quote>prepared</> state simultaneously (see <xref
926 linkend="sql-prepare-transaction">).
927 Setting this parameter to zero (which is the default)
928 disables the prepared-transaction feature.
929 This parameter can only be set at server start.
933 If you are not planning to use prepared transactions, this parameter
934 should be set to zero to prevent accidental creation of prepared
935 transactions. If you are using prepared transactions, you will
936 probably want <varname>max_prepared_transactions</varname> to be at
937 least as large as <xref linkend="guc-max-connections">, so that every
938 session can have a prepared transaction pending.
942 Increasing this parameter might cause <productname>PostgreSQL</>
943 to request more <systemitem class="osname">System V</> shared
944 memory than your operating system's default configuration
945 allows. See <xref linkend="sysvipc"> for information on how to
946 adjust those parameters, if necessary.
950 When running a standby server, you must set this parameter to the
951 same or higher value than on the master server. Otherwise, queries
952 will not be allowed in the standby server.
957 <varlistentry id="guc-work-mem" xreflabel="work_mem">
958 <term><varname>work_mem</varname> (<type>integer</type>)</term>
960 <primary><varname>work_mem</> configuration parameter</primary>
964 Specifies the amount of memory to be used by internal sort operations
965 and hash tables before writing to temporary disk files. The value
966 defaults to one megabyte (<literal>1MB</>).
967 Note that for a complex query, several sort or hash operations might be
968 running in parallel; each operation will be allowed to use as much memory
969 as this value specifies before it starts to write data into temporary
970 files. Also, several running sessions could be doing such operations
971 concurrently. Therefore, the total memory used could be many
972 times the value of <varname>work_mem</varname>; it is necessary to
973 keep this fact in mind when choosing the value. Sort operations are
974 used for <literal>ORDER BY</>, <literal>DISTINCT</>, and
976 Hash tables are used in hash joins, hash-based aggregation, and
977 hash-based processing of <literal>IN</> subqueries.
982 <varlistentry id="guc-maintenance-work-mem" xreflabel="maintenance_work_mem">
983 <term><varname>maintenance_work_mem</varname> (<type>integer</type>)</term>
985 <primary><varname>maintenance_work_mem</> configuration parameter</primary>
989 Specifies the maximum amount of memory to be used by maintenance
990 operations, such as <command>VACUUM</command>, <command>CREATE
991 INDEX</>, and <command>ALTER TABLE ADD FOREIGN KEY</>. It defaults
992 to 16 megabytes (<literal>16MB</>). Since only one of these
993 operations can be executed at a time by a database session, and
994 an installation normally doesn't have many of them running
995 concurrently, it's safe to set this value significantly larger
996 than <varname>work_mem</varname>. Larger settings might improve
997 performance for vacuuming and for restoring database dumps.
1000 Note that when autovacuum runs, up to
1001 <xref linkend="guc-autovacuum-max-workers"> times this memory may be
1002 allocated, so be careful not to set the default value too high.
1007 <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
1008 <term><varname>max_stack_depth</varname> (<type>integer</type>)</term>
1010 <primary><varname>max_stack_depth</> configuration parameter</primary>
1014 Specifies the maximum safe depth of the server's execution stack.
1015 The ideal setting for this parameter is the actual stack size limit
1016 enforced by the kernel (as set by <literal>ulimit -s</> or local
1017 equivalent), less a safety margin of a megabyte or so. The safety
1018 margin is needed because the stack depth is not checked in every
1019 routine in the server, but only in key potentially-recursive routines
1020 such as expression evaluation. The default setting is two
1021 megabytes (<literal>2MB</>), which is conservatively small and
1022 unlikely to risk crashes. However, it might be too small to allow
1023 execution of complex functions. Only superusers can change this
1028 Setting <varname>max_stack_depth</> higher than
1029 the actual kernel limit will mean that a runaway recursive function
1030 can crash an individual backend process. On platforms where
1031 <productname>PostgreSQL</productname> can determine the kernel limit,
1032 the server will not allow this variable to be set to an unsafe
1033 value. However, not all platforms provide the information,
1034 so caution is recommended in selecting a value.
1042 <sect2 id="runtime-config-resource-disk">
1046 <varlistentry id="guc-temp-file-limit" xreflabel="temp_file_limit">
1047 <term><varname>temp_file_limit</varname> (<type>integer</type>)</term>
1049 <primary><varname>temp_file_limit</> configuration parameter</primary>
1053 Specifies the maximum amount of disk space that a session can use
1054 for temporary files, such as sort and hash temporary files, or the
1055 storage file for a held cursor.
1056 The value is specified in kilobytes, and <literal>-1</> (the
1057 default) means no limit.
1058 Only superusers can change this setting.
1061 This setting constrains the total space used at any instant by all
1062 temporary files used by a given <productname>PostgreSQL</> session.
1063 It should be noted that disk space used for explicit temporary
1064 tables, as opposed to temporary files used behind-the-scenes in query
1065 execution, does <emphasis>not</emphasis> count against this limit.
1073 <sect2 id="runtime-config-resource-kernel">
1074 <title>Kernel Resource Usage</title>
1077 <varlistentry id="guc-max-files-per-process" xreflabel="max_files_per_process">
1078 <term><varname>max_files_per_process</varname> (<type>integer</type>)</term>
1080 <primary><varname>max_files_per_process</> configuration parameter</primary>
1084 Sets the maximum number of simultaneously open files allowed to each
1085 server subprocess. The default is one thousand files. If the kernel is enforcing
1086 a safe per-process limit, you don't need to worry about this setting.
1087 But on some platforms (notably, most BSD systems), the kernel will
1088 allow individual processes to open many more files than the system
1089 can actually support if many processes all try to open
1090 that many files. If you find yourself seeing <quote>Too many open
1091 files</> failures, try reducing this setting.
1092 This parameter can only be set at server start.
1097 <varlistentry id="guc-shared-preload-libraries" xreflabel="shared_preload_libraries">
1098 <term><varname>shared_preload_libraries</varname> (<type>string</type>)</term>
1100 <primary><varname>shared_preload_libraries</> configuration parameter</primary>
1104 This variable specifies one or more shared libraries
1105 to be preloaded at server start. For example,
1106 <literal>'$libdir/mylib'</literal> would cause
1107 <literal>mylib.so</> (or on some platforms,
1108 <literal>mylib.sl</>) to be preloaded from the installation's
1109 standard library directory.
1110 All library names are converted to lower case unless double-quoted.
1111 If more than one library is to be loaded, separate their names
1112 with commas. This parameter can only be set at server start.
1116 <productname>PostgreSQL</productname> procedural language
1117 libraries can be preloaded in this way, typically by using the
1118 syntax <literal>'$libdir/plXXX'</literal> where
1119 <literal>XXX</literal> is <literal>pgsql</>, <literal>perl</>,
1120 <literal>tcl</>, or <literal>python</>.
1124 By preloading a shared library, the library startup time is avoided
1125 when the library is first used. However, the time to start each new
1126 server process might increase slightly, even if that process never
1127 uses the library. So this parameter is recommended only for
1128 libraries that will be used in most sessions.
1133 On Windows hosts, preloading a library at server start will not reduce
1134 the time required to start each new server process; each server process
1135 will re-load all preload libraries. However, <varname>shared_preload_libraries
1136 </varname> is still useful on Windows hosts because some shared libraries may
1137 need to perform certain operations that only take place at postmaster start
1138 (for example, a shared library may need to reserve lightweight locks
1139 or shared memory and you can't do that after the postmaster has started).
1143 If a specified library is not found,
1144 the server will fail to start.
1148 Every PostgreSQL-supported library has a <quote>magic
1149 block</> that is checked to guarantee compatibility.
1150 For this reason, non-PostgreSQL libraries cannot be
1159 <sect2 id="runtime-config-resource-vacuum-cost">
1160 <title>Cost-based Vacuum Delay</title>
1163 During the execution of <xref linkend="sql-vacuum">
1164 and <xref linkend="sql-analyze">
1165 commands, the system maintains an
1166 internal counter that keeps track of the estimated cost of the
1167 various I/O operations that are performed. When the accumulated
1168 cost reaches a limit (specified by
1169 <varname>vacuum_cost_limit</varname>), the process performing
1170 the operation will sleep for a short period of time, as specified by
1171 <varname>vacuum_cost_delay</varname>. Then it will reset the
1172 counter and continue execution.
1176 The intent of this feature is to allow administrators to reduce
1177 the I/O impact of these commands on concurrent database
1178 activity. There are many situations where it is not
1179 important that maintenance commands like
1180 <command>VACUUM</command> and <command>ANALYZE</command> finish
1181 quickly; however, it is usually very important that these
1182 commands do not significantly interfere with the ability of the
1183 system to perform other database operations. Cost-based vacuum
1184 delay provides a way for administrators to achieve this.
1188 This feature is disabled by default for manually issued
1189 <command>VACUUM</command> commands. To enable it, set the
1190 <varname>vacuum_cost_delay</varname> variable to a nonzero
1195 <varlistentry id="guc-vacuum-cost-delay" xreflabel="vacuum_cost_delay">
1196 <term><varname>vacuum_cost_delay</varname> (<type>integer</type>)</term>
1198 <primary><varname>vacuum_cost_delay</> configuration parameter</primary>
1202 The length of time, in milliseconds, that the process will sleep
1203 when the cost limit has been exceeded.
1204 The default value is zero, which disables the cost-based vacuum
1205 delay feature. Positive values enable cost-based vacuuming.
1206 Note that on many systems, the effective resolution
1207 of sleep delays is 10 milliseconds; setting
1208 <varname>vacuum_cost_delay</varname> to a value that is
1209 not a multiple of 10 might have the same results as setting it
1210 to the next higher multiple of 10.
1214 When using cost-based vacuuming, appropriate values for
1215 <varname>vacuum_cost_delay</> are usually quite small, perhaps
1216 10 or 20 milliseconds. Adjusting vacuum's resource consumption
1217 is best done by changing the other vacuum cost parameters.
1222 <varlistentry id="guc-vacuum-cost-page-hit" xreflabel="vacuum_cost_page_hit">
1223 <term><varname>vacuum_cost_page_hit</varname> (<type>integer</type>)</term>
1225 <primary><varname>vacuum_cost_page_hit</> configuration parameter</primary>
1229 The estimated cost for vacuuming a buffer found in the shared buffer
1230 cache. It represents the cost to lock the buffer pool, lookup
1231 the shared hash table and scan the content of the page. The
1232 default value is one.
1237 <varlistentry id="guc-vacuum-cost-page-miss" xreflabel="vacuum_cost_page_miss">
1238 <term><varname>vacuum_cost_page_miss</varname> (<type>integer</type>)</term>
1240 <primary><varname>vacuum_cost_page_miss</> configuration parameter</primary>
1244 The estimated cost for vacuuming a buffer that has to be read from
1245 disk. This represents the effort to lock the buffer pool,
1246 lookup the shared hash table, read the desired block in from
1247 the disk and scan its content. The default value is 10.
1252 <varlistentry id="guc-vacuum-cost-page-dirty" xreflabel="vacuum_cost_page_dirty">
1253 <term><varname>vacuum_cost_page_dirty</varname> (<type>integer</type>)</term>
1255 <primary><varname>vacuum_cost_page_dirty</> configuration parameter</primary>
1259 The estimated cost charged when vacuum modifies a block that was
1260 previously clean. It represents the extra I/O required to
1261 flush the dirty block out to disk again. The default value is
1267 <varlistentry id="guc-vacuum-cost-limit" xreflabel="vacuum_cost_limit">
1268 <term><varname>vacuum_cost_limit</varname> (<type>integer</type>)</term>
1270 <primary><varname>vacuum_cost_limit</> configuration parameter</primary>
1274 The accumulated cost that will cause the vacuuming process to sleep.
1275 The default value is 200.
1283 There are certain operations that hold critical locks and should
1284 therefore complete as quickly as possible. Cost-based vacuum
1285 delays do not occur during such operations. Therefore it is
1286 possible that the cost accumulates far higher than the specified
1287 limit. To avoid uselessly long delays in such cases, the actual
1288 delay is calculated as <varname>vacuum_cost_delay</varname> *
1289 <varname>accumulated_balance</varname> /
1290 <varname>vacuum_cost_limit</varname> with a maximum of
1291 <varname>vacuum_cost_delay</varname> * 4.
1296 <sect2 id="runtime-config-resource-background-writer">
1297 <title>Background Writer</title>
1300 There is a separate server
1301 process called the <firstterm>background writer</>, whose function
1302 is to issue writes of <quote>dirty</> (new or modified) shared
1303 buffers. It writes shared buffers so server processes handling
1304 user queries seldom or never need to wait for a write to occur.
1305 However, the background writer does cause a net overall
1306 increase in I/O load, because while a repeatedly-dirtied page might
1307 otherwise be written only once per checkpoint interval, the
1308 background writer might write it several times as it is dirtied
1309 in the same interval. The parameters discussed in this subsection
1310 can be used to tune the behavior for local needs.
1314 <varlistentry id="guc-bgwriter-delay" xreflabel="bgwriter_delay">
1315 <term><varname>bgwriter_delay</varname> (<type>integer</type>)</term>
1317 <primary><varname>bgwriter_delay</> configuration parameter</primary>
1321 Specifies the delay between activity rounds for the
1322 background writer. In each round the writer issues writes
1323 for some number of dirty buffers (controllable by the
1324 following parameters). It then sleeps for <varname>bgwriter_delay</>
1325 milliseconds, and repeats. When there are no dirty buffers in the
1326 buffer pool, though, it goes into a longer sleep regardless of
1327 <varname>bgwriter_delay</>. The default value is 200
1328 milliseconds (<literal>200ms</>). Note that on many systems, the
1329 effective resolution of sleep delays is 10 milliseconds; setting
1330 <varname>bgwriter_delay</> to a value that is not a multiple of 10
1331 might have the same results as setting it to the next higher multiple
1332 of 10. This parameter can only be set in the
1333 <filename>postgresql.conf</> file or on the server command line.
1338 <varlistentry id="guc-bgwriter-lru-maxpages" xreflabel="bgwriter_lru_maxpages">
1339 <term><varname>bgwriter_lru_maxpages</varname> (<type>integer</type>)</term>
1341 <primary><varname>bgwriter_lru_maxpages</> configuration parameter</primary>
1345 In each round, no more than this many buffers will be written
1346 by the background writer. Setting this to zero disables
1347 background writing. (Note that checkpoints, which are managed by
1348 a separate, dedicated auxiliary process, are unaffected.)
1349 The default value is 100 buffers.
1350 This parameter can only be set in the <filename>postgresql.conf</>
1351 file or on the server command line.
1356 <varlistentry id="guc-bgwriter-lru-multiplier" xreflabel="bgwriter_lru_multiplier">
1357 <term><varname>bgwriter_lru_multiplier</varname> (<type>floating point</type>)</term>
1359 <primary><varname>bgwriter_lru_multiplier</> configuration parameter</primary>
1363 The number of dirty buffers written in each round is based on the
1364 number of new buffers that have been needed by server processes
1365 during recent rounds. The average recent need is multiplied by
1366 <varname>bgwriter_lru_multiplier</> to arrive at an estimate of the
1367 number of buffers that will be needed during the next round. Dirty
1368 buffers are written until there are that many clean, reusable buffers
1369 available. (However, no more than <varname>bgwriter_lru_maxpages</>
1370 buffers will be written per round.)
1371 Thus, a setting of 1.0 represents a <quote>just in time</> policy
1372 of writing exactly the number of buffers predicted to be needed.
1373 Larger values provide some cushion against spikes in demand,
1374 while smaller values intentionally leave writes to be done by
1377 This parameter can only be set in the <filename>postgresql.conf</>
1378 file or on the server command line.
1385 Smaller values of <varname>bgwriter_lru_maxpages</varname> and
1386 <varname>bgwriter_lru_multiplier</varname> reduce the extra I/O load
1387 caused by the background writer, but make it more likely that server
1388 processes will have to issue writes for themselves, delaying interactive
1393 <sect2 id="runtime-config-resource-async-behavior">
1394 <title>Asynchronous Behavior</title>
1397 <varlistentry id="guc-effective-io-concurrency" xreflabel="effective_io_concurrency">
1398 <term><varname>effective_io_concurrency</varname> (<type>integer</type>)</term>
1400 <primary><varname>effective_io_concurrency</> configuration parameter</primary>
1404 Sets the number of concurrent disk I/O operations that
1405 <productname>PostgreSQL</> expects can be executed
1406 simultaneously. Raising this value will increase the number of I/O
1407 operations that any individual <productname>PostgreSQL</> session
1408 attempts to initiate in parallel. The allowed range is 1 to 1000,
1409 or zero to disable issuance of asynchronous I/O requests. Currently,
1410 this setting only affects bitmap heap scans.
1414 A good starting point for this setting is the number of separate
1415 drives comprising a RAID 0 stripe or RAID 1 mirror being used for the
1416 database. (For RAID 5 the parity drive should not be counted.)
1417 However, if the database is often busy with multiple queries issued in
1418 concurrent sessions, lower values may be sufficient to keep the disk
1419 array busy. A value higher than needed to keep the disks busy will
1420 only result in extra CPU overhead.
1424 For more exotic systems, such as memory-based storage or a RAID array
1425 that is limited by bus bandwidth, the correct value might be the
1426 number of I/O paths available. Some experimentation may be needed
1427 to find the best value.
1431 Asynchronous I/O depends on an effective <function>posix_fadvise</>
1432 function, which some operating systems lack. If the function is not
1433 present then setting this parameter to anything but zero will result
1434 in an error. On some operating systems (e.g., Solaris), the function
1435 is present but does not actually do anything.
1443 <sect1 id="runtime-config-wal">
1444 <title>Write Ahead Log</title>
1447 See also <xref linkend="wal-configuration"> for details on WAL
1448 and checkpoint tuning.
1451 <sect2 id="runtime-config-wal-settings">
1452 <title>Settings</title>
1455 <varlistentry id="guc-wal-level" xreflabel="wal_level">
1456 <term><varname>wal_level</varname> (<type>enum</type>)</term>
1458 <primary><varname>wal_level</> configuration parameter</primary>
1462 <varname>wal_level</> determines how much information is written
1463 to the WAL. The default value is <literal>minimal</>, which writes
1464 only the information needed to recover from a crash or immediate
1465 shutdown. <literal>archive</> adds logging required for WAL archiving,
1466 and <literal>hot_standby</> further adds information required to run
1467 read-only queries on a standby server.
1468 This parameter can only be set at server start.
1471 In <literal>minimal</> level, WAL-logging of some bulk
1472 operations can be safely skipped, which can make those
1473 operations much faster (see <xref linkend="populate-pitr">).
1474 Operations in which this optimization can be applied include:
1476 <member><command>CREATE TABLE AS</></member>
1477 <member><command>CREATE INDEX</></member>
1478 <member><command>CLUSTER</></member>
1479 <member><command>COPY</> into tables that were created or truncated in the same
1480 transaction</member>
1482 But minimal WAL does not contain
1483 enough information to reconstruct the data from a base backup and the
1484 WAL logs, so either <literal>archive</> or <literal>hot_standby</>
1485 level must be used to enable
1486 WAL archiving (<xref linkend="guc-archive-mode">) and streaming
1490 In <literal>hot_standby</> level, the same information is logged as
1491 with <literal>archive</>, plus information needed to reconstruct
1492 the status of running transactions from the WAL. To enable read-only
1493 queries on a standby server, <varname>wal_level</> must be set to
1494 <literal>hot_standby</> on the primary, and
1495 <xref linkend="guc-hot-standby"> must be enabled in the standby. It is
1496 thought that there is
1497 little measurable difference in performance between using
1498 <literal>hot_standby</> and <literal>archive</> levels, so feedback
1499 is welcome if any production impacts are noticeable.
1504 <varlistentry id="guc-fsync" xreflabel="fsync">
1506 <primary><varname>fsync</> configuration parameter</primary>
1508 <term><varname>fsync</varname> (<type>boolean</type>)</term>
1511 If this parameter is on, the <productname>PostgreSQL</> server
1512 will try to make sure that updates are physically written to
1513 disk, by issuing <function>fsync()</> system calls or various
1514 equivalent methods (see <xref linkend="guc-wal-sync-method">).
1515 This ensures that the database cluster can recover to a
1516 consistent state after an operating system or hardware crash.
1520 While turning off <varname>fsync</varname> is often a performance
1521 benefit, this can result in unrecoverable data corruption in
1522 the event of a power failure or system crash. Thus it
1523 is only advisable to turn off <varname>fsync</varname> if
1524 you can easily recreate your entire database from external
1529 Examples of safe circumstances for turning off
1530 <varname>fsync</varname> include the initial loading of a new
1531 database cluster from a backup file, using a database cluster
1532 for processing a batch of data after which the database
1533 will be thrown away and recreated,
1534 or for a read-only database clone which
1535 gets recreated frequently and is not used for failover. High
1536 quality hardware alone is not a sufficient justification for
1537 turning off <varname>fsync</varname>.
1541 In many situations, turning off <xref linkend="guc-synchronous-commit">
1542 for noncritical transactions can provide much of the potential
1543 performance benefit of turning off <varname>fsync</varname>, without
1544 the attendant risks of data corruption.
1548 <varname>fsync</varname> can only be set in the <filename>postgresql.conf</>
1549 file or on the server command line.
1550 If you turn this parameter off, also consider turning off
1551 <xref linkend="guc-full-page-writes">.
1556 <varlistentry id="guc-synchronous-commit" xreflabel="synchronous_commit">
1557 <term><varname>synchronous_commit</varname> (<type>enum</type>)</term>
1559 <primary><varname>synchronous_commit</> configuration parameter</primary>
1563 Specifies whether transaction commit will wait for WAL records
1564 to be written to disk before the command returns a <quote>success</>
1565 indication to the client. Valid values are <literal>on</>, <literal>write</>,
1566 <literal>local</>, and <literal>off</>. The default, and safe, value
1567 is <literal>on</>. When <literal>off</>, there can be a delay between
1568 when success is reported to the client and when the transaction is
1569 really guaranteed to be safe against a server crash. (The maximum
1570 delay is three times <xref linkend="guc-wal-writer-delay">.) Unlike
1571 <xref linkend="guc-fsync">, setting this parameter to <literal>off</>
1572 does not create any risk of database inconsistency: an operating
1573 system or database crash might
1574 result in some recent allegedly-committed transactions being lost, but
1575 the database state will be just the same as if those transactions had
1576 been aborted cleanly. So, turning <varname>synchronous_commit</> off
1577 can be a useful alternative when performance is more important than
1578 exact certainty about the durability of a transaction. For more
1579 discussion see <xref linkend="wal-async-commit">.
1582 If <xref linkend="guc-synchronous-standby-names"> is set, this
1583 parameter also controls whether or not transaction commit will wait
1584 for the transaction's WAL records to be flushed to disk and replicated
1585 to the standby server. When <literal>write</>, the commit wait will
1586 last until a reply from the current synchronous standby indicates
1587 it has received the commit record of the transaction to memory.
1588 Normally this causes no data loss at the time of failover. However,
1589 if both primary and standby crash, and the database cluster of
1590 the primary gets corrupted, recent committed transactions might
1591 be lost. When <literal>on</>, the commit wait will last until a reply
1592 from the current synchronous standby indicates it has flushed
1593 the commit record of the transaction to durable storage. This
1594 avoids any data loss unless the database cluster of both primary and
1595 standby gets corrupted simultaneously. If synchronous
1596 replication is in use, it will normally be sensible either to wait
1597 for both local flush and replication of WAL records, or
1598 to allow the transaction to commit asynchronously. However, the
1599 special value <literal>local</> is available for transactions that
1600 wish to wait for local flush to disk, but not synchronous replication.
1603 This parameter can be changed at any time; the behavior for any
1604 one transaction is determined by the setting in effect when it
1605 commits. It is therefore possible, and useful, to have some
1606 transactions commit synchronously and others asynchronously.
1607 For example, to make a single multistatement transaction commit
1608 asynchronously when the default is the opposite, issue <command>SET
1609 LOCAL synchronous_commit TO OFF</> within the transaction.
1614 <varlistentry id="guc-wal-sync-method" xreflabel="wal_sync_method">
1615 <term><varname>wal_sync_method</varname> (<type>enum</type>)</term>
1617 <primary><varname>wal_sync_method</> configuration parameter</primary>
1621 Method used for forcing WAL updates out to disk.
1622 If <varname>fsync</varname> is off then this setting is irrelevant,
1623 since WAL file updates will not be forced out at all.
1624 Possible values are:
1629 <literal>open_datasync</> (write WAL files with <function>open()</> option <symbol>O_DSYNC</>)
1634 <literal>fdatasync</> (call <function>fdatasync()</> at each commit)
1639 <literal>fsync</> (call <function>fsync()</> at each commit)
1644 <literal>fsync_writethrough</> (call <function>fsync()</> at each commit, forcing write-through of any disk write cache)
1649 <literal>open_sync</> (write WAL files with <function>open()</> option <symbol>O_SYNC</>)
1654 The <literal>open_</>* options also use <literal>O_DIRECT</> if available.
1655 Not all of these choices are available on all platforms.
1656 The default is the first method in the above list that is supported
1657 by the platform, except that <literal>fdatasync</> is the default on
1658 Linux. The default is not necessarily ideal; it might be
1659 necessary to change this setting or other aspects of your system
1660 configuration in order to create a crash-safe configuration or
1661 achieve optimal performance.
1662 These aspects are discussed in <xref linkend="wal-reliability">.
1663 This parameter can only be set in the <filename>postgresql.conf</>
1664 file or on the server command line.
1669 <varlistentry id="guc-full-page-writes" xreflabel="full_page_writes">
1671 <primary><varname>full_page_writes</> configuration parameter</primary>
1673 <term><varname>full_page_writes</varname> (<type>boolean</type>)</term>
1676 When this parameter is on, the <productname>PostgreSQL</> server
1677 writes the entire content of each disk page to WAL during the
1678 first modification of that page after a checkpoint.
1679 This is needed because
1680 a page write that is in process during an operating system crash might
1681 be only partially completed, leading to an on-disk page
1682 that contains a mix of old and new data. The row-level change data
1683 normally stored in WAL will not be enough to completely restore
1684 such a page during post-crash recovery. Storing the full page image
1685 guarantees that the page can be correctly restored, but at the price
1686 of increasing the amount of data that must be written to WAL.
1687 (Because WAL replay always starts from a checkpoint, it is sufficient
1688 to do this during the first change of each page after a checkpoint.
1689 Therefore, one way to reduce the cost of full-page writes is to
1690 increase the checkpoint interval parameters.)
1694 Turning this parameter off speeds normal operation, but
1695 might lead to either unrecoverable data corruption, or silent
1696 data corruption, after a system failure. The risks are similar to turning off
1697 <varname>fsync</varname>, though smaller, and it should be turned off
1698 only based on the same circumstances recommended for that parameter.
1702 Turning off this parameter does not affect use of
1703 WAL archiving for point-in-time recovery (PITR)
1704 (see <xref linkend="continuous-archiving">).
1708 This parameter can only be set in the <filename>postgresql.conf</>
1709 file or on the server command line.
1710 The default is <literal>on</>.
1715 <varlistentry id="guc-wal-buffers" xreflabel="wal_buffers">
1716 <term><varname>wal_buffers</varname> (<type>integer</type>)</term>
1718 <primary><varname>wal_buffers</> configuration parameter</primary>
1722 The amount of shared memory used for WAL data that has not yet been
1723 written to disk. The default setting of -1 selects a size equal to
1724 1/32nd (about 3%) of <xref linkend="guc-shared-buffers">, but not less
1725 than <literal>64kB</literal> nor more than the size of one WAL
1726 segment, typically <literal>16MB</literal>. This value can be set
1727 manually if the automatic choice is too large or too small,
1728 but any positive value less than <literal>32kB</literal> will be
1729 treated as <literal>32kB</literal>.
1730 This parameter can only be set at server start.
1734 The contents of the WAL buffers are written out to disk at every
1735 transaction commit, so extremely large values are unlikely to
1736 provide a significant benefit. However, setting this value to at
1737 least a few megabytes can improve write performance on a busy
1738 server where many clients are committing at once. The auto-tuning
1739 selected by the default setting of -1 should give reasonable
1740 results in most cases.
1744 Increasing this parameter might cause <productname>PostgreSQL</>
1745 to request more <systemitem class="osname">System V</> shared
1746 memory than your operating system's default configuration
1747 allows. See <xref linkend="sysvipc"> for information on how to
1748 adjust those parameters, if necessary.
1753 <varlistentry id="guc-wal-writer-delay" xreflabel="wal_writer_delay">
1754 <term><varname>wal_writer_delay</varname> (<type>integer</type>)</term>
1756 <primary><varname>wal_writer_delay</> configuration parameter</primary>
1760 Specifies the delay between activity rounds for the WAL writer.
1761 In each round the writer will flush WAL to disk. It then sleeps for
1762 <varname>wal_writer_delay</> milliseconds, and repeats. The default
1763 value is 200 milliseconds (<literal>200ms</>). Note that on many
1764 systems, the effective resolution of sleep delays is 10 milliseconds;
1765 setting <varname>wal_writer_delay</> to a value that is not a multiple
1766 of 10 might have the same results as setting it to the next higher
1767 multiple of 10. This parameter can only be set in the
1768 <filename>postgresql.conf</> file or on the server command line.
1773 <varlistentry id="guc-commit-delay" xreflabel="commit_delay">
1774 <term><varname>commit_delay</varname> (<type>integer</type>)</term>
1776 <primary><varname>commit_delay</> configuration parameter</primary>
1780 When the commit data for a transaction is flushed to disk, any
1781 additional commits ready at that time are also flushed out.
1782 <varname>commit_delay</varname> adds a time delay, set in
1783 microseconds, before a transaction attempts to
1784 flush the WAL buffer out to disk. A nonzero delay can allow more
1785 transactions to be committed with only one flush operation, if
1786 system load is high enough that additional transactions become
1787 ready to commit within the given interval. But the delay is
1788 just wasted if no other transactions become ready to
1789 commit. Therefore, the delay is only performed if at least
1790 <varname>commit_siblings</varname> other transactions are
1791 active at the instant that a server process has written its
1793 The default <varname>commit_delay</> is zero (no delay).
1794 Since all pending commit data will be written at every flush
1795 regardless of this setting, it is rare that adding delay
1796 by increasing this parameter will actually improve performance.
1801 <varlistentry id="guc-commit-siblings" xreflabel="commit_siblings">
1802 <term><varname>commit_siblings</varname> (<type>integer</type>)</term>
1804 <primary><varname>commit_siblings</> configuration parameter</primary>
1808 Minimum number of concurrent open transactions to require
1809 before performing the <varname>commit_delay</> delay. A larger
1810 value makes it more probable that at least one other
1811 transaction will become ready to commit during the delay
1812 interval. The default is five transactions.
1819 <sect2 id="runtime-config-wal-checkpoints">
1820 <title>Checkpoints</title>
1823 <varlistentry id="guc-checkpoint-segments" xreflabel="checkpoint_segments">
1824 <term><varname>checkpoint_segments</varname> (<type>integer</type>)</term>
1826 <primary><varname>checkpoint_segments</> configuration parameter</primary>
1830 Maximum number of log file segments between automatic WAL
1831 checkpoints (each segment is normally 16 megabytes). The default
1832 is three segments. Increasing this parameter can increase the
1833 amount of time needed for crash recovery.
1834 This parameter can only be set in the <filename>postgresql.conf</>
1835 file or on the server command line.
1840 <varlistentry id="guc-checkpoint-timeout" xreflabel="checkpoint_timeout">
1841 <term><varname>checkpoint_timeout</varname> (<type>integer</type>)</term>
1843 <primary><varname>checkpoint_timeout</> configuration parameter</primary>
1847 Maximum time between automatic WAL checkpoints, in
1848 seconds. The default is five minutes (<literal>5min</>).
1849 Increasing this parameter can increase the amount of time needed
1851 This parameter can only be set in the <filename>postgresql.conf</>
1852 file or on the server command line.
1857 <varlistentry id="guc-checkpoint-completion-target" xreflabel="checkpoint_completion_target">
1858 <term><varname>checkpoint_completion_target</varname> (<type>floating point</type>)</term>
1860 <primary><varname>checkpoint_completion_target</> configuration parameter</primary>
1864 Specifies the target of checkpoint completion, as a fraction of
1865 total time between checkpoints. The default is 0.5.
1867 This parameter can only be set in the <filename>postgresql.conf</>
1868 file or on the server command line.
1873 <varlistentry id="guc-checkpoint-warning" xreflabel="checkpoint_warning">
1874 <term><varname>checkpoint_warning</varname> (<type>integer</type>)</term>
1876 <primary><varname>checkpoint_warning</> configuration parameter</primary>
1880 Write a message to the server log if checkpoints caused by
1881 the filling of checkpoint segment files happen closer together
1882 than this many seconds (which suggests that
1883 <varname>checkpoint_segments</> ought to be raised). The default is
1884 30 seconds (<literal>30s</>). Zero disables the warning.
1885 This parameter can only be set in the <filename>postgresql.conf</>
1886 file or on the server command line.
1893 <sect2 id="runtime-config-wal-archiving">
1894 <title>Archiving</title>
1897 <varlistentry id="guc-archive-mode" xreflabel="archive_mode">
1898 <term><varname>archive_mode</varname> (<type>boolean</type>)</term>
1900 <primary><varname>archive_mode</> configuration parameter</primary>
1904 When <varname>archive_mode</> is enabled, completed WAL segments
1905 are sent to archive storage by setting
1906 <xref linkend="guc-archive-command">.
1907 <varname>archive_mode</> and <varname>archive_command</> are
1908 separate variables so that <varname>archive_command</> can be
1909 changed without leaving archiving mode.
1910 This parameter can only be set at server start.
1911 <varname>archive_mode</> cannot be enabled when
1912 <varname>wal_level</> is set to <literal>minimal</>.
1917 <varlistentry id="guc-archive-command" xreflabel="archive_command">
1918 <term><varname>archive_command</varname> (<type>string</type>)</term>
1920 <primary><varname>archive_command</> configuration parameter</primary>
1924 The shell command to execute to archive a completed WAL file
1925 segment. Any <literal>%p</> in the string is
1926 replaced by the path name of the file to archive, and any
1927 <literal>%f</> is replaced by only the file name.
1928 (The path name is relative to the working directory of the server,
1929 i.e., the cluster's data directory.)
1930 Use <literal>%%</> to embed an actual <literal>%</> character in the
1931 command. It is important for the command to return a zero
1932 exit status only if it succeeds. For more information see
1933 <xref linkend="backup-archiving-wal">.
1936 This parameter can only be set in the <filename>postgresql.conf</>
1937 file or on the server command line. It is ignored unless
1938 <varname>archive_mode</> was enabled at server start.
1939 If <varname>archive_command</> is an empty string (the default) while
1940 <varname>archive_mode</> is enabled, WAL archiving is temporarily
1941 disabled, but the server continues to accumulate WAL segment files in
1942 the expectation that a command will soon be provided. Setting
1943 <varname>archive_command</> to a command that does nothing but
1944 return true, e.g. <literal>/bin/true</> (<literal>REM</> on
1945 Windows), effectively disables
1946 archiving, but also breaks the chain of WAL files needed for
1947 archive recovery, so it should only be used in unusual circumstances.
1952 <varlistentry id="guc-archive-timeout" xreflabel="archive_timeout">
1953 <term><varname>archive_timeout</varname> (<type>integer</type>)</term>
1955 <primary><varname>archive_timeout</> configuration parameter</primary>
1959 The <xref linkend="guc-archive-command"> is only invoked for
1960 completed WAL segments. Hence, if your server generates little WAL
1961 traffic (or has slack periods where it does so), there could be a
1962 long delay between the completion of a transaction and its safe
1963 recording in archive storage. To limit how old unarchived
1964 data can be, you can set <varname>archive_timeout</> to force the
1965 server to switch to a new WAL segment file periodically. When this
1966 parameter is greater than zero, the server will switch to a new
1967 segment file whenever this many seconds have elapsed since the last
1968 segment file switch, and there has been any database activity,
1969 including a single checkpoint. (Increasing
1970 <varname>checkpoint_timeout</> will reduce unnecessary
1971 checkpoints on an idle system.)
1972 Note that archived files that are closed early
1973 due to a forced switch are still the same length as completely full
1974 files. Therefore, it is unwise to use a very short
1975 <varname>archive_timeout</> — it will bloat your archive
1976 storage. <varname>archive_timeout</> settings of a minute or so are
1977 usually reasonable. You should consider using streaming replication,
1978 instead of archiving, if you want data to be copied off the master
1979 server more quickly than that.
1980 This parameter can only be set in the
1981 <filename>postgresql.conf</> file or on the server command line.
1991 <sect1 id="runtime-config-replication">
1992 <title>Replication</title>
1995 These settings control the behavior of the built-in
1996 <firstterm>streaming replication</> feature (see
1997 <xref linkend="streaming-replication">). Servers will be either a
1998 Master or a Standby server. Masters can send data, while Standby(s)
1999 are always receivers of replicated data. When cascading replication
2000 (see <xref linkend="cascading-replication">) is used, Standby server(s)
2001 can also be senders, as well as receivers.
2002 Parameters are mainly for Sending and Standby servers, though some
2003 parameters have meaning only on the Master server. Settings may vary
2004 across the cluster without problems if that is required.
2007 <sect2 id="runtime-config-replication-sender">
2008 <title>Sending Server(s)</title>
2011 These parameters can be set on any server that is
2012 to send replication data to one or more standby servers.
2013 The master is always a sending server, so these parameters must
2014 always be set on the master.
2015 The role and meaning of these parameters does not change after a
2016 standby becomes the master.
2020 <varlistentry id="guc-max-wal-senders" xreflabel="max_wal_senders">
2021 <term><varname>max_wal_senders</varname> (<type>integer</type>)</term>
2023 <primary><varname>max_wal_senders</> configuration parameter</primary>
2027 Specifies the maximum number of concurrent connections from standby
2028 servers or streaming base backup clients (i.e., the maximum number of
2029 simultaneously running WAL sender
2030 processes). The default is zero. This parameter can only be set at
2031 server start. <varname>wal_level</> must be set to <literal>archive</>
2032 or <literal>hot_standby</> to allow connections from standby servers.
2037 <varlistentry id="guc-wal-keep-segments" xreflabel="wal_keep_segments">
2038 <term><varname>wal_keep_segments</varname> (<type>integer</type>)</term>
2040 <primary><varname>wal_keep_segments</> configuration parameter</primary>
2044 Specifies the minimum number of past log file segments kept in the
2045 <filename>pg_xlog</>
2046 directory, in case a standby server needs to fetch them for streaming
2047 replication. Each segment is normally 16 megabytes. If a standby
2048 server connected to the sending server falls behind by more than
2049 <varname>wal_keep_segments</> segments, the sending server might remove
2050 a WAL segment still needed by the standby, in which case the
2051 replication connection will be terminated. Downstream connections
2052 will also eventually fail as a result. (However, the standby
2053 server can recover by fetching the segment from archive, if WAL
2054 archiving is in use.)
2058 This sets only the minimum number of segments retained in
2059 <filename>pg_xlog</>; the system might need to retain more segments
2060 for WAL archival or to recover from a checkpoint. If
2061 <varname>wal_keep_segments</> is zero (the default), the system
2062 doesn't keep any extra segments for standby purposes, so the number
2063 of old WAL segments available to standby servers is a function of
2064 the location of the previous checkpoint and status of WAL
2066 This parameter can only be set in the
2067 <filename>postgresql.conf</> file or on the server command line.
2072 <varlistentry id="guc-replication-timeout" xreflabel="replication_timeout">
2073 <term><varname>replication_timeout</varname> (<type>integer</type>)</term>
2075 <primary><varname>replication_timeout</> configuration parameter</primary>
2079 Terminate replication connections that are inactive longer
2080 than the specified number of milliseconds. This is useful for
2081 the sending server to detect a standby crash or network outage.
2082 A value of zero disables the timeout mechanism. This parameter
2084 the <filename>postgresql.conf</> file or on the server command line.
2085 The default value is 60 seconds.
2088 To prevent connections from being terminated prematurely,
2089 <xref linkend="guc-wal-receiver-status-interval">
2090 must be enabled on the standby, and its value must be less than the
2091 value of <varname>replication_timeout</>.
2099 <sect2 id="runtime-config-replication-master">
2100 <title>Master Server</title>
2103 These parameters can be set on the master/primary server that is
2104 to send replication data to one or more standby servers.
2105 Note that in addition to these parameters,
2106 <xref linkend="guc-wal-level"> must be set appropriately on the master
2107 server, and optionally WAL archiving can be enabled as
2108 well (see <xref linkend="runtime-config-wal-archiving">).
2109 The values of these parameters on standby servers are irrelevant,
2110 although you may wish to set them there in preparation for the
2111 possibility of a standby becoming the master.
2116 <varlistentry id="guc-synchronous-standby-names" xreflabel="synchronous_standby_names">
2117 <term><varname>synchronous_standby_names</varname> (<type>string</type>)</term>
2119 <primary><varname>synchronous_standby_names</> configuration parameter</primary>
2123 Specifies a comma-separated list of standby names that can support
2124 <firstterm>synchronous replication</>, as described in
2125 <xref linkend="synchronous-replication">.
2126 At any one time there will be at most one active synchronous standby;
2127 transactions waiting for commit will be allowed to proceed after
2128 this standby server confirms receipt of their data.
2129 The synchronous standby will be the first standby named in this list
2130 that is both currently connected and streaming data in real-time
2131 (as shown by a state of <literal>streaming</literal> in the
2132 <link linkend="monitoring-stats-views-table">
2133 <literal>pg_stat_replication</></link> view).
2134 Other standby servers appearing later in this list represent potential
2135 synchronous standbys.
2136 If the current synchronous standby disconnects for whatever reason,
2137 it will be replaced immediately with the next-highest-priority standby.
2138 Specifying more than one standby name can allow very high availability.
2141 The name of a standby server for this purpose is the
2142 <varname>application_name</> setting of the standby, as set in the
2143 <varname>primary_conninfo</> of the standby's walreceiver. There is
2144 no mechanism to enforce uniqueness. In case of duplicates one of the
2145 matching standbys will be chosen to be the synchronous standby, though
2146 exactly which one is indeterminate.
2147 The special entry <literal>*</> matches any
2148 <varname>application_name</>, including the default application name
2149 of <literal>walreceiver</>.
2152 If no synchronous standby names are specified here, then synchronous
2153 replication is not enabled and transaction commits will not wait for
2154 replication. This is the default configuration. Even when
2155 synchronous replication is enabled, individual transactions can be
2156 configured not to wait for replication by setting the
2157 <xref linkend="guc-synchronous-commit"> parameter to
2158 <literal>local</> or <literal>off</>.
2161 This parameter can only be set in the <filename>postgresql.conf</>
2162 file or on the server command line.
2167 <varlistentry id="guc-vacuum-defer-cleanup-age" xreflabel="vacuum_defer_cleanup_age">
2168 <term><varname>vacuum_defer_cleanup_age</varname> (<type>integer</type>)</term>
2170 <primary><varname>vacuum_defer_cleanup_age</> configuration parameter</primary>
2174 Specifies the number of transactions by which <command>VACUUM</> and
2175 <acronym>HOT</> updates will defer cleanup of dead row versions. The
2176 default is zero transactions, meaning that dead row versions can be
2177 removed as soon as possible, that is, as soon as they are no longer
2178 visible to any open transaction. You may wish to set this to a
2179 non-zero value on a primary server that is supporting hot standby
2180 servers, as described in <xref linkend="hot-standby">. This allows
2181 more time for queries on the standby to complete without incurring
2182 conflicts due to early cleanup of rows. However, since the value
2183 is measured in terms of number of write transactions occurring on the
2184 primary server, it is difficult to predict just how much additional
2185 grace time will be made available to standby queries.
2186 This parameter can only be set in the <filename>postgresql.conf</>
2187 file or on the server command line.
2190 You should also consider setting <varname>hot_standby_feedback</>
2191 on standby server(s) as an alternative to using this parameter.
2199 <sect2 id="runtime-config-replication-standby">
2200 <title>Standby Servers</title>
2203 These settings control the behavior of a standby server that is
2204 to receive replication data. Their values on the master server
2210 <varlistentry id="guc-hot-standby" xreflabel="hot_standby">
2211 <term><varname>hot_standby</varname> (<type>boolean</type>)</term>
2213 <primary><varname>hot_standby</> configuration parameter</primary>
2217 Specifies whether or not you can connect and run queries during
2218 recovery, as described in <xref linkend="hot-standby">.
2219 The default value is <literal>off</literal>.
2220 This parameter can only be set at server start. It only has effect
2221 during archive recovery or in standby mode.
2226 <varlistentry id="guc-max-standby-archive-delay" xreflabel="max_standby_archive_delay">
2227 <term><varname>max_standby_archive_delay</varname> (<type>integer</type>)</term>
2229 <primary><varname>max_standby_archive_delay</> configuration parameter</primary>
2233 When Hot Standby is active, this parameter determines how long the
2234 standby server should wait before canceling standby queries that
2235 conflict with about-to-be-applied WAL entries, as described in
2236 <xref linkend="hot-standby-conflict">.
2237 <varname>max_standby_archive_delay</> applies when WAL data is
2238 being read from WAL archive (and is therefore not current).
2239 The default is 30 seconds. Units are milliseconds if not specified.
2240 A value of -1 allows the standby to wait forever for conflicting
2241 queries to complete.
2242 This parameter can only be set in the <filename>postgresql.conf</>
2243 file or on the server command line.
2246 Note that <varname>max_standby_archive_delay</> is not the same as the
2247 maximum length of time a query can run before cancellation; rather it
2248 is the maximum total time allowed to apply any one WAL segment's data.
2249 Thus, if one query has resulted in significant delay earlier in the
2250 WAL segment, subsequent conflicting queries will have much less grace
2256 <varlistentry id="guc-max-standby-streaming-delay" xreflabel="max_standby_streaming_delay">
2257 <term><varname>max_standby_streaming_delay</varname> (<type>integer</type>)</term>
2259 <primary><varname>max_standby_streaming_delay</> configuration parameter</primary>
2263 When Hot Standby is active, this parameter determines how long the
2264 standby server should wait before canceling standby queries that
2265 conflict with about-to-be-applied WAL entries, as described in
2266 <xref linkend="hot-standby-conflict">.
2267 <varname>max_standby_streaming_delay</> applies when WAL data is
2268 being received via streaming replication.
2269 The default is 30 seconds. Units are milliseconds if not specified.
2270 A value of -1 allows the standby to wait forever for conflicting
2271 queries to complete.
2272 This parameter can only be set in the <filename>postgresql.conf</>
2273 file or on the server command line.
2276 Note that <varname>max_standby_streaming_delay</> is not the same as
2277 the maximum length of time a query can run before cancellation; rather
2278 it is the maximum total time allowed to apply WAL data once it has
2279 been received from the primary server. Thus, if one query has
2280 resulted in significant delay, subsequent conflicting queries will
2281 have much less grace time until the standby server has caught up
2287 <varlistentry id="guc-wal-receiver-status-interval" xreflabel="wal_receiver_status_interval">
2288 <term><varname>wal_receiver_status_interval</varname> (<type>integer</type>)</term>
2290 <primary><varname>wal_receiver_status_interval</> configuration parameter</primary>
2294 Specifies the minimum frequency for the WAL receiver
2295 process on the standby to send information about replication progress
2296 to the primary or upstream standby, where it can be seen using the
2297 <link linkend="monitoring-stats-views-table">
2298 <literal>pg_stat_replication</></link> view. The standby will report
2299 the last transaction log position it has written, the last position it
2300 has flushed to disk, and the last position it has applied.
2302 value is the maximum interval, in seconds, between reports. Updates are
2303 sent each time the write or flush positions change, or at least as
2304 often as specified by this parameter. Thus, the apply position may
2305 lag slightly behind the true position. Setting this parameter to zero
2306 disables status updates completely. This parameter can only be set in
2307 the <filename>postgresql.conf</> file or on the server command line.
2308 The default value is 10 seconds.
2311 When <xref linkend="guc-replication-timeout"> is enabled on a sending server,
2312 <varname>wal_receiver_status_interval</> must be enabled, and its value
2313 must be less than the value of <varname>replication_timeout</>.
2318 <varlistentry id="guc-hot-standby-feedback" xreflabel="hot_standby">
2319 <term><varname>hot_standby_feedback</varname> (<type>boolean</type>)</term>
2321 <primary><varname>hot_standby_feedback</> configuration parameter</primary>
2325 Specifies whether or not a hot standby will send feedback to the primary
2327 about queries currently executing on the standby. This parameter can
2328 be used to eliminate query cancels caused by cleanup records, but
2329 can cause database bloat on the primary for some workloads.
2330 Feedback messages will not be sent more frequently than once per
2331 <varname>wal_receiver_status_interval</>. The default value is
2332 <literal>off</literal>. This parameter can only be set in the
2333 <filename>postgresql.conf</> file or on the server command line.
2336 If cascaded replication is in use the feedback is passed upstream
2337 until it eventually reaches the primary. Standbys make no other use
2338 of feedback they receive other than to pass upstream.
2347 <sect1 id="runtime-config-query">
2348 <title>Query Planning</title>
2350 <sect2 id="runtime-config-query-enable">
2351 <title>Planner Method Configuration</title>
2354 These configuration parameters provide a crude method of
2355 influencing the query plans chosen by the query optimizer. If
2356 the default plan chosen by the optimizer for a particular query
2357 is not optimal, a <emphasis>temporary</> solution is to use one
2358 of these configuration parameters to force the optimizer to
2359 choose a different plan.
2360 Better ways to improve the quality of the
2361 plans chosen by the optimizer include adjusting the planer cost
2362 constants (see <xref linkend="runtime-config-query-constants">),
2363 running <xref linkend="sql-analyze"> manually, increasing
2364 the value of the <xref
2365 linkend="guc-default-statistics-target"> configuration parameter,
2366 and increasing the amount of statistics collected for
2367 specific columns using <command>ALTER TABLE SET
2368 STATISTICS</command>.
2372 <varlistentry id="guc-enable-bitmapscan" xreflabel="enable_bitmapscan">
2373 <term><varname>enable_bitmapscan</varname> (<type>boolean</type>)</term>
2375 <primary>bitmap scan</primary>
2378 <primary><varname>enable_bitmapscan</> configuration parameter</primary>
2382 Enables or disables the query planner's use of bitmap-scan plan
2383 types. The default is <literal>on</>.
2388 <varlistentry id="guc-enable-hashagg" xreflabel="enable_hashagg">
2389 <term><varname>enable_hashagg</varname> (<type>boolean</type>)</term>
2391 <primary><varname>enable_hashagg</> configuration parameter</primary>
2395 Enables or disables the query planner's use of hashed
2396 aggregation plan types. The default is <literal>on</>.
2401 <varlistentry id="guc-enable-hashjoin" xreflabel="enable_hashjoin">
2402 <term><varname>enable_hashjoin</varname> (<type>boolean</type>)</term>
2404 <primary><varname>enable_hashjoin</> configuration parameter</primary>
2408 Enables or disables the query planner's use of hash-join plan
2409 types. The default is <literal>on</>.
2414 <varlistentry id="guc-enable-indexscan" xreflabel="enable_indexscan">
2415 <term><varname>enable_indexscan</varname> (<type>boolean</type>)</term>
2417 <primary>index scan</primary>
2420 <primary><varname>enable_indexscan</> configuration parameter</primary>
2424 Enables or disables the query planner's use of index-scan plan
2425 types. The default is <literal>on</>.
2430 <varlistentry id="guc-enable-indexonlyscan" xreflabel="enable_indexonlyscan">
2431 <term><varname>enable_indexonlyscan</varname> (<type>boolean</type>)</term>
2433 <primary>index-only scan</primary>
2436 <primary><varname>enable_indexonlyscan</> configuration parameter</primary>
2440 Enables or disables the query planner's use of index-only-scan plan
2441 types. The default is <literal>on</>.
2446 <varlistentry id="guc-enable-material" xreflabel="enable_material">
2447 <term><varname>enable_material</varname> (<type>boolean</type>)</term>
2449 <primary><varname>enable_material</> configuration parameter</primary>
2453 Enables or disables the query planner's use of materialization.
2454 It is impossible to suppress materialization entirely,
2455 but turning this variable off prevents the planner from inserting
2456 materialize nodes except in cases where it is required for correctness.
2457 The default is <literal>on</>.
2462 <varlistentry id="guc-enable-mergejoin" xreflabel="enable_mergejoin">
2463 <term><varname>enable_mergejoin</varname> (<type>boolean</type>)</term>
2465 <primary><varname>enable_mergejoin</> configuration parameter</primary>
2469 Enables or disables the query planner's use of merge-join plan
2470 types. The default is <literal>on</>.
2475 <varlistentry id="guc-enable-nestloop" xreflabel="enable_nestloop">
2476 <term><varname>enable_nestloop</varname> (<type>boolean</type>)</term>
2478 <primary><varname>enable_nestloop</> configuration parameter</primary>
2482 Enables or disables the query planner's use of nested-loop join
2483 plans. It is impossible to suppress nested-loop joins entirely,
2484 but turning this variable off discourages the planner from using
2485 one if there are other methods available. The default is
2491 <varlistentry id="guc-enable-seqscan" xreflabel="enable_seqscan">
2492 <term><varname>enable_seqscan</varname> (<type>boolean</type>)</term>
2494 <primary>sequential scan</primary>
2497 <primary><varname>enable_seqscan</> configuration parameter</primary>
2501 Enables or disables the query planner's use of sequential scan
2502 plan types. It is impossible to suppress sequential scans
2503 entirely, but turning this variable off discourages the planner
2504 from using one if there are other methods available. The
2505 default is <literal>on</>.
2510 <varlistentry id="guc-enable-sort" xreflabel="enable_sort">
2511 <term><varname>enable_sort</varname> (<type>boolean</type>)</term>
2513 <primary><varname>enable_sort</> configuration parameter</primary>
2517 Enables or disables the query planner's use of explicit sort
2518 steps. It is impossible to suppress explicit sorts entirely,
2519 but turning this variable off discourages the planner from
2520 using one if there are other methods available. The default
2526 <varlistentry id="guc-enable-tidscan" xreflabel="enable_tidscan">
2527 <term><varname>enable_tidscan</varname> (<type>boolean</type>)</term>
2529 <primary><varname>enable_tidscan</> configuration parameter</primary>
2533 Enables or disables the query planner's use of <acronym>TID</>
2534 scan plan types. The default is <literal>on</>.
2541 <sect2 id="runtime-config-query-constants">
2542 <title>Planner Cost Constants</title>
2545 The <firstterm>cost</> variables described in this section are measured
2546 on an arbitrary scale. Only their relative values matter, hence
2547 scaling them all up or down by the same factor will result in no change
2548 in the planner's choices. By default, these cost variables are based on
2549 the cost of sequential page fetches; that is,
2550 <varname>seq_page_cost</> is conventionally set to <literal>1.0</>
2551 and the other cost variables are set with reference to that. But
2552 you can use a different scale if you prefer, such as actual execution
2553 times in milliseconds on a particular machine.
2558 Unfortunately, there is no well-defined method for determining ideal
2559 values for the cost variables. They are best treated as averages over
2560 the entire mix of queries that a particular installation will receive. This
2561 means that changing them on the basis of just a few experiments is very
2568 <varlistentry id="guc-seq-page-cost" xreflabel="seq_page_cost">
2569 <term><varname>seq_page_cost</varname> (<type>floating point</type>)</term>
2571 <primary><varname>seq_page_cost</> configuration parameter</primary>
2575 Sets the planner's estimate of the cost of a disk page fetch
2576 that is part of a series of sequential fetches. The default is 1.0.
2577 This value can be overridden for tables and indexes in a particular
2578 tablespace by setting the tablespace parameter of the same name
2579 (see <xref linkend="sql-altertablespace">).
2584 <varlistentry id="guc-random-page-cost" xreflabel="random_page_cost">
2585 <term><varname>random_page_cost</varname> (<type>floating point</type>)</term>
2587 <primary><varname>random_page_cost</> configuration parameter</primary>
2591 Sets the planner's estimate of the cost of a
2592 non-sequentially-fetched disk page. The default is 4.0.
2593 This value can be overridden for tables and indexes in a particular
2594 tablespace by setting the tablespace parameter of the same name
2595 (see <xref linkend="sql-altertablespace">).
2599 Reducing this value relative to <varname>seq_page_cost</>
2600 will cause the system to prefer index scans; raising it will
2601 make index scans look relatively more expensive. You can raise
2602 or lower both values together to change the importance of disk I/O
2603 costs relative to CPU costs, which are described by the following
2609 Although the system will let you set <varname>random_page_cost</> to
2610 less than <varname>seq_page_cost</>, it is not physically sensible
2611 to do so. However, setting them equal makes sense if the database
2612 is entirely cached in RAM, since in that case there is no penalty
2613 for touching pages out of sequence. Also, in a heavily-cached
2614 database you should lower both values relative to the CPU parameters,
2615 since the cost of fetching a page already in RAM is much smaller
2616 than it would normally be.
2622 <varlistentry id="guc-cpu-tuple-cost" xreflabel="cpu_tuple_cost">
2623 <term><varname>cpu_tuple_cost</varname> (<type>floating point</type>)</term>
2625 <primary><varname>cpu_tuple_cost</> configuration parameter</primary>
2629 Sets the planner's estimate of the cost of processing
2630 each row during a query.
2631 The default is 0.01.
2636 <varlistentry id="guc-cpu-index-tuple-cost" xreflabel="cpu_index_tuple_cost">
2637 <term><varname>cpu_index_tuple_cost</varname> (<type>floating point</type>)</term>
2639 <primary><varname>cpu_index_tuple_cost</> configuration parameter</primary>
2643 Sets the planner's estimate of the cost of processing
2644 each index entry during an index scan.
2645 The default is 0.005.
2650 <varlistentry id="guc-cpu-operator-cost" xreflabel="cpu_operator_cost">
2651 <term><varname>cpu_operator_cost</varname> (<type>floating point</type>)</term>
2653 <primary><varname>cpu_operator_cost</> configuration parameter</primary>
2657 Sets the planner's estimate of the cost of processing each
2658 operator or function executed during a query.
2659 The default is 0.0025.
2664 <varlistentry id="guc-effective-cache-size" xreflabel="effective_cache_size">
2665 <term><varname>effective_cache_size</varname> (<type>integer</type>)</term>
2667 <primary><varname>effective_cache_size</> configuration parameter</primary>
2671 Sets the planner's assumption about the effective size of the
2672 disk cache that is available to a single query. This is
2673 factored into estimates of the cost of using an index; a
2674 higher value makes it more likely index scans will be used, a
2675 lower value makes it more likely sequential scans will be
2676 used. When setting this parameter you should consider both
2677 <productname>PostgreSQL</productname>'s shared buffers and the
2678 portion of the kernel's disk cache that will be used for
2679 <productname>PostgreSQL</productname> data files. Also, take
2680 into account the expected number of concurrent queries on different
2681 tables, since they will have to share the available
2682 space. This parameter has no effect on the size of shared
2683 memory allocated by <productname>PostgreSQL</productname>, nor
2684 does it reserve kernel disk cache; it is used only for estimation
2685 purposes. The system also does not assume data remains in
2686 the disk cache between queries. The default is 128 megabytes
2687 (<literal>128MB</>).
2695 <sect2 id="runtime-config-query-geqo">
2696 <title>Genetic Query Optimizer</title>
2699 The genetic query optimizer (GEQO) is an algorithm that does query
2700 planning using heuristic searching. This reduces planning time for
2701 complex queries (those joining many relations), at the cost of producing
2702 plans that are sometimes inferior to those found by the normal
2703 exhaustive-search algorithm. Also, GEQO's searching is randomized and
2704 therefore its plans may vary nondeterministically.
2705 For more information see <xref linkend="geqo">.
2710 <varlistentry id="guc-geqo" xreflabel="geqo">
2712 <primary>genetic query optimization</primary>
2715 <primary>GEQO</primary>
2716 <see>genetic query optimization</see>
2719 <primary><varname>geqo</> configuration parameter</primary>
2721 <term><varname>geqo</varname> (<type>boolean</type>)</term>
2724 Enables or disables genetic query optimization.
2725 This is on by default. It is usually best not to turn it off in
2726 production; the <varname>geqo_threshold</varname> variable provides
2727 more granular control of GEQO.
2732 <varlistentry id="guc-geqo-threshold" xreflabel="geqo_threshold">
2733 <term><varname>geqo_threshold</varname> (<type>integer</type>)</term>
2735 <primary><varname>geqo_threshold</> configuration parameter</primary>
2739 Use genetic query optimization to plan queries with at least
2740 this many <literal>FROM</> items involved. (Note that a
2741 <literal>FULL OUTER JOIN</> construct counts as only one <literal>FROM</>
2742 item.) The default is 12. For simpler queries it is usually best
2743 to use the deterministic, exhaustive planner, but for queries with
2744 many tables the deterministic planner takes too long, often
2745 longer than the penalty of executing a suboptimal plan.
2750 <varlistentry id="guc-geqo-effort" xreflabel="geqo_effort">
2751 <term><varname>geqo_effort</varname>
2752 (<type>integer</type>)</term>
2754 <primary><varname>geqo_effort</> configuration parameter</primary>
2758 Controls the trade-off between planning time and query plan
2759 quality in GEQO. This variable must be an integer in the
2760 range from 1 to 10. The default value is five. Larger values
2761 increase the time spent doing query planning, but also
2762 increase the likelihood that an efficient query plan will be
2767 <varname>geqo_effort</varname> doesn't actually do anything
2768 directly; it is only used to compute the default values for
2769 the other variables that influence GEQO behavior (described
2770 below). If you prefer, you can set the other parameters by
2776 <varlistentry id="guc-geqo-pool-size" xreflabel="geqo_pool_size">
2777 <term><varname>geqo_pool_size</varname> (<type>integer</type>)</term>
2779 <primary><varname>geqo_pool_size</> configuration parameter</primary>
2783 Controls the pool size used by GEQO, that is the
2784 number of individuals in the genetic population. It must be
2785 at least two, and useful values are typically 100 to 1000. If
2786 it is set to zero (the default setting) then a suitable
2787 value is chosen based on <varname>geqo_effort</varname> and
2788 the number of tables in the query.
2793 <varlistentry id="guc-geqo-generations" xreflabel="geqo_generations">
2794 <term><varname>geqo_generations</varname> (<type>integer</type>)</term>
2796 <primary><varname>geqo_generations</> configuration parameter</primary>
2800 Controls the number of generations used by GEQO, that is
2801 the number of iterations of the algorithm. It must
2802 be at least one, and useful values are in the same range as
2803 the pool size. If it is set to zero (the default setting)
2804 then a suitable value is chosen based on
2805 <varname>geqo_pool_size</varname>.
2810 <varlistentry id="guc-geqo-selection-bias" xreflabel="geqo_selection_bias">
2811 <term><varname>geqo_selection_bias</varname> (<type>floating point</type>)</term>
2813 <primary><varname>geqo_selection_bias</> configuration parameter</primary>
2817 Controls the selection bias used by GEQO. The selection bias
2818 is the selective pressure within the population. Values can be
2819 from 1.50 to 2.00; the latter is the default.
2824 <varlistentry id="guc-geqo-seed" xreflabel="geqo_seed">
2825 <term><varname>geqo_seed</varname> (<type>floating point</type>)</term>
2827 <primary><varname>geqo_seed</> configuration parameter</primary>
2831 Controls the initial value of the random number generator used
2832 by GEQO to select random paths through the join order search space.
2833 The value can range from zero (the default) to one. Varying the
2834 value changes the set of join paths explored, and may result in a
2835 better or worse best path being found.
2842 <sect2 id="runtime-config-query-other">
2843 <title>Other Planner Options</title>
2847 <varlistentry id="guc-default-statistics-target" xreflabel="default_statistics_target">
2848 <term><varname>default_statistics_target</varname> (<type>integer</type>)</term>
2850 <primary><varname>default_statistics_target</> configuration parameter</primary>
2854 Sets the default statistics target for table columns without
2855 a column-specific target set via <command>ALTER TABLE
2856 SET STATISTICS</>. Larger values increase the time needed to
2857 do <command>ANALYZE</>, but might improve the quality of the
2858 planner's estimates. The default is 100. For more information
2859 on the use of statistics by the <productname>PostgreSQL</>
2860 query planner, refer to <xref linkend="planner-stats">.
2865 <varlistentry id="guc-constraint-exclusion" xreflabel="constraint_exclusion">
2866 <term><varname>constraint_exclusion</varname> (<type>enum</type>)</term>
2868 <primary>constraint exclusion</primary>
2871 <primary><varname>constraint_exclusion</> configuration parameter</primary>
2875 Controls the query planner's use of table constraints to
2877 The allowed values of <varname>constraint_exclusion</> are
2878 <literal>on</> (examine constraints for all tables),
2879 <literal>off</> (never examine constraints), and
2880 <literal>partition</> (examine constraints only for inheritance child
2881 tables and <literal>UNION ALL</> subqueries).
2882 <literal>partition</> is the default setting.
2883 It is often used with inheritance and partitioned tables to
2884 improve performance.
2888 When this parameter allows it for a particular table, the planner
2889 compares query conditions with the table's <literal>CHECK</>
2890 constraints, and omits scanning tables for which the conditions
2891 contradict the constraints. For example:
2894 CREATE TABLE parent(key integer, ...);
2895 CREATE TABLE child1000(check (key between 1000 and 1999)) INHERITS(parent);
2896 CREATE TABLE child2000(check (key between 2000 and 2999)) INHERITS(parent);
2898 SELECT * FROM parent WHERE key = 2400;
2901 With constraint exclusion enabled, this <command>SELECT</>
2902 will not scan <structname>child1000</> at all, improving performance.
2906 Currently, constraint exclusion is enabled by default
2907 only for cases that are often used to implement table partitioning.
2908 Turning it on for all tables imposes extra planning overhead that is
2909 quite noticeable on simple queries, and most often will yield no
2910 benefit for simple queries. If you have no partitioned tables
2911 you might prefer to turn it off entirely.
2915 Refer to <xref linkend="ddl-partitioning-constraint-exclusion"> for
2916 more information on using constraint exclusion and partitioning.
2921 <varlistentry id="guc-cursor-tuple-fraction" xreflabel="cursor_tuple_fraction">
2922 <term><varname>cursor_tuple_fraction</varname> (<type>floating point</type>)</term>
2924 <primary><varname>cursor_tuple_fraction</> configuration parameter</primary>
2928 Sets the planner's estimate of the fraction of a cursor's rows that
2929 will be retrieved. The default is 0.1. Smaller values of this
2930 setting bias the planner towards using <quote>fast start</> plans
2931 for cursors, which will retrieve the first few rows quickly while
2932 perhaps taking a long time to fetch all rows. Larger values
2933 put more emphasis on the total estimated time. At the maximum
2934 setting of 1.0, cursors are planned exactly like regular queries,
2935 considering only the total estimated time and not how soon the
2936 first rows might be delivered.
2941 <varlistentry id="guc-from-collapse-limit" xreflabel="from_collapse_limit">
2942 <term><varname>from_collapse_limit</varname> (<type>integer</type>)</term>
2944 <primary><varname>from_collapse_limit</> configuration parameter</primary>
2948 The planner will merge sub-queries into upper queries if the
2949 resulting <literal>FROM</literal> list would have no more than
2950 this many items. Smaller values reduce planning time but might
2951 yield inferior query plans. The default is eight.
2952 For more information see <xref linkend="explicit-joins">.
2956 Setting this value to <xref linkend="guc-geqo-threshold"> or more
2957 may trigger use of the GEQO planner, resulting in nondeterministic
2958 plans. See <xref linkend="runtime-config-query-geqo">.
2963 <varlistentry id="guc-join-collapse-limit" xreflabel="join_collapse_limit">
2964 <term><varname>join_collapse_limit</varname> (<type>integer</type>)</term>
2966 <primary><varname>join_collapse_limit</> configuration parameter</primary>
2970 The planner will rewrite explicit <literal>JOIN</>
2971 constructs (except <literal>FULL JOIN</>s) into lists of
2972 <literal>FROM</> items whenever a list of no more than this many items
2973 would result. Smaller values reduce planning time but might
2974 yield inferior query plans.
2978 By default, this variable is set the same as
2979 <varname>from_collapse_limit</varname>, which is appropriate
2980 for most uses. Setting it to 1 prevents any reordering of
2981 explicit <literal>JOIN</>s. Thus, the explicit join order
2982 specified in the query will be the actual order in which the
2983 relations are joined. Because the query planner does not always choose
2984 the optimal join order, advanced users can elect to
2985 temporarily set this variable to 1, and then specify the join
2986 order they desire explicitly.
2987 For more information see <xref linkend="explicit-joins">.
2991 Setting this value to <xref linkend="guc-geqo-threshold"> or more
2992 may trigger use of the GEQO planner, resulting in nondeterministic
2993 plans. See <xref linkend="runtime-config-query-geqo">.
3002 <sect1 id="runtime-config-logging">
3003 <title>Error Reporting and Logging</title>
3005 <indexterm zone="runtime-config-logging">
3006 <primary>server log</primary>
3009 <sect2 id="runtime-config-logging-where">
3010 <title>Where To Log</title>
3012 <indexterm zone="runtime-config-logging-where">
3013 <primary>where to log</primary>
3018 <varlistentry id="guc-log-destination" xreflabel="log_destination">
3019 <term><varname>log_destination</varname> (<type>string</type>)</term>
3021 <primary><varname>log_destination</> configuration parameter</primary>
3025 <productname>PostgreSQL</productname> supports several methods
3026 for logging server messages, including
3027 <systemitem>stderr</systemitem>, <systemitem>csvlog</systemitem> and
3028 <systemitem>syslog</systemitem>. On Windows,
3029 <systemitem>eventlog</systemitem> is also supported. Set this
3030 parameter to a list of desired log destinations separated by
3031 commas. The default is to log to <systemitem>stderr</systemitem>
3033 This parameter can only be set in the <filename>postgresql.conf</>
3034 file or on the server command line.
3037 If <systemitem>csvlog</> is included in <varname>log_destination</>,
3038 log entries are output in <quote>comma separated
3039 value</> (<acronym>CSV</>) format, which is convenient for
3040 loading logs into programs.
3041 See <xref linkend="runtime-config-logging-csvlog"> for details.
3042 <varname>logging_collector</varname> must be enabled to generate
3043 CSV-format log output.
3048 On most Unix systems, you will need to alter the configuration of
3049 your system's <application>syslog</application> daemon in order
3050 to make use of the <systemitem>syslog</systemitem> option for
3051 <varname>log_destination</>. <productname>PostgreSQL</productname>
3052 can log to <application>syslog</application> facilities
3053 <literal>LOCAL0</> through <literal>LOCAL7</> (see <xref
3054 linkend="guc-syslog-facility">), but the default
3055 <application>syslog</application> configuration on most platforms
3056 will discard all such messages. You will need to add something like:
3058 local0.* /var/log/postgresql
3060 to the <application>syslog</application> daemon's configuration file
3064 On Windows, when you use the <literal>eventlog</literal>
3065 option for <varname>log_destination</>, you should
3066 register an event source and its library with the operating
3067 system so that the Windows Event Viewer can display event
3068 log messages cleanly.
3069 See <xref linkend="event-log-registration"> for details.
3075 <varlistentry id="guc-logging-collector" xreflabel="logging_collector">
3076 <term><varname>logging_collector</varname> (<type>boolean</type>)</term>
3078 <primary><varname>logging_collector</> configuration parameter</primary>
3082 This parameter captures plain and CSV-format log messages
3083 sent to <application>stderr</> and redirects them into log files.
3084 This approach is often more useful than
3085 logging to <application>syslog</>, since some types of messages
3086 might not appear in <application>syslog</> output (a common example
3087 is dynamic-linker failure messages).
3088 This parameter can only be set at server start.
3093 The logging collector is designed to never lose messages. This means
3094 that in case of extremely high load, server processes could be
3095 blocked due to trying to send additional log messages when the
3096 collector has fallen behind. In contrast, <application>syslog</>
3097 prefers to drop messages if it cannot write them, which means it's
3098 less reliable in those cases but it will not block the rest of the
3106 <varlistentry id="guc-log-directory" xreflabel="log_directory">
3107 <term><varname>log_directory</varname> (<type>string</type>)</term>
3109 <primary><varname>log_directory</> configuration parameter</primary>
3113 When <varname>logging_collector</> is enabled,
3114 this parameter determines the directory in which log files will be created.
3115 It can be specified as an absolute path, or relative to the
3116 cluster data directory.
3117 This parameter can only be set in the <filename>postgresql.conf</>
3118 file or on the server command line.
3123 <varlistentry id="guc-log-filename" xreflabel="log_filename">
3124 <term><varname>log_filename</varname> (<type>string</type>)</term>
3126 <primary><varname>log_filename</> configuration parameter</primary>
3130 When <varname>logging_collector</varname> is enabled,
3131 this parameter sets the file names of the created log files. The value
3132 is treated as a <systemitem>strftime</systemitem> pattern,
3133 so <literal>%</literal>-escapes can be used to specify time-varying
3134 file names. (Note that if there are
3135 any time-zone-dependent <literal>%</literal>-escapes, the computation
3136 is done in the zone specified
3137 by <xref linkend="guc-log-timezone">.)
3138 The supported <literal>%</literal>-escapes are similar to those
3139 listed in the Open Group's <ulink
3140 url="http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html">strftime
3141 </ulink> specification.
3142 Note that the system's <systemitem>strftime</systemitem> is not used
3143 directly, so platform-specific (nonstandard) extensions do not work.
3146 If you specify a file name without escapes, you should plan to
3147 use a log rotation utility to avoid eventually filling the
3148 entire disk. In releases prior to 8.4, if
3149 no <literal>%</literal> escapes were
3150 present, <productname>PostgreSQL</productname> would append
3151 the epoch of the new log file's creation time, but this is no
3155 If CSV-format output is enabled in <varname>log_destination</>,
3156 <literal>.csv</> will be appended to the timestamped
3157 log file name to create the file name for CSV-format output.
3158 (If <varname>log_filename</> ends in <literal>.log</>, the suffix is
3160 In the case of the example above, the CSV
3161 file name will be <literal>server_log.1093827753.csv</literal>.
3164 This parameter can only be set in the <filename>postgresql.conf</>
3165 file or on the server command line.
3170 <varlistentry id="guc-log-file-mode" xreflabel="log_file_mode">
3171 <term><varname>log_file_mode</varname> (<type>integer</type>)</term>
3173 <primary><varname>log_file_mode</> configuration parameter</primary>
3177 On Unix systems this parameter sets the permissions for log files
3178 when <varname>logging_collector</varname> is enabled. (On Microsoft
3179 Windows this parameter is ignored.)
3180 The parameter value is expected to be a numeric mode
3181 specified in the format accepted by the
3182 <function>chmod</function> and <function>umask</function>
3183 system calls. (To use the customary octal format the number
3184 must start with a <literal>0</literal> (zero).)
3187 The default permissions are <literal>0600</>, meaning only the
3188 server owner can read or write the log files. The other commonly
3189 useful setting is <literal>0640</>, allowing members of the owner's
3190 group to read the files. Note however that to make use of such a
3191 setting, you'll need to alter <xref linkend="guc-log-directory"> to
3192 store the files somewhere outside the cluster data directory. In
3193 any case, it's unwise to make the log files world-readable, since
3194 they might contain sensitive data.
3197 This parameter can only be set in the <filename>postgresql.conf</>
3198 file or on the server command line.
3203 <varlistentry id="guc-log-rotation-age" xreflabel="log_rotation_age">
3204 <term><varname>log_rotation_age</varname> (<type>integer</type>)</term>
3206 <primary><varname>log_rotation_age</> configuration parameter</primary>
3210 When <varname>logging_collector</varname> is enabled,
3211 this parameter determines the maximum lifetime of an individual log file.
3212 After this many minutes have elapsed, a new log file will
3213 be created. Set to zero to disable time-based creation of
3215 This parameter can only be set in the <filename>postgresql.conf</>
3216 file or on the server command line.
3221 <varlistentry id="guc-log-rotation-size" xreflabel="log_rotation_size">
3222 <term><varname>log_rotation_size</varname> (<type>integer</type>)</term>
3224 <primary><varname>log_rotation_size</> configuration parameter</primary>
3228 When <varname>logging_collector</varname> is enabled,
3229 this parameter determines the maximum size of an individual log file.
3230 After this many kilobytes have been emitted into a log file,
3231 a new log file will be created. Set to zero to disable size-based
3232 creation of new log files.
3233 This parameter can only be set in the <filename>postgresql.conf</>
3234 file or on the server command line.
3239 <varlistentry id="guc-log-truncate-on-rotation" xreflabel="log_truncate_on_rotation">
3240 <term><varname>log_truncate_on_rotation</varname> (<type>boolean</type>)</term>
3242 <primary><varname>log_truncate_on_rotation</> configuration parameter</primary>
3246 When <varname>logging_collector</varname> is enabled,
3247 this parameter will cause <productname>PostgreSQL</productname> to truncate (overwrite),
3248 rather than append to, any existing log file of the same name.
3249 However, truncation will occur only when a new file is being opened
3250 due to time-based rotation, not during server startup or size-based
3251 rotation. When off, pre-existing files will be appended to in
3252 all cases. For example, using this setting in combination with
3253 a <varname>log_filename</varname> like <literal>postgresql-%H.log</literal>
3254 would result in generating twenty-four hourly log files and then
3255 cyclically overwriting them.
3256 This parameter can only be set in the <filename>postgresql.conf</>
3257 file or on the server command line.
3260 Example: To keep 7 days of logs, one log file per day named
3261 <literal>server_log.Mon</literal>, <literal>server_log.Tue</literal>,
3262 etc, and automatically overwrite last week's log with this week's log,
3263 set <varname>log_filename</varname> to <literal>server_log.%a</literal>,
3264 <varname>log_truncate_on_rotation</varname> to <literal>on</literal>, and
3265 <varname>log_rotation_age</varname> to <literal>1440</literal>.
3268 Example: To keep 24 hours of logs, one log file per hour, but
3269 also rotate sooner if the log file size exceeds 1GB, set
3270 <varname>log_filename</varname> to <literal>server_log.%H%M</literal>,
3271 <varname>log_truncate_on_rotation</varname> to <literal>on</literal>,
3272 <varname>log_rotation_age</varname> to <literal>60</literal>, and
3273 <varname>log_rotation_size</varname> to <literal>1000000</literal>.
3274 Including <literal>%M</> in <varname>log_filename</varname> allows
3275 any size-driven rotations that might occur to select a file name
3276 different from the hour's initial file name.
3281 <varlistentry id="guc-syslog-facility" xreflabel="syslog_facility">
3282 <term><varname>syslog_facility</varname> (<type>enum</type>)</term>
3284 <primary><varname>syslog_facility</> configuration parameter</primary>
3288 When logging to <application>syslog</> is enabled, this parameter
3289 determines the <application>syslog</application>
3290 <quote>facility</quote> to be used. You can choose
3291 from <literal>LOCAL0</>, <literal>LOCAL1</>,
3292 <literal>LOCAL2</>, <literal>LOCAL3</>, <literal>LOCAL4</>,
3293 <literal>LOCAL5</>, <literal>LOCAL6</>, <literal>LOCAL7</>;
3294 the default is <literal>LOCAL0</>. See also the
3295 documentation of your system's
3296 <application>syslog</application> daemon.
3297 This parameter can only be set in the <filename>postgresql.conf</>
3298 file or on the server command line.
3303 <varlistentry id="guc-syslog-ident" xreflabel="syslog_ident">
3304 <term><varname>syslog_ident</varname> (<type>string</type>)</term>
3306 <primary><varname>syslog_identity</> configuration parameter</primary>
3310 When logging to <application>syslog</> is enabled, this parameter
3311 determines the program name used to identify
3312 <productname>PostgreSQL</productname> messages in
3313 <application>syslog</application> logs. The default is
3314 <literal>postgres</literal>.
3315 This parameter can only be set in the <filename>postgresql.conf</>
3316 file or on the server command line.
3321 <varlistentry id="guc-event-source" xreflabel="event_source">
3322 <term><varname>event_source</varname> (<type>string</type>)</term>
3324 <primary><varname>event_source</> configuration parameter</primary>
3328 When logging to <application>event log</> is enabled, this parameter
3329 determines the program name used to identify
3330 <productname>PostgreSQL</productname> messages in
3331 the log. The default is <literal>PostgreSQL</literal>.
3332 This parameter can only be set in the <filename>postgresql.conf</>
3333 file or on the server command line.
3340 <sect2 id="runtime-config-logging-when">
3341 <title>When To Log</title>
3345 <varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
3346 <term><varname>client_min_messages</varname> (<type>enum</type>)</term>
3348 <primary><varname>client_min_messages</> configuration parameter</primary>
3352 Controls which message levels are sent to the client.
3353 Valid values are <literal>DEBUG5</>,
3354 <literal>DEBUG4</>, <literal>DEBUG3</>, <literal>DEBUG2</>,
3355 <literal>DEBUG1</>, <literal>LOG</>, <literal>NOTICE</>,
3356 <literal>WARNING</>, <literal>ERROR</>, <literal>FATAL</>,
3357 and <literal>PANIC</>. Each level
3358 includes all the levels that follow it. The later the level,
3359 the fewer messages are sent. The default is
3360 <literal>NOTICE</>. Note that <literal>LOG</> has a different
3361 rank here than in <varname>log_min_messages</>.
3366 <varlistentry id="guc-log-min-messages" xreflabel="log_min_messages">
3367 <term><varname>log_min_messages</varname> (<type>enum</type>)</term>
3369 <primary><varname>log_min_messages</> configuration parameter</primary>
3373 Controls which message levels are written to the server log.
3374 Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
3375 <literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>,
3376 <literal>INFO</>, <literal>NOTICE</>, <literal>WARNING</>,
3377 <literal>ERROR</>, <literal>LOG</>, <literal>FATAL</>, and
3378 <literal>PANIC</>. Each level includes all the levels that
3379 follow it. The later the level, the fewer messages are sent
3380 to the log. The default is <literal>WARNING</>. Note that
3381 <literal>LOG</> has a different rank here than in
3382 <varname>client_min_messages</>.
3383 Only superusers can change this setting.
3388 <varlistentry id="guc-log-min-error-statement" xreflabel="log_min_error_statement">
3389 <term><varname>log_min_error_statement</varname> (<type>enum</type>)</term>
3391 <primary><varname>log_min_error_statement</> configuration parameter</primary>
3395 Controls which SQL statements that cause an error
3396 condition are recorded in the server log. The current
3397 SQL statement is included in the log entry for any message of
3398 the specified severity or higher.
3399 Valid values are <literal>DEBUG5</literal>,
3400 <literal>DEBUG4</literal>, <literal>DEBUG3</literal>,
3401 <literal>DEBUG2</literal>, <literal>DEBUG1</literal>,
3402 <literal>INFO</literal>, <literal>NOTICE</literal>,
3403 <literal>WARNING</literal>, <literal>ERROR</literal>,
3404 <literal>LOG</literal>,
3405 <literal>FATAL</literal>, and <literal>PANIC</literal>.
3406 The default is <literal>ERROR</literal>, which means statements
3407 causing errors, log messages, fatal errors, or panics will be logged.
3408 To effectively turn off logging of failing statements,
3409 set this parameter to <literal>PANIC</literal>.
3410 Only superusers can change this setting.
3415 <varlistentry id="guc-log-min-duration-statement" xreflabel="log_min_duration_statement">
3416 <term><varname>log_min_duration_statement</varname> (<type>integer</type>)</term>
3418 <primary><varname>log_min_duration_statement</> configuration parameter</primary>
3422 Causes the duration of each completed statement to be logged
3423 if the statement ran for at least the specified number of
3424 milliseconds. Setting this to zero prints all statement durations.
3425 Minus-one (the default) disables logging statement durations.
3426 For example, if you set it to <literal>250ms</literal>
3427 then all SQL statements that run 250ms or longer will be
3428 logged. Enabling this parameter can be helpful in tracking down
3429 unoptimized queries in your applications.
3430 Only superusers can change this setting.
3434 For clients using extended query protocol, durations of the Parse,
3435 Bind, and Execute steps are logged independently.
3440 When using this option together with
3441 <xref linkend="guc-log-statement">,
3442 the text of statements that are logged because of
3443 <varname>log_statement</> will not be repeated in the
3444 duration log message.
3445 If you are not using <application>syslog</>, it is recommended
3446 that you log the PID or session ID using
3447 <xref linkend="guc-log-line-prefix">
3448 so that you can link the statement message to the later
3449 duration message using the process ID or session ID.
3458 <xref linkend="runtime-config-severity-levels"> explains the message
3459 severity levels used by <productname>PostgreSQL</>. If logging output
3460 is sent to <systemitem>syslog</systemitem> or Windows'
3461 <systemitem>eventlog</systemitem>, the severity levels are translated
3462 as shown in the table.
3465 <table id="runtime-config-severity-levels">
3466 <title>Message Severity Levels</title>
3470 <entry>Severity</entry>
3471 <entry>Usage</entry>
3472 <entry><systemitem>syslog</></entry>
3473 <entry><systemitem>eventlog</></entry>
3479 <entry><literal>DEBUG1..DEBUG5</></entry>
3480 <entry>Provides successively-more-detailed information for use by
3482 <entry><literal>DEBUG</></entry>
3483 <entry><literal>INFORMATION</></entry>
3487 <entry><literal>INFO</></entry>
3488 <entry>Provides information implicitly requested by the user,
3489 e.g., output from <command>VACUUM VERBOSE</>.</entry>
3490 <entry><literal>INFO</></entry>
3491 <entry><literal>INFORMATION</></entry>
3495 <entry><literal>NOTICE</></entry>
3496 <entry>Provides information that might be helpful to users, e.g.,
3497 notice of truncation of long identifiers.</entry>
3498 <entry><literal>NOTICE</></entry>
3499 <entry><literal>INFORMATION</></entry>
3503 <entry><literal>WARNING</></entry>
3504 <entry>Provides warnings of likely problems, e.g., <command>COMMIT</>
3505 outside a transaction block.</entry>
3506 <entry><literal>NOTICE</></entry>
3507 <entry><literal>WARNING</></entry>
3511 <entry><literal>ERROR</></entry>
3512 <entry>Reports an error that caused the current command to
3514 <entry><literal>WARNING</></entry>
3515 <entry><literal>ERROR</></entry>
3519 <entry><literal>LOG</></entry>
3520 <entry>Reports information of interest to administrators, e.g.,
3521 checkpoint activity.</entry>
3522 <entry><literal>INFO</></entry>
3523 <entry><literal>INFORMATION</></entry>
3527 <entry><literal>FATAL</></entry>
3528 <entry>Reports an error that caused the current session to
3530 <entry><literal>ERR</></entry>
3531 <entry><literal>ERROR</></entry>
3535 <entry><literal>PANIC</></entry>
3536 <entry>Reports an error that caused all database sessions to abort.</entry>
3537 <entry><literal>CRIT</></entry>
3538 <entry><literal>ERROR</></entry>
3545 <sect2 id="runtime-config-logging-what">
3546 <title>What To Log</title>
3550 <varlistentry id="guc-application-name" xreflabel="application_name">
3551 <term><varname>application_name</varname> (<type>string</type>)</term>
3553 <primary><varname>application_name</> configuration parameter</primary>
3557 The <varname>application_name</varname> can be any string of less than
3558 <symbol>NAMEDATALEN</> characters (64 characters in a standard build).
3559 It is typically set by an application upon connection to the server.
3560 The name will be displayed in the <structname>pg_stat_activity</> view
3561 and included in CSV log entries. It can also be included in regular
3562 log entries via the <xref linkend="guc-log-line-prefix"> parameter.
3563 Only printable ASCII characters may be used in the
3564 <varname>application_name</varname> value. Other characters will be
3565 replaced with question marks (<literal>?</literal>).
3571 <term><varname>debug_print_parse</varname> (<type>boolean</type>)</term>
3572 <term><varname>debug_print_rewritten</varname> (<type>boolean</type>)</term>
3573 <term><varname>debug_print_plan</varname> (<type>boolean</type>)</term>
3575 <primary><varname>debug_print_parse</> configuration parameter</primary>
3578 <primary><varname>debug_print_rewritten</> configuration parameter</primary>
3581 <primary><varname>debug_print_plan</> configuration parameter</primary>
3585 These parameters enable various debugging output to be emitted.
3586 When set, they print the resulting parse tree, the query rewriter
3587 output, or the execution plan for each executed query.
3588 These messages are emitted at <literal>LOG</> message level, so by
3589 default they will appear in the server log but will not be sent to the
3590 client. You can change that by adjusting
3591 <xref linkend="guc-client-min-messages"> and/or
3592 <xref linkend="guc-log-min-messages">.
3593 These parameters are off by default.
3599 <term><varname>debug_pretty_print</varname> (<type>boolean</type>)</term>
3601 <primary><varname>debug_pretty_print</> configuration parameter</primary>
3605 When set, <varname>debug_pretty_print</varname> indents the messages
3606 produced by <varname>debug_print_parse</varname>,
3607 <varname>debug_print_rewritten</varname>, or
3608 <varname>debug_print_plan</varname>. This results in more readable
3609 but much longer output than the <quote>compact</> format used when
3610 it is off. It is on by default.
3615 <varlistentry id="guc-log-checkpoints" xreflabel="log_checkpoints">
3616 <term><varname>log_checkpoints</varname> (<type>boolean</type>)</term>
3618 <primary><varname>log_checkpoints</> configuration parameter</primary>
3622 Causes checkpoints and restartpoints to be logged in the server log.
3623 Some statistics are included in the log messages, including the number
3624 of buffers written and the time spent writing them.
3625 This parameter can only be set in the <filename>postgresql.conf</>
3626 file or on the server command line. The default is off.
3631 <varlistentry id="guc-log-connections" xreflabel="log_connections">
3632 <term><varname>log_connections</varname> (<type>boolean</type>)</term>
3634 <primary><varname>log_connections</> configuration parameter</primary>
3638 Causes each attempted connection to the server to be logged,
3639 as well as successful completion of client authentication.
3640 This parameter cannot be changed after session start.
3646 Some client programs, like <application>psql</>, attempt
3647 to connect twice while determining if a password is required, so
3648 duplicate <quote>connection received</> messages do not
3649 necessarily indicate a problem.
3655 <varlistentry id="guc-log-disconnections" xreflabel="log_disconnections">
3656 <term><varname>log_disconnections</varname> (<type>boolean</type>)</term>
3658 <primary><varname>log_disconnections</> configuration parameter</primary>
3662 This outputs a line in the server log similar to
3663 <varname>log_connections</varname> but at session termination,
3664 and includes the duration of the session. This is off by
3666 This parameter cannot be changed after session start.
3672 <varlistentry id="guc-log-duration" xreflabel="log_duration">
3673 <term><varname>log_duration</varname> (<type>boolean</type>)</term>
3675 <primary><varname>log_duration</> configuration parameter</primary>
3679 Causes the duration of every completed statement to be logged.
3680 The default is <literal>off</>.
3681 Only superusers can change this setting.
3685 For clients using extended query protocol, durations of the Parse,
3686 Bind, and Execute steps are logged independently.
3691 The difference between setting this option and setting
3692 <xref linkend="guc-log-min-duration-statement"> to zero is that
3693 exceeding <varname>log_min_duration_statement</> forces the text of
3694 the query to be logged, but this option doesn't. Thus, if
3695 <varname>log_duration</> is <literal>on</> and
3696 <varname>log_min_duration_statement</> has a positive value, all
3697 durations are logged but the query text is included only for
3698 statements exceeding the threshold. This behavior can be useful for
3699 gathering statistics in high-load installations.
3705 <varlistentry id="guc-log-error-verbosity" xreflabel="log_error_verbosity">
3706 <term><varname>log_error_verbosity</varname> (<type>enum</type>)</term>
3708 <primary><varname>log_error_verbosity</> configuration parameter</primary>
3712 Controls the amount of detail written in the server log for each
3713 message that is logged. Valid values are <literal>TERSE</>,
3714 <literal>DEFAULT</>, and <literal>VERBOSE</>, each adding more
3715 fields to displayed messages. <literal>TERSE</> excludes
3716 the logging of <literal>DETAIL</>, <literal>HINT</>,
3717 <literal>QUERY</>, and <literal>CONTEXT</> error information.
3718 <literal>VERBOSE</> output includes the <symbol>SQLSTATE</> error
3719 code (see also <xref linkend="errcodes-appendix">) and the source code file name, function name,
3720 and line number that generated the error.
3721 Only superusers can change this setting.
3726 <varlistentry id="guc-log-hostname" xreflabel="log_hostname">
3727 <term><varname>log_hostname</varname> (<type>boolean</type>)</term>
3729 <primary><varname>log_hostname</> configuration parameter</primary>
3733 By default, connection log messages only show the IP address of the
3734 connecting host. Turning this parameter on causes logging of the
3735 host name as well. Note that depending on your host name resolution
3736 setup this might impose a non-negligible performance penalty.
3737 This parameter can only be set in the <filename>postgresql.conf</>
3738 file or on the server command line.
3743 <varlistentry id="guc-log-line-prefix" xreflabel="log_line_prefix">
3744 <term><varname>log_line_prefix</varname> (<type>string</type>)</term>
3746 <primary><varname>log_line_prefix</> configuration parameter</primary>
3750 This is a <function>printf</>-style string that is output at the
3751 beginning of each log line.
3752 <literal>%</> characters begin <quote>escape sequences</>
3753 that are replaced with status information as outlined below.
3754 Unrecognized escapes are ignored. Other
3755 characters are copied straight to the log line. Some escapes are
3756 only recognized by session processes, and are ignored by
3757 background processes such as the main server process.
3758 This parameter can only be set in the <filename>postgresql.conf</>
3759 file or on the server command line. The default is an empty string.
3765 <entry>Escape</entry>
3766 <entry>Effect</entry>
3767 <entry>Session only</entry>
3772 <entry><literal>%a</literal></entry>
3773 <entry>Application name</entry>
3777 <entry><literal>%u</literal></entry>
3778 <entry>User name</entry>
3782 <entry><literal>%d</literal></entry>
3783 <entry>Database name</entry>
3787 <entry><literal>%r</literal></entry>
3788 <entry>Remote host name or IP address, and remote port</entry>
3792 <entry><literal>%h</literal></entry>
3793 <entry>Remote host name or IP address</entry>
3797 <entry><literal>%p</literal></entry>
3798 <entry>Process ID</entry>
3802 <entry><literal>%t</literal></entry>
3803 <entry>Time stamp without milliseconds</entry>
3807 <entry><literal>%m</literal></entry>
3808 <entry>Time stamp with milliseconds</entry>
3812 <entry><literal>%i</literal></entry>
3813 <entry>Command tag: type of session's current command</entry>
3817 <entry><literal>%e</literal></entry>
3818 <entry>SQLSTATE error code</entry>
3822 <entry><literal>%c</literal></entry>
3823 <entry>Session ID: see below</entry>
3827 <entry><literal>%l</literal></entry>
3828 <entry>Number of the log line for each session or process, starting at 1</entry>
3832 <entry><literal>%s</literal></entry>
3833 <entry>Process start time stamp</entry>
3837 <entry><literal>%v</literal></entry>
3838 <entry>Virtual transaction ID (backendID/localXID)</entry>
3842 <entry><literal>%x</literal></entry>
3843 <entry>Transaction ID (0 if none is assigned)</entry>
3847 <entry><literal>%q</literal></entry>
3848 <entry>Produces no output, but tells non-session
3849 processes to stop at this point in the string; ignored by
3850 session processes</entry>
3854 <entry><literal>%%</literal></entry>
3855 <entry>Literal <literal>%</></entry>
3862 The <literal>%c</> escape prints a quasi-unique session identifier,
3863 consisting of two 4-byte hexadecimal numbers (without leading zeros)
3864 separated by a dot. The numbers are the process start time and the
3865 process ID, so <literal>%c</> can also be used as a space saving way
3866 of printing those items. For example, to generate the session
3867 identifier from <literal>pg_stat_activity</>, use this query:
3869 SELECT to_hex(EXTRACT(EPOCH FROM backend_start)::integer) || '.' ||
3871 FROM pg_stat_activity;
3878 If you set a nonempty value for <varname>log_line_prefix</>,
3879 you should usually make its last character be a space, to provide
3880 visual separation from the rest of the log line. A punctuation
3881 character can be used too.
3887 <application>Syslog</> produces its own
3888 time stamp and process ID information, so you probably do not want to
3889 include those escapes if you are logging to <application>syslog</>.
3895 <varlistentry id="guc-log-lock-waits" xreflabel="log_lock_waits">
3896 <term><varname>log_lock_waits</varname> (<type>boolean</type>)</term>
3898 <primary><varname>log_lock_waits</> configuration parameter</primary>
3902 Controls whether a log message is produced when a session waits
3903 longer than <xref linkend="guc-deadlock-timeout"> to acquire a
3904 lock. This is useful in determining if lock waits are causing
3905 poor performance. The default is <literal>off</>.
3910 <varlistentry id="guc-log-statement" xreflabel="log_statement">
3911 <term><varname>log_statement</varname> (<type>enum</type>)</term>
3913 <primary><varname>log_statement</> configuration parameter</primary>
3917 Controls which SQL statements are logged. Valid values are
3918 <literal>none</> (off), <literal>ddl</>, <literal>mod</>, and
3919 <literal>all</> (all statements). <literal>ddl</> logs all data definition
3920 statements, such as <command>CREATE</>, <command>ALTER</>, and
3921 <command>DROP</> statements. <literal>mod</> logs all
3922 <literal>ddl</> statements, plus data-modifying statements
3923 such as <command>INSERT</>,
3924 <command>UPDATE</>, <command>DELETE</>, <command>TRUNCATE</>,
3925 and <command>COPY FROM</>.
3926 <command>PREPARE</>, <command>EXECUTE</>, and
3927 <command>EXPLAIN ANALYZE</> statements are also logged if their
3928 contained command is of an appropriate type. For clients using
3929 extended query protocol, logging occurs when an Execute message
3930 is received, and values of the Bind parameters are included
3931 (with any embedded single-quote marks doubled).
3935 The default is <literal>none</>. Only superusers can change this
3941 Statements that contain simple syntax errors are not logged
3942 even by the <varname>log_statement</> = <literal>all</> setting,
3943 because the log message is emitted only after basic parsing has
3944 been done to determine the statement type. In the case of extended
3945 query protocol, this setting likewise does not log statements that
3946 fail before the Execute phase (i.e., during parse analysis or
3947 planning). Set <varname>log_min_error_statement</> to
3948 <literal>ERROR</> (or lower) to log such statements.
3954 <varlistentry id="guc-log-temp-files" xreflabel="log_temp_files">
3955 <term><varname>log_temp_files</varname> (<type>integer</type>)</term>
3957 <primary><varname>log_temp_files</> configuration parameter</primary>
3961 Controls logging of temporary file names and sizes.
3962 Temporary files can be
3963 created for sorts, hashes, and temporary query results.
3964 A log entry is made for each temporary file when it is deleted.
3965 A value of zero logs all temporary file information, while positive
3966 values log only files whose size is greater than or equal to
3967 the specified number of kilobytes. The
3968 default setting is -1, which disables such logging.
3969 Only superusers can change this setting.
3974 <varlistentry id="guc-log-timezone" xreflabel="log_timezone">
3975 <term><varname>log_timezone</varname> (<type>string</type>)</term>
3977 <primary><varname>log_timezone</> configuration parameter</primary>
3981 Sets the time zone used for timestamps written in the server log.
3982 Unlike <xref linkend="guc-timezone">, this value is cluster-wide,
3983 so that all sessions will report timestamps consistently.
3984 The built-in default is <literal>GMT</>, but that is typically
3985 overridden in <filename>postgresql.conf</>; <application>initdb</>
3986 will install a setting there corresponding to its system environment.
3987 See <xref linkend="datatype-timezones"> for more information.
3988 This parameter can only be set in the <filename>postgresql.conf</>
3989 file or on the server command line.
3996 <sect2 id="runtime-config-logging-csvlog">
3997 <title>Using CSV-Format Log Output</title>
4000 Including <literal>csvlog</> in the <varname>log_destination</> list
4001 provides a convenient way to import log files into a database table.
4002 This option emits log lines in comma-separated-values
4003 (<acronym>CSV</>) format,
4005 time stamp with milliseconds,
4009 client host:port number,
4011 per-session line number,
4014 virtual transaction ID,
4015 regular transaction ID,
4019 error message detail,
4021 internal query that led to the error (if any),
4022 character count of the error position therein,
4024 user query that led to the error (if any and enabled by
4025 <varname>log_min_error_statement</>),
4026 character count of the error position therein,
4027 location of the error in the PostgreSQL source code
4028 (if <varname>log_error_verbosity</> is set to <literal>verbose</>),
4029 and application name.
4030 Here is a sample table definition for storing CSV-format log output:
4033 CREATE TABLE postgres_log
4035 log_time timestamp(3) with time zone,
4039 connection_from text,
4041 session_line_num bigint,
4043 session_start_time timestamp with time zone,
4044 virtual_transaction_id text,
4045 transaction_id bigint,
4046 error_severity text,
4047 sql_state_code text,
4051 internal_query text,
4052 internal_query_pos integer,
4057 application_name text,
4058 PRIMARY KEY (session_id, session_line_num)
4064 To import a log file into this table, use the <command>COPY FROM</>
4068 COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
4073 There are a few things you need to do to simplify importing CSV log
4079 Set <varname>log_filename</varname> and
4080 <varname>log_rotation_age</> to provide a consistent,
4081 predictable naming scheme for your log files. This lets you
4082 predict what the file name will be and know when an individual log
4083 file is complete and therefore ready to be imported.
4089 Set <varname>log_rotation_size</varname> to 0 to disable
4090 size-based log rotation, as it makes the log file name difficult
4097 Set <varname>log_truncate_on_rotation</varname> to <literal>on</> so
4098 that old log data isn't mixed with the new in the same file.
4104 The table definition above includes a primary key specification.
4105 This is useful to protect against accidentally importing the same
4106 information twice. The <command>COPY</> command commits all of the
4107 data it imports at one time, so any error will cause the entire
4108 import to fail. If you import a partial log file and later import
4109 the file again when it is complete, the primary key violation will
4110 cause the import to fail. Wait until the log is complete and
4111 closed before importing. This procedure will also protect against
4112 accidentally importing a partial line that hasn't been completely
4113 written, which would also cause <command>COPY</> to fail.
4122 <sect1 id="runtime-config-statistics">
4123 <title>Run-time Statistics</title>
4125 <sect2 id="runtime-config-statistics-collector">
4126 <title>Query and Index Statistics Collector</title>
4129 These parameters control server-wide statistics collection features.
4130 When statistics collection is enabled, the data that is produced can be
4131 accessed via the <structname>pg_stat</structname> and
4132 <structname>pg_statio</structname> family of system views.
4133 Refer to <xref linkend="monitoring"> for more information.
4138 <varlistentry id="guc-track-activities" xreflabel="track_activities">
4139 <term><varname>track_activities</varname> (<type>boolean</type>)</term>
4141 <primary><varname>track_activities</> configuration parameter</primary>
4145 Enables the collection of information on the currently
4146 executing command of each session, along with the time when
4147 that command began execution. This parameter is on by
4148 default. Note that even when enabled, this information is not
4149 visible to all users, only to superusers and the user owning
4150 the session being reported on, so it should not represent a
4152 Only superusers can change this setting.
4157 <varlistentry id="guc-track-activity-query-size" xreflabel="track_activity_query_size">
4158 <term><varname>track_activity_query_size</varname> (<type>integer</type>)</term>
4160 <primary><varname>track_activity_query_size</> configuration parameter</primary>
4164 Specifies the number of bytes reserved to track the currently
4165 executing command for each active session, for the
4166 <structname>pg_stat_activity</>.<structfield>query</> field.
4167 The default value is 1024. This parameter can only be set at server
4173 <varlistentry id="guc-track-counts" xreflabel="track_counts">
4174 <term><varname>track_counts</varname> (<type>boolean</type>)</term>
4176 <primary><varname>track_counts</> configuration parameter</primary>
4180 Enables collection of statistics on database activity.
4181 This parameter is on by default, because the autovacuum
4182 daemon needs the collected information.
4183 Only superusers can change this setting.
4188 <varlistentry id="guc-track-functions" xreflabel="track_functions">
4189 <term><varname>track_functions</varname> (<type>enum</type>)</term>
4191 <primary><varname>track_functions</> configuration parameter</primary>
4195 Enables tracking of function call counts and time used. Specify
4196 <literal>pl</literal> to track only procedural-language functions,
4197 <literal>all</literal> to also track SQL and C language functions.
4198 The default is <literal>none</literal>, which disables function
4199 statistics tracking. Only superusers can change this setting.
4204 SQL-language functions that are simple enough to be <quote>inlined</>
4205 into the calling query will not be tracked, regardless of this
4212 <varlistentry id="guc-update-process-title" xreflabel="update_process_title">
4213 <term><varname>update_process_title</varname> (<type>boolean</type>)</term>
4215 <primary><varname>update_process_title</> configuration parameter</primary>
4219 Enables updating of the process title every time a new SQL command
4220 is received by the server. The process title is typically viewed
4221 by the <command>ps</> command,
4222 or in Windows by using the <application>Process Explorer</>.
4223 Only superusers can change this setting.
4228 <varlistentry id="guc-stats-temp-directory" xreflabel="stats_temp_directory">
4229 <term><varname>stats_temp_directory</varname> (<type>string</type>)</term>
4231 <primary><varname>stats_temp_directory</> configuration parameter</primary>
4235 Sets the directory to store temporary statistics data in. This can be
4236 a path relative to the data directory or an absolute path. The default
4237 is <filename>pg_stat_tmp</filename>. Pointing this at a RAM-based
4238 file system will decrease physical I/O requirements and can lead to
4239 improved performance.
4240 This parameter can only be set in the <filename>postgresql.conf</>
4241 file or on the server command line.
4249 <sect2 id="runtime-config-statistics-monitor">
4250 <title>Statistics Monitoring</title>
4254 <term><varname>log_statement_stats</varname> (<type>boolean</type>)</term>
4255 <term><varname>log_parser_stats</varname> (<type>boolean</type>)</term>
4256 <term><varname>log_planner_stats</varname> (<type>boolean</type>)</term>
4257 <term><varname>log_executor_stats</varname> (<type>boolean</type>)</term>
4259 <primary><varname>log_statement_stats</> configuration parameter</primary>
4262 <primary><varname>log_parser_stats</> configuration parameter</primary>
4265 <primary><varname>log_planner_stats</> configuration parameter</primary>
4268 <primary><varname>log_executor_stats</> configuration parameter</primary>
4272 For each query, output performance statistics of the respective
4273 module to the server log. This is a crude profiling
4274 instrument, similar to the Unix <function>getrusage()</> operating
4275 system facility. <varname>log_statement_stats</varname> reports total
4276 statement statistics, while the others report per-module statistics.
4277 <varname>log_statement_stats</varname> cannot be enabled together with
4278 any of the per-module options. All of these options are disabled by
4279 default. Only superusers can change these settings.
4289 <sect1 id="runtime-config-autovacuum">
4290 <title>Automatic Vacuuming</title>
4293 <primary>autovacuum</primary>
4294 <secondary>configuration parameters</secondary>
4298 These settings control the behavior of the <firstterm>autovacuum</>
4299 feature. Refer to <xref linkend="autovacuum"> for
4305 <varlistentry id="guc-autovacuum" xreflabel="autovacuum">
4306 <term><varname>autovacuum</varname> (<type>boolean</type>)</term>
4308 <primary><varname>autovacuum</> configuration parameter</primary>
4312 Controls whether the server should run the
4313 autovacuum launcher daemon. This is on by default; however,
4314 <xref linkend="guc-track-counts"> must also be enabled for
4316 This parameter can only be set in the <filename>postgresql.conf</>
4317 file or on the server command line.
4320 Note that even when this parameter is disabled, the system
4321 will launch autovacuum processes if necessary to
4322 prevent transaction ID wraparound. See <xref
4323 linkend="vacuum-for-wraparound"> for more information.
4328 <varlistentry id="guc-log-autovacuum-min-duration" xreflabel="log_autovacuum_min_duration">
4329 <term><varname>log_autovacuum_min_duration</varname> (<type>integer</type>)</term>
4331 <primary><varname>log_autovacuum_min_duration</> configuration parameter</primary>
4335 Causes each action executed by autovacuum to be logged if it ran for at
4336 least the specified number of milliseconds. Setting this to zero logs
4337 all autovacuum actions. Minus-one (the default) disables logging
4338 autovacuum actions. For example, if you set this to
4339 <literal>250ms</literal> then all automatic vacuums and analyzes that run
4340 250ms or longer will be logged. In addition, when this parameter is
4341 set to any value other than <literal>-1</literal>, a message will be
4342 logged if an autovacuum action is skipped due to the existence of a
4343 conflicting lock. Enabling this parameter can be helpful
4344 in tracking autovacuum activity. This setting can only be set in
4345 the <filename>postgresql.conf</> file or on the server command line.
4350 <varlistentry id="guc-autovacuum-max-workers" xreflabel="autovacuum_max_workers">
4351 <term><varname>autovacuum_max_workers</varname> (<type>integer</type>)</term>
4353 <primary><varname>autovacuum_max_workers</> configuration parameter</primary>
4357 Specifies the maximum number of autovacuum processes (other than the
4358 autovacuum launcher) which may be running at any one time. The default
4359 is three. This parameter can only be set at server start.
4364 <varlistentry id="guc-autovacuum-naptime" xreflabel="autovacuum_naptime">
4365 <term><varname>autovacuum_naptime</varname> (<type>integer</type>)</term>
4367 <primary><varname>autovacuum_naptime</> configuration parameter</primary>
4371 Specifies the minimum delay between autovacuum runs on any given
4372 database. In each round the daemon examines the
4373 database and issues <command>VACUUM</> and <command>ANALYZE</> commands
4374 as needed for tables in that database. The delay is measured
4375 in seconds, and the default is one minute (<literal>1min</>).
4376 This parameter can only be set in the <filename>postgresql.conf</>
4377 file or on the server command line.
4382 <varlistentry id="guc-autovacuum-vacuum-threshold" xreflabel="autovacuum_vacuum_threshold">
4383 <term><varname>autovacuum_vacuum_threshold</varname> (<type>integer</type>)</term>
4385 <primary><varname>autovacuum_vacuum_threshold</> configuration parameter</primary>
4389 Specifies the minimum number of updated or deleted tuples needed
4390 to trigger a <command>VACUUM</> in any one table.
4391 The default is 50 tuples.
4392 This parameter can only be set in the <filename>postgresql.conf</>
4393 file or on the server command line.
4394 This setting can be overridden for individual tables by
4395 changing storage parameters.
4400 <varlistentry id="guc-autovacuum-analyze-threshold" xreflabel="autovacuum_analyze_threshold">
4401 <term><varname>autovacuum_analyze_threshold</varname> (<type>integer</type>)</term>
4403 <primary><varname>autovacuum_analyze_threshold</> configuration parameter</primary>
4407 Specifies the minimum number of inserted, updated or deleted tuples
4408 needed to trigger an <command>ANALYZE</> in any one table.
4409 The default is 50 tuples.
4410 This parameter can only be set in the <filename>postgresql.conf</>
4411 file or on the server command line.
4412 This setting can be overridden for individual tables by
4413 changing storage parameters.
4418 <varlistentry id="guc-autovacuum-vacuum-scale-factor" xreflabel="autovacuum_vacuum_scale_factor">
4419 <term><varname>autovacuum_vacuum_scale_factor</varname> (<type>floating point</type>)</term>
4421 <primary><varname>autovacuum_vacuum_scale_factor</> configuration parameter</primary>
4425 Specifies a fraction of the table size to add to
4426 <varname>autovacuum_vacuum_threshold</varname>
4427 when deciding whether to trigger a <command>VACUUM</>.
4428 The default is 0.2 (20% of table size).
4429 This parameter can only be set in the <filename>postgresql.conf</>
4430 file or on the server command line.
4431 This setting can be overridden for individual tables by
4432 changing storage parameters.
4437 <varlistentry id="guc-autovacuum-analyze-scale-factor" xreflabel="autovacuum_analyze_scale_factor">
4438 <term><varname>autovacuum_analyze_scale_factor</varname> (<type>floating point</type>)</term>
4440 <primary><varname>autovacuum_analyze_scale_factor</> configuration parameter</primary>
4444 Specifies a fraction of the table size to add to
4445 <varname>autovacuum_analyze_threshold</varname>
4446 when deciding whether to trigger an <command>ANALYZE</>.
4447 The default is 0.1 (10% of table size).
4448 This parameter can only be set in the <filename>postgresql.conf</>
4449 file or on the server command line.
4450 This setting can be overridden for individual tables by
4451 changing storage parameters.
4456 <varlistentry id="guc-autovacuum-freeze-max-age" xreflabel="autovacuum_freeze_max_age">
4457 <term><varname>autovacuum_freeze_max_age</varname> (<type>integer</type>)</term>
4459 <primary><varname>autovacuum_freeze_max_age</> configuration parameter</primary>
4463 Specifies the maximum age (in transactions) that a table's
4464 <structname>pg_class</>.<structfield>relfrozenxid</> field can
4465 attain before a <command>VACUUM</> operation is forced
4466 to prevent transaction ID wraparound within the table.
4467 Note that the system will launch autovacuum processes to
4468 prevent wraparound even when autovacuum is otherwise disabled.
4472 Vacuum also allows removal of old files from the
4473 <filename>pg_clog</> subdirectory, which is why the default
4474 is a relatively low 200 million transactions.
4475 This parameter can only be set at server start, but the setting
4476 can be reduced for individual tables by
4477 changing storage parameters.
4478 For more information see <xref linkend="vacuum-for-wraparound">.
4483 <varlistentry id="guc-autovacuum-vacuum-cost-delay" xreflabel="autovacuum_vacuum_cost_delay">
4484 <term><varname>autovacuum_vacuum_cost_delay</varname> (<type>integer</type>)</term>
4486 <primary><varname>autovacuum_vacuum_cost_delay</> configuration parameter</primary>
4490 Specifies the cost delay value that will be used in automatic
4491 <command>VACUUM</> operations. If -1 is specified, the regular
4492 <xref linkend="guc-vacuum-cost-delay"> value will be used.
4493 The default value is 20 milliseconds.
4494 This parameter can only be set in the <filename>postgresql.conf</>
4495 file or on the server command line.
4496 This setting can be overridden for individual tables by
4497 changing storage parameters.
4502 <varlistentry id="guc-autovacuum-vacuum-cost-limit" xreflabel="autovacuum_vacuum_cost_limit">
4503 <term><varname>autovacuum_vacuum_cost_limit</varname> (<type>integer</type>)</term>
4505 <primary><varname>autovacuum_vacuum_cost_limit</> configuration parameter</primary>
4509 Specifies the cost limit value that will be used in automatic
4510 <command>VACUUM</> operations. If -1 is specified (which is the
4511 default), the regular
4512 <xref linkend="guc-vacuum-cost-limit"> value will be used. Note that
4513 the value is distributed proportionally among the running autovacuum
4514 workers, if there is more than one, so that the sum of the limits of
4515 each worker never exceeds the limit on this variable.
4516 This parameter can only be set in the <filename>postgresql.conf</>
4517 file or on the server command line.
4518 This setting can be overridden for individual tables by
4519 changing storage parameters.
4527 <sect1 id="runtime-config-client">
4528 <title>Client Connection Defaults</title>
4530 <sect2 id="runtime-config-client-statement">
4531 <title>Statement Behavior</title>
4534 <varlistentry id="guc-search-path" xreflabel="search_path">
4535 <term><varname>search_path</varname> (<type>string</type>)</term>
4537 <primary><varname>search_path</> configuration parameter</primary>
4539 <indexterm><primary>path</><secondary>for schemas</></>
4542 This variable specifies the order in which schemas are searched
4543 when an object (table, data type, function, etc.) is referenced by a
4544 simple name with no schema specified. When there are objects of
4545 identical names in different schemas, the one found first
4546 in the search path is used. An object that is not in any of the
4547 schemas in the search path can only be referenced by specifying
4548 its containing schema with a qualified (dotted) name.
4552 The value for <varname>search_path</varname> must be a comma-separated
4553 list of schema names. If one of the list items is
4554 the special value <literal>$user</literal>, then the schema
4555 having the name returned by <function>SESSION_USER</> is substituted, if there
4556 is such a schema. (If not, <literal>$user</literal> is ignored.)
4560 The system catalog schema, <literal>pg_catalog</>, is always
4561 searched, whether it is mentioned in the path or not. If it is
4562 mentioned in the path then it will be searched in the specified
4563 order. If <literal>pg_catalog</> is not in the path then it will
4564 be searched <emphasis>before</> searching any of the path items.
4568 Likewise, the current session's temporary-table schema,
4569 <literal>pg_temp_<replaceable>nnn</></>, is always searched if it
4570 exists. It can be explicitly listed in the path by using the
4571 alias <literal>pg_temp</>. If it is not listed in the path then
4572 it is searched first (even before <literal>pg_catalog</>). However,
4573 the temporary schema is only searched for relation (table, view,
4574 sequence, etc) and data type names. It is never searched for
4575 function or operator names.
4579 When objects are created without specifying a particular target
4580 schema, they will be placed in the first schema listed
4581 in the search path. An error is reported if the search path is
4586 The default value for this parameter is
4587 <literal>'"$user", public'</literal> (where the second part will be
4588 ignored if there is no schema named <literal>public</>).
4589 This supports shared use of a database (where no users
4590 have private schemas, and all share use of <literal>public</>),
4591 private per-user schemas, and combinations of these. Other
4592 effects can be obtained by altering the default search path
4593 setting, either globally or per-user.
4597 The current effective value of the search path can be examined
4598 via the <acronym>SQL</acronym> function
4599 <function>current_schemas</>
4600 (see <xref linkend="functions-info">).
4601 This is not quite the same as
4602 examining the value of <varname>search_path</varname>, since
4603 <function>current_schemas</> shows how the items
4604 appearing in <varname>search_path</varname> were resolved.
4608 For more information on schema handling, see <xref linkend="ddl-schemas">.
4613 <varlistentry id="guc-default-tablespace" xreflabel="default_tablespace">
4614 <term><varname>default_tablespace</varname> (<type>string</type>)</term>
4616 <primary><varname>default_tablespace</> configuration parameter</primary>
4618 <indexterm><primary>tablespace</><secondary>default</></>
4621 This variable specifies the default tablespace in which to create
4622 objects (tables and indexes) when a <command>CREATE</> command does
4623 not explicitly specify a tablespace.
4627 The value is either the name of a tablespace, or an empty string
4628 to specify using the default tablespace of the current database.
4629 If the value does not match the name of any existing tablespace,
4630 <productname>PostgreSQL</> will automatically use the default
4631 tablespace of the current database. If a nondefault tablespace
4632 is specified, the user must have <literal>CREATE</> privilege
4633 for it, or creation attempts will fail.
4637 This variable is not used for temporary tables; for them,
4638 <xref linkend="guc-temp-tablespaces"> is consulted instead.
4642 This variable is also not used when creating databases.
4643 By default, a new database inherits its tablespace setting from
4644 the template database it is copied from.
4648 For more information on tablespaces,
4649 see <xref linkend="manage-ag-tablespaces">.
4654 <varlistentry id="guc-temp-tablespaces" xreflabel="temp_tablespaces">
4655 <term><varname>temp_tablespaces</varname> (<type>string</type>)</term>
4657 <primary><varname>temp_tablespaces</> configuration parameter</primary>
4659 <indexterm><primary>tablespace</><secondary>temporary</></>
4662 This variable specifies tablespaces in which to create temporary
4663 objects (temp tables and indexes on temp tables) when a
4664 <command>CREATE</> command does not explicitly specify a tablespace.
4665 Temporary files for purposes such as sorting large data sets
4666 are also created in these tablespaces.
4670 The value is a list of names of tablespaces. When there is more than
4671 one name in the list, <productname>PostgreSQL</> chooses a random
4672 member of the list each time a temporary object is to be created;
4673 except that within a transaction, successively created temporary
4674 objects are placed in successive tablespaces from the list.
4675 If the selected element of the list is an empty string,
4676 <productname>PostgreSQL</> will automatically use the default
4677 tablespace of the current database instead.
4681 When <varname>temp_tablespaces</> is set interactively, specifying a
4682 nonexistent tablespace is an error, as is specifying a tablespace for
4683 which the user does not have <literal>CREATE</> privilege. However,
4684 when using a previously set value, nonexistent tablespaces are
4685 ignored, as are tablespaces for which the user lacks
4686 <literal>CREATE</> privilege. In particular, this rule applies when
4687 using a value set in <filename>postgresql.conf</>.
4691 The default value is an empty string, which results in all temporary
4692 objects being created in the default tablespace of the current
4697 See also <xref linkend="guc-default-tablespace">.
4702 <varlistentry id="guc-check-function-bodies" xreflabel="check_function_bodies">
4703 <term><varname>check_function_bodies</varname> (<type>boolean</type>)</term>
4705 <primary><varname>check_function_bodies</> configuration parameter</primary>
4709 This parameter is normally on. When set to <literal>off</>, it
4710 disables validation of the function body string during <xref
4711 linkend="sql-createfunction">. Disabling validation is
4712 occasionally useful to avoid problems such as forward references
4713 when restoring function definitions from a dump.
4718 <varlistentry id="guc-default-transaction-isolation" xreflabel="default_transaction_isolation">
4720 <primary>transaction isolation level</primary>
4721 <secondary>setting default</secondary>
4724 <primary><varname>default_transaction_isolation</> configuration parameter</primary>
4726 <term><varname>default_transaction_isolation</varname> (<type>enum</type>)</term>
4729 Each SQL transaction has an isolation level, which can be
4730 either <quote>read uncommitted</quote>, <quote>read
4731 committed</quote>, <quote>repeatable read</quote>, or
4732 <quote>serializable</quote>. This parameter controls the
4733 default isolation level of each new transaction. The default
4734 is <quote>read committed</quote>.
4738 Consult <xref linkend="mvcc"> and <xref
4739 linkend="sql-set-transaction"> for more information.
4744 <varlistentry id="guc-default-transaction-read-only" xreflabel="default_transaction_read_only">
4746 <primary>read-only transaction</primary>
4747 <secondary>setting default</secondary>
4750 <primary><varname>default_transaction_read_only</> configuration parameter</primary>
4753 <term><varname>default_transaction_read_only</varname> (<type>boolean</type>)</term>
4756 A read-only SQL transaction cannot alter non-temporary tables.
4757 This parameter controls the default read-only status of each new
4758 transaction. The default is <literal>off</> (read/write).
4762 Consult <xref linkend="sql-set-transaction"> for more information.
4767 <varlistentry id="guc-default-transaction-deferrable" xreflabel="default_transaction_deferrable">
4769 <primary>deferrable transaction</primary>
4770 <secondary>setting default</secondary>
4773 <primary><varname>default_transaction_deferrable</> configuration parameter</primary>
4776 <term><varname>default_transaction_deferrable</varname> (<type>boolean</type>)</term>
4779 When running at the <literal>serializable</> isolation level,
4780 a deferrable read-only SQL transaction may be delayed before
4781 it is allowed to proceed. However, once it begins executing
4782 it does not incur any of the overhead required to ensure
4783 serializability; so serialization code will have no reason to
4784 force it to abort because of concurrent updates, making this
4785 option suitable for long-running read-only transactions.
4789 This parameter controls the default deferrable status of each
4790 new transaction. It currently has no effect on read-write
4791 transactions or those operating at isolation levels lower
4792 than <literal>serializable</>. The default is <literal>off</>.
4796 Consult <xref linkend="sql-set-transaction"> for more information.
4802 <varlistentry id="guc-session-replication-role" xreflabel="session_replication_role">
4803 <term><varname>session_replication_role</varname> (<type>enum</type>)</term>
4805 <primary><varname>session_replication_role</> configuration parameter</primary>
4809 Controls firing of replication-related triggers and rules for the
4810 current session. Setting this variable requires
4811 superuser privilege and results in discarding any previously cached
4812 query plans. Possible values are <literal>origin</> (the default),
4813 <literal>replica</> and <literal>local</>.
4814 See <xref linkend="sql-altertable"> for
4820 <varlistentry id="guc-statement-timeout" xreflabel="statement_timeout">
4821 <term><varname>statement_timeout</varname> (<type>integer</type>)</term>
4823 <primary><varname>statement_timeout</> configuration parameter</primary>
4827 Abort any statement that takes over the specified number of
4828 milliseconds, starting from the time the command arrives at the server
4829 from the client. If <varname>log_min_error_statement</> is set to
4830 <literal>ERROR</> or lower, the statement that timed out will also be
4831 logged. A value of zero (the default) turns this off.
4835 Setting <varname>statement_timeout</> in
4836 <filename>postgresql.conf</> is not recommended because it
4837 affects all sessions.
4842 <varlistentry id="guc-vacuum-freeze-table-age" xreflabel="vacuum_freeze_table_age">
4843 <term><varname>vacuum_freeze_table_age</varname> (<type>integer</type>)</term>
4845 <primary><varname>vacuum_freeze_table_age</> configuration parameter</primary>
4849 <command>VACUUM</> performs a whole-table scan if the table's
4850 <structname>pg_class</>.<structfield>relfrozenxid</> field has reached
4851 the age specified by this setting. The default is 150 million
4852 transactions. Although users can set this value anywhere from zero to
4853 one billion, <command>VACUUM</> will silently limit the effective value
4854 to 95% of <xref linkend="guc-autovacuum-freeze-max-age">, so that a
4855 periodical manual <command>VACUUM</> has a chance to run before an
4856 anti-wraparound autovacuum is launched for the table. For more
4858 <xref linkend="vacuum-for-wraparound">.
4863 <varlistentry id="guc-vacuum-freeze-min-age" xreflabel="vacuum_freeze_min_age">
4864 <term><varname>vacuum_freeze_min_age</varname> (<type>integer</type>)</term>
4866 <primary><varname>vacuum_freeze_min_age</> configuration parameter</primary>
4870 Specifies the cutoff age (in transactions) that <command>VACUUM</>
4871 should use to decide whether to replace transaction IDs with
4872 <literal>FrozenXID</> while scanning a table.
4873 The default is 50 million transactions. Although
4874 users can set this value anywhere from zero to one billion,
4875 <command>VACUUM</> will silently limit the effective value to half
4876 the value of <xref linkend="guc-autovacuum-freeze-max-age">, so
4877 that there is not an unreasonably short time between forced
4878 autovacuums. For more information see <xref
4879 linkend="vacuum-for-wraparound">.
4884 <varlistentry id="guc-bytea-output" xreflabel="bytea_output">
4885 <term><varname>bytea_output</varname> (<type>enum</type>)</term>
4887 <primary><varname>bytea_output</> configuration parameter</primary>
4891 Sets the output format for values of type <type>bytea</type>.
4892 Valid values are <literal>hex</literal> (the default)
4893 and <literal>escape</literal> (the traditional PostgreSQL
4894 format). See <xref linkend="datatype-binary"> for more
4895 information. The <type>bytea</type> type always
4896 accepts both formats on input, regardless of this setting.
4901 <varlistentry id="guc-xmlbinary" xreflabel="xmlbinary">
4902 <term><varname>xmlbinary</varname> (<type>enum</type>)</term>
4904 <primary><varname>xmlbinary</> configuration parameter</primary>
4908 Sets how binary values are to be encoded in XML. This applies
4909 for example when <type>bytea</type> values are converted to
4910 XML by the functions <function>xmlelement</function> or
4911 <function>xmlforest</function>. Possible values are
4912 <literal>base64</literal> and <literal>hex</literal>, which
4913 are both defined in the XML Schema standard. The default is
4914 <literal>base64</literal>. For further information about
4915 XML-related functions, see <xref linkend="functions-xml">.
4919 The actual choice here is mostly a matter of taste,
4920 constrained only by possible restrictions in client
4921 applications. Both methods support all possible values,
4922 although the hex encoding will be somewhat larger than the
4928 <varlistentry id="guc-xmloption" xreflabel="xmloption">
4929 <term><varname>xmloption</varname> (<type>enum</type>)</term>
4931 <primary><varname>xmloption</> configuration parameter</primary>
4934 <primary><varname>SET XML OPTION</></primary>
4937 <primary>XML option</primary>
4941 Sets whether <literal>DOCUMENT</literal> or
4942 <literal>CONTENT</literal> is implicit when converting between
4943 XML and character string values. See <xref
4944 linkend="datatype-xml"> for a description of this. Valid
4945 values are <literal>DOCUMENT</literal> and
4946 <literal>CONTENT</literal>. The default is
4947 <literal>CONTENT</literal>.
4951 According to the SQL standard, the command to set this option is
4953 SET XML OPTION { DOCUMENT | CONTENT };
4955 This syntax is also available in PostgreSQL.
4962 <sect2 id="runtime-config-client-format">
4963 <title>Locale and Formatting</title>
4967 <varlistentry id="guc-datestyle" xreflabel="DateStyle">
4968 <term><varname>DateStyle</varname> (<type>string</type>)</term>
4970 <primary><varname>DateStyle</> configuration parameter</primary>
4974 Sets the display format for date and time values, as well as the
4975 rules for interpreting ambiguous date input values. For
4976 historical reasons, this variable contains two independent
4977 components: the output format specification (<literal>ISO</>,
4978 <literal>Postgres</>, <literal>SQL</>, or <literal>German</>)
4979 and the input/output specification for year/month/day ordering
4980 (<literal>DMY</>, <literal>MDY</>, or <literal>YMD</>). These
4981 can be set separately or together. The keywords <literal>Euro</>
4982 and <literal>European</> are synonyms for <literal>DMY</>; the
4983 keywords <literal>US</>, <literal>NonEuro</>, and
4984 <literal>NonEuropean</> are synonyms for <literal>MDY</>. See
4985 <xref linkend="datatype-datetime"> for more information. The
4986 built-in default is <literal>ISO, MDY</>, but
4987 <application>initdb</application> will initialize the
4988 configuration file with a setting that corresponds to the
4989 behavior of the chosen <varname>lc_time</varname> locale.
4994 <varlistentry id="guc-intervalstyle" xreflabel="IntervalStyle">
4995 <term><varname>IntervalStyle</varname> (<type>enum</type>)</term>
4997 <primary><varname>IntervalStyle</> configuration parameter</primary>
5001 Sets the display format for interval values.
5002 The value <literal>sql_standard</> will produce
5003 output matching <acronym>SQL</acronym> standard interval literals.
5004 The value <literal>postgres</> (which is the default) will produce
5005 output matching <productname>PostgreSQL</> releases prior to 8.4
5006 when the <xref linkend="guc-datestyle">
5007 parameter was set to <literal>ISO</>.
5008 The value <literal>postgres_verbose</> will produce output
5009 matching <productname>PostgreSQL</> releases prior to 8.4
5010 when the <varname>DateStyle</>
5011 parameter was set to non-<literal>ISO</> output.
5012 The value <literal>iso_8601</> will produce output matching the time
5013 interval <quote>format with designators</> defined in section
5014 4.4.3.2 of ISO 8601.
5017 The <varname>IntervalStyle</> parameter also affects the
5018 interpretation of ambiguous interval input. See
5019 <xref linkend="datatype-interval-input"> for more information.
5024 <varlistentry id="guc-timezone" xreflabel="timezone">
5025 <term><varname>timezone</varname> (<type>string</type>)</term>
5027 <primary><varname>timezone</> configuration parameter</primary>
5029 <indexterm><primary>time zone</></>
5032 Sets the time zone for displaying and interpreting time stamps.
5033 The built-in default is <literal>GMT</>, but that is typically
5034 overridden in <filename>postgresql.conf</>; <application>initdb</>
5035 will install a setting there corresponding to its system environment.
5036 See <xref linkend="datatype-timezones"> for more information.
5041 <varlistentry id="guc-timezone-abbreviations" xreflabel="timezone_abbreviations">
5042 <term><varname>timezone_abbreviations</varname> (<type>string</type>)</term>
5044 <primary><varname>timezone_abbreviations</> configuration parameter</primary>
5046 <indexterm><primary>time zone names</></>
5049 Sets the collection of time zone abbreviations that will be accepted
5050 by the server for datetime input. The default is <literal>'Default'</>,
5051 which is a collection that works in most of the world; there are
5052 also <literal>'Australia'</literal> and <literal>'India'</literal>, and other collections can be defined
5053 for a particular installation. See <xref
5054 linkend="datetime-appendix"> for more information.
5059 <varlistentry id="guc-extra-float-digits" xreflabel="extra_float_digits">
5061 <primary>significant digits</primary>
5064 <primary>floating-point</primary>
5065 <secondary>display</secondary>
5068 <primary><varname>extra_float_digits</> configuration parameter</primary>
5071 <term><varname>extra_float_digits</varname> (<type>integer</type>)</term>
5074 This parameter adjusts the number of digits displayed for
5075 floating-point values, including <type>float4</>, <type>float8</>,
5076 and geometric data types. The parameter value is added to the
5077 standard number of digits (<literal>FLT_DIG</> or <literal>DBL_DIG</>
5078 as appropriate). The value can be set as high as 3, to include
5079 partially-significant digits; this is especially useful for dumping
5080 float data that needs to be restored exactly. Or it can be set
5081 negative to suppress unwanted digits.
5086 <varlistentry id="guc-client-encoding" xreflabel="client_encoding">
5087 <term><varname>client_encoding</varname> (<type>string</type>)</term>
5089 <primary><varname>client_encoding</> configuration parameter</primary>
5091 <indexterm><primary>character set</></>
5094 Sets the client-side encoding (character set).
5095 The default is to use the database encoding.
5096 The character sets supported by the <productname>PostgreSQL</productname>
5097 server are described in <xref linkend="multibyte-charset-supported">.
5102 <varlistentry id="guc-lc-messages" xreflabel="lc_messages">
5103 <term><varname>lc_messages</varname> (<type>string</type>)</term>
5105 <primary><varname>lc_messages</> configuration parameter</primary>
5109 Sets the language in which messages are displayed. Acceptable
5110 values are system-dependent; see <xref linkend="locale"> for
5111 more information. If this variable is set to the empty string
5112 (which is the default) then the value is inherited from the
5113 execution environment of the server in a system-dependent way.
5117 On some systems, this locale category does not exist. Setting
5118 this variable will still work, but there will be no effect.
5119 Also, there is a chance that no translated messages for the
5120 desired language exist. In that case you will continue to see
5121 the English messages.
5125 Only superusers can change this setting, because it affects the
5126 messages sent to the server log as well as to the client, and
5127 an improper value might obscure the readability of the server
5133 <varlistentry id="guc-lc-monetary" xreflabel="lc_monetary">
5134 <term><varname>lc_monetary</varname> (<type>string</type>)</term>
5136 <primary><varname>lc_monetary</> configuration parameter</primary>
5140 Sets the locale to use for formatting monetary amounts, for
5141 example with the <function>to_char</function> family of
5142 functions. Acceptable values are system-dependent; see <xref
5143 linkend="locale"> for more information. If this variable is
5144 set to the empty string (which is the default) then the value
5145 is inherited from the execution environment of the server in a
5146 system-dependent way.
5151 <varlistentry id="guc-lc-numeric" xreflabel="lc_numeric">
5152 <term><varname>lc_numeric</varname> (<type>string</type>)</term>
5154 <primary><varname>lc_numeric</> configuration parameter</primary>
5158 Sets the locale to use for formatting numbers, for example
5159 with the <function>to_char</function> family of
5160 functions. Acceptable values are system-dependent; see <xref
5161 linkend="locale"> for more information. If this variable is
5162 set to the empty string (which is the default) then the value
5163 is inherited from the execution environment of the server in a
5164 system-dependent way.
5169 <varlistentry id="guc-lc-time" xreflabel="lc_time">
5170 <term><varname>lc_time</varname> (<type>string</type>)</term>
5172 <primary><varname>lc_time</> configuration parameter</primary>
5176 Sets the locale to use for formatting dates and times, for example
5177 with the <function>to_char</function> family of
5178 functions. Acceptable values are system-dependent; see <xref
5179 linkend="locale"> for more information. If this variable is
5180 set to the empty string (which is the default) then the value
5181 is inherited from the execution environment of the server in a
5182 system-dependent way.
5187 <varlistentry id="guc-default-text-search-config" xreflabel="default_text_search_config">
5188 <term><varname>default_text_search_config</varname> (<type>string</type>)</term>
5190 <primary><varname>default_text_search_config</> configuration parameter</primary>
5194 Selects the text search configuration that is used by those variants
5195 of the text search functions that do not have an explicit argument
5196 specifying the configuration.
5197 See <xref linkend="textsearch"> for further information.
5198 The built-in default is <literal>pg_catalog.simple</>, but
5199 <application>initdb</application> will initialize the
5200 configuration file with a setting that corresponds to the
5201 chosen <varname>lc_ctype</varname> locale, if a configuration
5202 matching that locale can be identified.
5210 <sect2 id="runtime-config-client-other">
5211 <title>Other Defaults</title>
5215 <varlistentry id="guc-dynamic-library-path" xreflabel="dynamic_library_path">
5216 <term><varname>dynamic_library_path</varname> (<type>string</type>)</term>
5218 <primary><varname>dynamic_library_path</> configuration parameter</primary>
5220 <indexterm><primary>dynamic loading</></>
5223 If a dynamically loadable module needs to be opened and the
5224 file name specified in the <command>CREATE FUNCTION</command> or
5225 <command>LOAD</command> command
5226 does not have a directory component (i.e., the
5227 name does not contain a slash), the system will search this
5228 path for the required file.
5232 The value for <varname>dynamic_library_path</varname> must be a
5233 list of absolute directory paths separated by colons (or semi-colons
5234 on Windows). If a list element starts
5235 with the special string <literal>$libdir</literal>, the
5236 compiled-in <productname>PostgreSQL</productname> package
5237 library directory is substituted for <literal>$libdir</literal>; this
5238 is where the modules provided by the standard
5239 <productname>PostgreSQL</productname> distribution are installed.
5240 (Use <literal>pg_config --pkglibdir</literal> to find out the name of
5241 this directory.) For example:
5243 dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
5245 or, in a Windows environment:
5247 dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
5252 The default value for this parameter is
5253 <literal>'$libdir'</literal>. If the value is set to an empty
5254 string, the automatic path search is turned off.
5258 This parameter can be changed at run time by superusers, but a
5259 setting done that way will only persist until the end of the
5260 client connection, so this method should be reserved for
5261 development purposes. The recommended way to set this parameter
5262 is in the <filename>postgresql.conf</filename> configuration
5268 <varlistentry id="guc-gin-fuzzy-search-limit" xreflabel="gin_fuzzy_search_limit">
5269 <term><varname>gin_fuzzy_search_limit</varname> (<type>integer</type>)</term>
5271 <primary><varname>gin_fuzzy_search_limit</> configuration parameter</primary>
5275 Soft upper limit of the size of the set returned by GIN index scans. For more
5276 information see <xref linkend="gin-tips">.
5281 <varlistentry id="guc-local-preload-libraries" xreflabel="local_preload_libraries">
5282 <term><varname>local_preload_libraries</varname> (<type>string</type>)</term>
5284 <primary><varname>local_preload_libraries</> configuration parameter</primary>
5287 <primary><filename>$libdir/plugins</></primary>
5291 This variable specifies one or more shared libraries that are
5292 to be preloaded at connection start. If more than one library
5293 is to be loaded, separate their names with commas. All library
5294 names are converted to lower case unless double-quoted.
5295 This parameter cannot be changed after the start of a particular
5300 Because this is not a superuser-only option, the libraries
5301 that can be loaded are restricted to those appearing in the
5302 <filename>plugins</> subdirectory of the installation's
5303 standard library directory. (It is the database administrator's
5304 responsibility to ensure that only <quote>safe</> libraries
5305 are installed there.) Entries in <varname>local_preload_libraries</>
5306 can specify this directory explicitly, for example
5307 <literal>$libdir/plugins/mylib</literal>, or just specify
5308 the library name — <literal>mylib</literal> would have
5309 the same effect as <literal>$libdir/plugins/mylib</literal>.
5313 Unlike <xref linkend="guc-shared-preload-libraries">, there is no
5314 performance advantage to loading a library at session
5315 start rather than when it is first used. Rather, the intent of
5316 this feature is to allow debugging or performance-measurement
5317 libraries to be loaded into specific sessions without an explicit
5318 <command>LOAD</> command being given. For example, debugging could
5319 be enabled for all sessions under a given user name by setting
5320 this parameter with <command>ALTER ROLE SET</>.
5324 If a specified library is not found,
5325 the connection attempt will fail.
5329 Every PostgreSQL-supported library has a <quote>magic
5330 block</> that is checked to guarantee compatibility.
5331 For this reason, non-PostgreSQL libraries cannot be
5341 <sect1 id="runtime-config-locks">
5342 <title>Lock Management</title>
5346 <varlistentry id="guc-deadlock-timeout" xreflabel="deadlock_timeout">
5348 <primary>deadlock</primary>
5349 <secondary>timeout during</secondary>
5352 <primary>timeout</primary>
5353 <secondary>deadlock</secondary>
5356 <primary><varname>deadlock_timeout</> configuration parameter</primary>
5359 <term><varname>deadlock_timeout</varname> (<type>integer</type>)</term>
5362 This is the amount of time, in milliseconds, to wait on a lock
5363 before checking to see if there is a deadlock condition. The
5364 check for deadlock is relatively expensive, so the server doesn't run
5365 it every time it waits for a lock. We optimistically assume
5366 that deadlocks are not common in production applications and
5367 just wait on the lock for a while before checking for a
5368 deadlock. Increasing this value reduces the amount of time
5369 wasted in needless deadlock checks, but slows down reporting of
5370 real deadlock errors. The default is one second (<literal>1s</>),
5371 which is probably about the smallest value you would want in
5372 practice. On a heavily loaded server you might want to raise it.
5373 Ideally the setting should exceed your typical transaction time,
5374 so as to improve the odds that a lock will be released before
5375 the waiter decides to check for deadlock. Only superusers can change
5380 When <xref linkend="guc-log-lock-waits"> is set,
5381 this parameter also determines the length of time to wait before
5382 a log message is issued about the lock wait. If you are trying
5383 to investigate locking delays you might want to set a shorter than
5384 normal <varname>deadlock_timeout</varname>.
5389 <varlistentry id="guc-max-locks-per-transaction" xreflabel="max_locks_per_transaction">
5390 <term><varname>max_locks_per_transaction</varname> (<type>integer</type>)</term>
5392 <primary><varname>max_locks_per_transaction</> configuration parameter</primary>
5396 The shared lock table tracks locks on
5397 <varname>max_locks_per_transaction</varname> * (<xref
5398 linkend="guc-max-connections"> + <xref
5399 linkend="guc-max-prepared-transactions">) objects (e.g., tables);
5400 hence, no more than this many distinct objects can be locked at
5401 any one time. This parameter controls the average number of object
5402 locks allocated for each transaction; individual transactions
5403 can lock more objects as long as the locks of all transactions
5404 fit in the lock table. This is <emphasis>not</> the number of
5405 rows that can be locked; that value is unlimited. The default,
5406 64, has historically proven sufficient, but you might need to
5407 raise this value if you have clients that touch many different
5408 tables in a single transaction. This parameter can only be set at
5413 Increasing this parameter might cause <productname>PostgreSQL</>
5414 to request more <systemitem class="osname">System V</> shared
5415 memory than your operating system's default configuration
5416 allows. See <xref linkend="sysvipc"> for information on how to
5417 adjust those parameters, if necessary.
5421 When running a standby server, you must set this parameter to the
5422 same or higher value than on the master server. Otherwise, queries
5423 will not be allowed in the standby server.
5428 <varlistentry id="guc-max-pred-locks-per-transaction" xreflabel="max_pred_locks_per_transaction">
5429 <term><varname>max_pred_locks_per_transaction</varname> (<type>integer</type>)</term>
5431 <primary><varname>max_pred_locks_per_transaction</> configuration parameter</primary>
5435 The shared predicate lock table tracks locks on
5436 <varname>max_pred_locks_per_transaction</varname> * (<xref
5437 linkend="guc-max-connections"> + <xref
5438 linkend="guc-max-prepared-transactions">) objects (e.g., tables);
5439 hence, no more than this many distinct objects can be locked at
5440 any one time. This parameter controls the average number of object
5441 locks allocated for each transaction; individual transactions
5442 can lock more objects as long as the locks of all transactions
5443 fit in the lock table. This is <emphasis>not</> the number of
5444 rows that can be locked; that value is unlimited. The default,
5445 64, has generally been sufficient in testing, but you might need to
5446 raise this value if you have clients that touch many different
5447 tables in a single serializable transaction. This parameter can
5448 only be set at server start.
5452 Increasing this parameter might cause <productname>PostgreSQL</>
5453 to request more <systemitem class="osname">System V</> shared
5454 memory than your operating system's default configuration
5455 allows. See <xref linkend="sysvipc"> for information on how to
5456 adjust those parameters, if necessary.
5464 <sect1 id="runtime-config-compatible">
5465 <title>Version and Platform Compatibility</title>
5467 <sect2 id="runtime-config-compatible-version">
5468 <title>Previous PostgreSQL Versions</title>
5472 <varlistentry id="guc-array-nulls" xreflabel="array_nulls">
5473 <term><varname>array_nulls</varname> (<type>boolean</type>)</term>
5475 <primary><varname>array_nulls</> configuration parameter</primary>
5479 This controls whether the array input parser recognizes
5480 unquoted <literal>NULL</> as specifying a null array element.
5481 By default, this is <literal>on</>, allowing array values containing
5482 null values to be entered. However, <productname>PostgreSQL</> versions
5483 before 8.2 did not support null values in arrays, and therefore would
5484 treat <literal>NULL</> as specifying a normal array element with
5485 the string value <quote>NULL</>. For backward compatibility with
5486 applications that require the old behavior, this variable can be
5487 turned <literal>off</>.
5491 Note that it is possible to create array values containing null values
5492 even when this variable is <literal>off</>.
5497 <varlistentry id="guc-backslash-quote" xreflabel="backslash_quote">
5498 <term><varname>backslash_quote</varname> (<type>enum</type>)</term>
5499 <indexterm><primary>strings</><secondary>backslash quotes</></>
5501 <primary><varname>backslash_quote</> configuration parameter</primary>
5505 This controls whether a quote mark can be represented by
5506 <literal>\'</> in a string literal. The preferred, SQL-standard way
5507 to represent a quote mark is by doubling it (<literal>''</>) but
5508 <productname>PostgreSQL</> has historically also accepted
5509 <literal>\'</>. However, use of <literal>\'</> creates security risks
5510 because in some client character set encodings, there are multibyte
5511 characters in which the last byte is numerically equivalent to ASCII
5512 <literal>\</>. If client-side code does escaping incorrectly then a
5513 SQL-injection attack is possible. This risk can be prevented by
5514 making the server reject queries in which a quote mark appears to be
5515 escaped by a backslash.
5516 The allowed values of <varname>backslash_quote</> are
5517 <literal>on</> (allow <literal>\'</> always),
5518 <literal>off</> (reject always), and
5519 <literal>safe_encoding</> (allow only if client encoding does not
5520 allow ASCII <literal>\</> within a multibyte character).
5521 <literal>safe_encoding</> is the default setting.
5525 Note that in a standard-conforming string literal, <literal>\</> just
5526 means <literal>\</> anyway. This parameter only affects the handling of
5527 non-standard-conforming literals, including
5528 escape string syntax (<literal>E'...'</>).
5533 <varlistentry id="guc-default-with-oids" xreflabel="default_with_oids">
5534 <term><varname>default_with_oids</varname> (<type>boolean</type>)</term>
5536 <primary><varname>default_with_oids</> configuration parameter</primary>
5540 This controls whether <command>CREATE TABLE</command> and
5541 <command>CREATE TABLE AS</command> include an OID column in
5542 newly-created tables, if neither <literal>WITH OIDS</literal>
5543 nor <literal>WITHOUT OIDS</literal> is specified. It also
5544 determines whether OIDs will be included in tables created by
5545 <command>SELECT INTO</command>. The parameter is <literal>off</>
5546 by default; in <productname>PostgreSQL</> 8.0 and earlier, it
5551 The use of OIDs in user tables is considered deprecated, so
5552 most installations should leave this variable disabled.
5553 Applications that require OIDs for a particular table should
5554 specify <literal>WITH OIDS</literal> when creating the
5555 table. This variable can be enabled for compatibility with old
5556 applications that do not follow this behavior.
5561 <varlistentry id="guc-escape-string-warning" xreflabel="escape_string_warning">
5562 <term><varname>escape_string_warning</varname> (<type>boolean</type>)</term>
5563 <indexterm><primary>strings</><secondary>escape warning</></>
5565 <primary><varname>escape_string_warning</> configuration parameter</primary>
5569 When on, a warning is issued if a backslash (<literal>\</>)
5570 appears in an ordinary string literal (<literal>'...'</>
5571 syntax) and <varname>standard_conforming_strings</varname> is off.
5572 The default is <literal>on</>.
5575 Applications that wish to use backslash as escape should be
5576 modified to use escape string syntax (<literal>E'...'</>),
5577 because the default behavior of ordinary strings is now to treat
5578 backslash as an ordinary character, per SQL standard. This variable
5579 can be enabled to help locate code that needs to be changed.
5584 <varlistentry id="guc-lo-compat-privileges" xreflabel="lo_compat_privileges">
5585 <term><varname>lo_compat_privileges</varname> (<type>boolean</type>)</term>
5587 <primary><varname>lo_compat_privileges</> configuration parameter</primary>
5591 In <productname>PostgreSQL</> releases prior to 9.0, large objects
5592 did not have access privileges and were, in effect, readable and
5593 writable by all users. Setting this variable to <literal>on</>
5594 disables the new privilege checks, for compatibility with prior
5595 releases. The default is <literal>off</>.
5598 Setting this variable does not disable all security checks related to
5599 large objects — only those for which the default behavior has
5600 changed in <productname>PostgreSQL</> 9.0.
5601 For example, <literal>lo_import()</literal> and
5602 <literal>lo_export()</literal> need superuser privileges independent
5608 <varlistentry id="guc-quote-all-identifiers" xreflabel="quote-all-identifiers">
5609 <term><varname>quote_all_identifiers</varname> (<type>boolean</type>)</term>
5611 <primary><varname>quote_all_identifiers</> configuration parameter</primary>
5615 When the database generates SQL, force all identifiers to be quoted,
5616 even if they are not (currently) keywords. This will affect the
5617 output of <command>EXPLAIN</> as well as the results of functions
5618 like <function>pg_get_viewdef</>. See also the
5619 <option>--quote-all-identifiers</option> option of
5620 <xref linkend="app-pgdump"> and <xref linkend="app-pg-dumpall">.
5625 <varlistentry id="guc-sql-inheritance" xreflabel="sql_inheritance">
5626 <term><varname>sql_inheritance</varname> (<type>boolean</type>)</term>
5628 <primary><varname>sql_inheritance</> configuration parameter</primary>
5630 <indexterm><primary>inheritance</></>
5633 This controls the inheritance semantics. If turned <literal>off</>,
5634 subtables are not accessed by various commands by default; basically
5635 an implied <literal>ONLY</literal> key word. This was added for
5636 compatibility with releases prior to 7.1. See
5637 <xref linkend="ddl-inherit"> for more information.
5642 <varlistentry id="guc-standard-conforming-strings" xreflabel="standard_conforming_strings">
5643 <term><varname>standard_conforming_strings</varname> (<type>boolean</type>)</term>
5644 <indexterm><primary>strings</><secondary>standard conforming</></>
5646 <primary><varname>standard_conforming_strings</> configuration parameter</primary>
5650 This controls whether ordinary string literals
5651 (<literal>'...'</>) treat backslashes literally, as specified in
5653 Beginning in <productname>PostgreSQL</productname> 9.1, the default is
5654 <literal>on</> (prior releases defaulted to <literal>off</>).
5655 Applications can check this
5656 parameter to determine how string literals will be processed.
5657 The presence of this parameter can also be taken as an indication
5658 that the escape string syntax (<literal>E'...'</>) is supported.
5659 Escape string syntax (<xref linkend="sql-syntax-strings-escape">)
5660 should be used if an application desires
5661 backslashes to be treated as escape characters.
5666 <varlistentry id="guc-synchronize-seqscans" xreflabel="synchronize_seqscans">
5667 <term><varname>synchronize_seqscans</varname> (<type>boolean</type>)</term>
5669 <primary><varname>synchronize_seqscans</> configuration parameter</primary>
5673 This allows sequential scans of large tables to synchronize with each
5674 other, so that concurrent scans read the same block at about the
5675 same time and hence share the I/O workload. When this is enabled,
5676 a scan might start in the middle of the table and then <quote>wrap
5677 around</> the end to cover all rows, so as to synchronize with the
5678 activity of scans already in progress. This can result in
5679 unpredictable changes in the row ordering returned by queries that
5680 have no <literal>ORDER BY</> clause. Setting this parameter to
5681 <literal>off</> ensures the pre-8.3 behavior in which a sequential
5682 scan always starts from the beginning of the table. The default
5691 <sect2 id="runtime-config-compatible-clients">
5692 <title>Platform and Client Compatibility</title>
5695 <varlistentry id="guc-transform-null-equals" xreflabel="transform_null_equals">
5696 <term><varname>transform_null_equals</varname> (<type>boolean</type>)</term>
5697 <indexterm><primary>IS NULL</></>
5699 <primary><varname>transform_null_equals</> configuration parameter</primary>
5703 When on, expressions of the form <literal><replaceable>expr</> =
5704 NULL</literal> (or <literal>NULL =
5705 <replaceable>expr</></literal>) are treated as
5706 <literal><replaceable>expr</> IS NULL</literal>, that is, they
5707 return true if <replaceable>expr</> evaluates to the null value,
5708 and false otherwise. The correct SQL-spec-compliant behavior of
5709 <literal><replaceable>expr</> = NULL</literal> is to always
5710 return null (unknown). Therefore this parameter defaults to
5715 However, filtered forms in <productname>Microsoft
5716 Access</productname> generate queries that appear to use
5717 <literal><replaceable>expr</> = NULL</literal> to test for
5718 null values, so if you use that interface to access the database you
5719 might want to turn this option on. Since expressions of the
5720 form <literal><replaceable>expr</> = NULL</literal> always
5721 return the null value (using the SQL standard interpretation), they are not
5722 very useful and do not appear often in normal applications so
5723 this option does little harm in practice. But new users are
5724 frequently confused about the semantics of expressions
5725 involving null values, so this option is off by default.
5729 Note that this option only affects the exact form <literal>= NULL</>,
5730 not other comparison operators or other expressions
5731 that are computationally equivalent to some expression
5732 involving the equals operator (such as <literal>IN</literal>).
5733 Thus, this option is not a general fix for bad programming.
5737 Refer to <xref linkend="functions-comparison"> for related information.
5746 <sect1 id="runtime-config-error-handling">
5747 <title>Error Handling</title>
5751 <varlistentry id="guc-exit-on-error" xreflabel="exit_on_error">
5752 <term><varname>exit_on_error</varname> (<type>boolean</type>)</term>
5754 <primary><varname>exit_on_error</> configuration parameter</primary>
5758 If true, any error will terminate the current session. By default,
5759 this is set to false, so that only FATAL errors will terminate the
5765 <varlistentry id="guc-restart-after-crash" xreflabel="restart_after_crash">
5766 <term><varname>restart_after_crash</varname> (<type>boolean</type>)</term>
5768 <primary><varname>restart_after_crash</> configuration parameter</primary>
5772 When set to true, which is the default, <productname>PostgreSQL</>
5773 will automatically reinitialize after a backend crash. Leaving this
5774 value set to true is normally the best way to maximize the availability
5775 of the database. However, in some circumstances, such as when
5776 <productname>PostgreSQL</> is being invoked by clusterware, it may be
5777 useful to disable the restart so that the clusterware can gain
5778 control and take any actions it deems appropriate.
5787 <sect1 id="runtime-config-preset">
5788 <title>Preset Options</title>
5791 The following <quote>parameters</> are read-only, and are determined
5792 when <productname>PostgreSQL</productname> is compiled or when it is
5793 installed. As such, they have been excluded from the sample
5794 <filename>postgresql.conf</> file. These options report
5795 various aspects of <productname>PostgreSQL</productname> behavior
5796 that might be of interest to certain applications, particularly
5797 administrative front-ends.
5802 <varlistentry id="guc-block-size" xreflabel="block_size">
5803 <term><varname>block_size</varname> (<type>integer</type>)</term>
5805 <primary><varname>block_size</> configuration parameter</primary>
5809 Reports the size of a disk block. It is determined by the value
5810 of <literal>BLCKSZ</> when building the server. The default
5811 value is 8192 bytes. The meaning of some configuration
5812 variables (such as <xref linkend="guc-shared-buffers">) is
5813 influenced by <varname>block_size</varname>. See <xref
5814 linkend="runtime-config-resource"> for information.
5819 <varlistentry id="guc-integer-datetimes" xreflabel="integer_datetimes">
5820 <term><varname>integer_datetimes</varname> (<type>boolean</type>)</term>
5822 <primary><varname>integer_datetimes</> configuration parameter</primary>
5826 Reports whether <productname>PostgreSQL</> was built with
5827 support for 64-bit-integer dates and times. This can be
5828 disabled by configuring with <literal>--disable-integer-datetimes</>
5829 when building <productname>PostgreSQL</>. The default value is
5830 <literal>on</literal>.
5835 <varlistentry id="guc-lc-collate" xreflabel="lc_collate">
5836 <term><varname>lc_collate</varname> (<type>string</type>)</term>
5838 <primary><varname>lc_collate</> configuration parameter</primary>
5842 Reports the locale in which sorting of textual data is done.
5843 See <xref linkend="locale"> for more information.
5844 This value is determined when a database is created.
5849 <varlistentry id="guc-lc-ctype" xreflabel="lc_ctype">
5850 <term><varname>lc_ctype</varname> (<type>string</type>)</term>
5852 <primary><varname>lc_ctype</> configuration parameter</primary>
5856 Reports the locale that determines character classifications.
5857 See <xref linkend="locale"> for more information.
5858 This value is determined when a database is created.
5859 Ordinarily this will be the same as <varname>lc_collate</varname>,
5860 but for special applications it might be set differently.
5865 <varlistentry id="guc-max-function-args" xreflabel="max_function_args">
5866 <term><varname>max_function_args</varname> (<type>integer</type>)</term>
5868 <primary><varname>max_function_args</> configuration parameter</primary>
5872 Reports the maximum number of function arguments. It is determined by
5873 the value of <literal>FUNC_MAX_ARGS</> when building the server. The
5874 default value is 100 arguments.
5879 <varlistentry id="guc-max-identifier-length" xreflabel="max_identifier_length">
5880 <term><varname>max_identifier_length</varname> (<type>integer</type>)</term>
5882 <primary><varname>max_identifier_length</> configuration parameter</primary>
5886 Reports the maximum identifier length. It is determined as one
5887 less than the value of <literal>NAMEDATALEN</> when building
5888 the server. The default value of <literal>NAMEDATALEN</> is
5889 64; therefore the default
5890 <varname>max_identifier_length</varname> is 63 bytes, which
5891 can be less than 63 characters when using multibyte encodings.
5896 <varlistentry id="guc-max-index-keys" xreflabel="max_index_keys">
5897 <term><varname>max_index_keys</varname> (<type>integer</type>)</term>
5899 <primary><varname>max_index_keys</> configuration parameter</primary>
5903 Reports the maximum number of index keys. It is determined by
5904 the value of <literal>INDEX_MAX_KEYS</> when building the server. The
5905 default value is 32 keys.
5910 <varlistentry id="guc-segment-size" xreflabel="segment_size">
5911 <term><varname>segment_size</varname> (<type>integer</type>)</term>
5913 <primary><varname>segment_size</> configuration parameter</primary>
5917 Reports the number of blocks (pages) that can be stored within a file
5918 segment. It is determined by the value of <literal>RELSEG_SIZE</>
5919 when building the server. The maximum size of a segment file in bytes
5920 is equal to <varname>segment_size</> multiplied by
5921 <varname>block_size</>; by default this is 1GB.
5926 <varlistentry id="guc-server-encoding" xreflabel="server_encoding">
5927 <term><varname>server_encoding</varname> (<type>string</type>)</term>
5929 <primary><varname>server_encoding</> configuration parameter</primary>
5931 <indexterm><primary>character set</></>
5934 Reports the database encoding (character set).
5935 It is determined when the database is created. Ordinarily,
5936 clients need only be concerned with the value of <xref
5937 linkend="guc-client-encoding">.
5942 <varlistentry id="guc-server-version" xreflabel="server_version">
5943 <term><varname>server_version</varname> (<type>string</type>)</term>
5945 <primary><varname>server_version</> configuration parameter</primary>
5949 Reports the version number of the server. It is determined by the
5950 value of <literal>PG_VERSION</> when building the server.
5955 <varlistentry id="guc-server-version-num" xreflabel="server_version_num">
5956 <term><varname>server_version_num</varname> (<type>integer</type>)</term>
5958 <primary><varname>server_version_num</> configuration parameter</primary>
5962 Reports the version number of the server as an integer. It is determined
5963 by the value of <literal>PG_VERSION_NUM</> when building the server.
5968 <varlistentry id="guc-wal-block-size" xreflabel="wal_block_size">
5969 <term><varname>wal_block_size</varname> (<type>integer</type>)</term>
5971 <primary><varname>wal_block_size</> configuration parameter</primary>
5975 Reports the size of a WAL disk block. It is determined by the value
5976 of <literal>XLOG_BLCKSZ</> when building the server. The default value
5982 <varlistentry id="guc-wal-segment-size" xreflabel="wal_segment_size">
5983 <term><varname>wal_segment_size</varname> (<type>integer</type>)</term>
5985 <primary><varname>wal_segment_size</> configuration parameter</primary>
5989 Reports the number of blocks (pages) in a WAL segment file.
5990 The total size of a WAL segment file in bytes is equal to
5991 <varname>wal_segment_size</> multiplied by <varname>wal_block_size</>;
5992 by default this is 16MB. See <xref linkend="wal-configuration"> for
6001 <sect1 id="runtime-config-custom">
6002 <title>Customized Options</title>
6005 This feature was designed to allow parameters not normally known to
6006 <productname>PostgreSQL</productname> to be added by add-on modules
6007 (such as procedural languages). This allows extension modules to be
6008 configured in the standard ways.
6012 Custom options have two-part names: an extension name, then a dot, then
6013 the parameter name proper, much like qualified names in SQL. An example
6014 is <literal>plpgsql.variable_conflict</>.
6018 Because custom options may need to be set in processes that have not
6019 loaded the relevant extension module, <productname>PostgreSQL</>
6020 will accept a setting for any two-part parameter name. Such variables
6021 are treated as placeholders and have no function until the module that
6022 defines them is loaded. When an extension module is loaded, it will add
6023 its variable definitions, convert any placeholder values according to
6024 those definitions, and issue warnings for any unrecognized placeholders
6025 that begin with its extension name.
6029 <sect1 id="runtime-config-developer">
6030 <title>Developer Options</title>
6033 The following parameters are intended for work on the
6034 <productname>PostgreSQL</productname> source code, and in some cases
6035 to assist with recovery of severely damaged databases. There
6036 should be no reason to use them on a production database.
6037 As such, they have been excluded from the sample
6038 <filename>postgresql.conf</> file. Note that many of these
6039 parameters require special source compilation flags to work at all.
6043 <varlistentry id="guc-allow-system-table-mods" xreflabel="allow_system_table_mods">
6044 <term><varname>allow_system_table_mods</varname> (<type>boolean</type>)</term>
6046 <primary><varname>allow_system_table_mods</varname> configuration parameter</primary>
6050 Allows modification of the structure of system tables.
6051 This is used by <command>initdb</command>.
6052 This parameter can only be set at server start.
6057 <varlistentry id="guc-debug-assertions" xreflabel="debug_assertions">
6058 <term><varname>debug_assertions</varname> (<type>boolean</type>)</term>
6060 <primary><varname>debug_assertions</> configuration parameter</primary>
6064 Turns on various assertion checks. This is a debugging aid. If
6065 you are experiencing strange problems or crashes you might want
6066 to turn this on, as it might expose programming mistakes. To use
6067 this parameter, the macro <symbol>USE_ASSERT_CHECKING</symbol>
6068 must be defined when <productname>PostgreSQL</productname> is
6069 built (accomplished by the <command>configure</command> option
6070 <option>--enable-cassert</option>). Note that
6071 <varname>debug_assertions</varname> defaults to <literal>on</>
6072 if <productname>PostgreSQL</productname> has been built with
6078 <varlistentry id="guc-ignore-system-indexes" xreflabel="ignore_system_indexes">
6079 <term><varname>ignore_system_indexes</varname> (<type>boolean</type>)</term>
6081 <primary><varname>ignore_system_indexes</varname> configuration parameter</primary>
6085 Ignore system indexes when reading system tables (but still
6086 update the indexes when modifying the tables). This is useful
6087 when recovering from damaged system indexes.
6088 This parameter cannot be changed after session start.
6093 <varlistentry id="guc-post-auth-delay" xreflabel="post_auth_delay">
6094 <term><varname>post_auth_delay</varname> (<type>integer</type>)</term>
6096 <primary><varname>post_auth_delay</> configuration parameter</primary>
6100 If nonzero, a delay of this many seconds occurs when a new
6101 server process is started, after it conducts the
6102 authentication procedure. This is intended to give developers an
6103 opportunity to attach to the server process with a debugger.
6104 This parameter cannot be changed after session start.
6109 <varlistentry id="guc-pre-auth-delay" xreflabel="pre_auth_delay">
6110 <term><varname>pre_auth_delay</varname> (<type>integer</type>)</term>
6112 <primary><varname>pre_auth_delay</> configuration parameter</primary>
6116 If nonzero, a delay of this many seconds occurs just after a
6117 new server process is forked, before it conducts the
6118 authentication procedure. This is intended to give developers an
6119 opportunity to attach to the server process with a debugger to
6120 trace down misbehavior in authentication.
6121 This parameter can only be set in the <filename>postgresql.conf</>
6122 file or on the server command line.
6127 <varlistentry id="guc-trace-notify" xreflabel="trace_notify">
6128 <term><varname>trace_notify</varname> (<type>boolean</type>)</term>
6130 <primary><varname>trace_notify</> configuration parameter</primary>
6134 Generates a great amount of debugging output for the
6135 <command>LISTEN</command> and <command>NOTIFY</command>
6136 commands. <xref linkend="guc-client-min-messages"> or
6137 <xref linkend="guc-log-min-messages"> must be
6138 <literal>DEBUG1</literal> or lower to send this output to the
6139 client or server logs, respectively.
6144 <varlistentry id="guc-trace-recovery-messages" xreflabel="trace_recovery_messages">
6145 <term><varname>trace_recovery_messages</varname> (<type>enum</type>)</term>
6147 <primary><varname>trace_recovery_messages</> configuration parameter</primary>
6151 Enables logging of recovery-related debugging output that otherwise
6152 would not be logged. This parameter allows the user to override the
6153 normal setting of <xref linkend="guc-log-min-messages">, but only for
6154 specific messages. This is intended for use in debugging Hot Standby.
6155 Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
6156 <literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>, and
6157 <literal>LOG</>. The default, <literal>LOG</>, does not affect
6158 logging decisions at all. The other values cause recovery-related
6159 debug messages of that priority or higher to be logged as though they
6160 had <literal>LOG</> priority; for common settings of
6161 <varname>log_min_messages</> this results in unconditionally sending
6162 them to the server log.
6163 This parameter can only be set in the <filename>postgresql.conf</>
6164 file or on the server command line.
6169 <varlistentry id="guc-trace-sort" xreflabel="trace_sort">
6170 <term><varname>trace_sort</varname> (<type>boolean</type>)</term>
6172 <primary><varname>trace_sort</> configuration parameter</primary>
6176 If on, emit information about resource usage during sort operations.
6177 This parameter is only available if the <symbol>TRACE_SORT</symbol> macro
6178 was defined when <productname>PostgreSQL</productname> was compiled.
6179 (However, <symbol>TRACE_SORT</symbol> is currently defined by default.)
6185 <term><varname>trace_locks</varname> (<type>boolean</type>)</term>
6187 <primary><varname>trace_locks</> configuration parameter</primary>
6191 If on, emit information about lock usage. Information dumped
6192 includes the type of lock operation, the type of lock and the unique
6193 identifier of the object being locked or unlocked. Also included
6194 are bit masks for the lock types already granted on this object as
6195 well as for the lock types awaited on this object. For each lock
6196 type a count of the number of granted locks and waiting locks is
6197 also dumped as well as the totals. An example of the log file output
6200 LOG: LockAcquire: new: lock(0xb7acd844) id(24688,24696,0,0,0,1)
6201 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
6202 wait(0) type(AccessShareLock)
6203 LOG: GrantLock: lock(0xb7acd844) id(24688,24696,0,0,0,1)
6204 grantMask(2) req(1,0,0,0,0,0,0)=1 grant(1,0,0,0,0,0,0)=1
6205 wait(0) type(AccessShareLock)
6206 LOG: UnGrantLock: updated: lock(0xb7acd844) id(24688,24696,0,0,0,1)
6207 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
6208 wait(0) type(AccessShareLock)
6209 LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
6210 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
6211 wait(0) type(INVALID)
6213 Details of the structure being dumped may be found in
6214 <filename>src/include/storage/lock.h</filename>.
6217 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6218 macro was defined when <productname>PostgreSQL</productname> was
6225 <term><varname>trace_lwlocks</varname> (<type>boolean</type>)</term>
6227 <primary><varname>trace_lwlocks</> configuration parameter</primary>
6231 If on, emit information about lightweight lock usage. Lightweight
6232 locks are intended primarily to provide mutual exclusion of access
6233 to shared-memory data structures.
6236 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6237 macro was defined when <productname>PostgreSQL</productname> was
6244 <term><varname>trace_userlocks</varname> (<type>boolean</type>)</term>
6246 <primary><varname>trace_userlocks</> configuration parameter</primary>
6250 If on, emit information about user lock usage. Output is the same
6251 as for <symbol>trace_locks</symbol>, only for advisory locks.
6254 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6255 macro was defined when <productname>PostgreSQL</productname> was
6262 <term><varname>trace_lock_oidmin</varname> (<type>integer</type>)</term>
6264 <primary><varname>trace_lock_oidmin</> configuration parameter</primary>
6268 If set, do not trace locks for tables below this OID. (use to avoid
6269 output on system tables)
6272 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6273 macro was defined when <productname>PostgreSQL</productname> was
6280 <term><varname>trace_lock_table</varname> (<type>integer</type>)</term>
6282 <primary><varname>trace_lock_table</> configuration parameter</primary>
6286 Unconditionally trace locks on this table (OID).
6289 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6290 macro was defined when <productname>PostgreSQL</productname> was
6297 <term><varname>debug_deadlocks</varname> (<type>boolean</type>)</term>
6299 <primary><varname>debug_deadlocks</> configuration parameter</primary>
6303 If set, dumps information about all current locks when a
6304 deadlock timeout occurs.
6307 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6308 macro was defined when <productname>PostgreSQL</productname> was
6315 <term><varname>log_btree_build_stats</varname> (<type>boolean</type>)</term>
6317 <primary><varname>log_btree_build_stats</> configuration parameter</primary>
6321 If set, logs system resource usage statistics (memory and CPU) on
6322 various B-tree operations.
6325 This parameter is only available if the <symbol>BTREE_BUILD_STATS</symbol>
6326 macro was defined when <productname>PostgreSQL</productname> was
6332 <varlistentry id="guc-wal-debug" xreflabel="wal_debug">
6333 <term><varname>wal_debug</varname> (<type>boolean</type>)</term>
6335 <primary><varname>wal_debug</> configuration parameter</primary>
6339 If on, emit WAL-related debugging output. This parameter is
6340 only available if the <symbol>WAL_DEBUG</symbol> macro was
6341 defined when <productname>PostgreSQL</productname> was
6347 <varlistentry id="guc-zero-damaged-pages" xreflabel="zero_damaged_pages">
6348 <term><varname>zero_damaged_pages</varname> (<type>boolean</type>)</term>
6350 <primary><varname>zero_damaged_pages</> configuration parameter</primary>
6354 Detection of a damaged page header normally causes
6355 <productname>PostgreSQL</> to report an error, aborting the current
6356 transaction. Setting <varname>zero_damaged_pages</> to on causes
6357 the system to instead report a warning, zero out the damaged
6358 page in memory, and continue processing. This behavior <emphasis>will destroy data</>,
6359 namely all the rows on the damaged page. However, it does allow you to get
6360 past the error and retrieve rows from any undamaged pages that might
6361 be present in the table. It is useful for recovering data if
6362 corruption has occurred due to a hardware or software error. You should
6363 generally not set this on until you have given up hope of recovering
6364 data from the damaged pages of a table. Zeroed-out pages are not
6365 forced to disk so it is recommended to recreate the table or
6366 the index before turning this parameter off again. The
6367 default setting is <literal>off</>, and it can only be changed
6374 <sect1 id="runtime-config-short">
6375 <title>Short Options</title>
6378 For convenience there are also single letter command-line option
6379 switches available for some parameters. They are described in
6380 <xref linkend="runtime-config-short-table">. Some of these
6381 options exist for historical reasons, and their presence as a
6382 single-letter option does not necessarily indicate an endorsement
6383 to use the option heavily.
6386 <table id="runtime-config-short-table">
6387 <title>Short Option Key</title>
6391 <entry>Short Option</entry>
6392 <entry>Equivalent</entry>
6398 <entry><option>-A <replaceable>x</replaceable></option></entry>
6399 <entry><literal>debug_assertions = <replaceable>x</replaceable></></entry>
6402 <entry><option>-B <replaceable>x</replaceable></option></entry>
6403 <entry><literal>shared_buffers = <replaceable>x</replaceable></></entry>
6406 <entry><option>-d <replaceable>x</replaceable></option></entry>
6407 <entry><literal>log_min_messages = DEBUG<replaceable>x</replaceable></></entry>
6410 <entry><option>-e</option></entry>
6411 <entry><literal>datestyle = euro</></entry>
6415 <option>-fb</option>, <option>-fh</option>, <option>-fi</option>,
6416 <option>-fm</option>, <option>-fn</option>, <option>-fo</option>,
6417 <option>-fs</option>, <option>-ft</option>
6420 <literal>enable_bitmapscan = off</>,
6421 <literal>enable_hashjoin = off</>,
6422 <literal>enable_indexscan = off</>,
6423 <literal>enable_mergejoin = off</>,
6424 <literal>enable_nestloop = off</>,
6425 <literal>enable_indexonlyscan = off</>,
6426 <literal>enable_seqscan = off</>,
6427 <literal>enable_tidscan = off</>
6431 <entry><option>-F</option></entry>
6432 <entry><literal>fsync = off</></entry>
6435 <entry><option>-h <replaceable>x</replaceable></option></entry>
6436 <entry><literal>listen_addresses = <replaceable>x</replaceable></></entry>
6439 <entry><option>-i</option></entry>
6440 <entry><literal>listen_addresses = '*'</></entry>
6443 <entry><option>-k <replaceable>x</replaceable></option></entry>
6444 <entry><literal>unix_socket_directory = <replaceable>x</replaceable></></entry>
6447 <entry><option>-l</option></entry>
6448 <entry><literal>ssl = on</></entry>
6451 <entry><option>-N <replaceable>x</replaceable></option></entry>
6452 <entry><literal>max_connections = <replaceable>x</replaceable></></entry>
6455 <entry><option>-O</option></entry>
6456 <entry><literal>allow_system_table_mods = on</></entry>
6459 <entry><option>-p <replaceable>x</replaceable></option></entry>
6460 <entry><literal>port = <replaceable>x</replaceable></></entry>
6463 <entry><option>-P</option></entry>
6464 <entry><literal>ignore_system_indexes = on</></entry>
6467 <entry><option>-s</option></entry>
6468 <entry><literal>log_statement_stats = on</></entry>
6471 <entry><option>-S <replaceable>x</replaceable></option></entry>
6472 <entry><literal>work_mem = <replaceable>x</replaceable></></entry>
6475 <entry><option>-tpa</option>, <option>-tpl</option>, <option>-te</option></entry>
6476 <entry><literal>log_parser_stats = on</>,
6477 <literal>log_planner_stats = on</>,
6478 <literal>log_executor_stats = on</></entry>
6481 <entry><option>-W <replaceable>x</replaceable></option></entry>
6482 <entry><literal>post_auth_delay = <replaceable>x</replaceable></></entry>