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
2608 Random access to mechanical disk storage is normally much more expensive
2609 than four-times sequential access. However, a lower default is used
2610 (4.0) because the majority of random accesses to disk, such as indexed
2611 reads, are assumed to be in cache. The default value can be thought of
2612 as modeling random access as 40 times slower than sequential, while
2613 expecting 90% of random reads to be cached.
2617 If you believe a 90% cache rate is an incorrect assumption
2618 for your workload, you can increase random_page_cost to better
2619 reflect the true cost of random storage reads. Correspondingly,
2620 if your data is likely to be completely in cache, such as when
2621 the database is smaller than the total server memory, decreasing
2622 random_page_cost can be appropriate. Storage that has a low random
2623 read cost relative to sequential, e.g. solid-state drives, might
2624 also be better modeled with a lower value for random_page_cost.
2629 Although the system will let you set <varname>random_page_cost</> to
2630 less than <varname>seq_page_cost</>, it is not physically sensible
2631 to do so. However, setting them equal makes sense if the database
2632 is entirely cached in RAM, since in that case there is no penalty
2633 for touching pages out of sequence. Also, in a heavily-cached
2634 database you should lower both values relative to the CPU parameters,
2635 since the cost of fetching a page already in RAM is much smaller
2636 than it would normally be.
2642 <varlistentry id="guc-cpu-tuple-cost" xreflabel="cpu_tuple_cost">
2643 <term><varname>cpu_tuple_cost</varname> (<type>floating point</type>)</term>
2645 <primary><varname>cpu_tuple_cost</> configuration parameter</primary>
2649 Sets the planner's estimate of the cost of processing
2650 each row during a query.
2651 The default is 0.01.
2656 <varlistentry id="guc-cpu-index-tuple-cost" xreflabel="cpu_index_tuple_cost">
2657 <term><varname>cpu_index_tuple_cost</varname> (<type>floating point</type>)</term>
2659 <primary><varname>cpu_index_tuple_cost</> configuration parameter</primary>
2663 Sets the planner's estimate of the cost of processing
2664 each index entry during an index scan.
2665 The default is 0.005.
2670 <varlistentry id="guc-cpu-operator-cost" xreflabel="cpu_operator_cost">
2671 <term><varname>cpu_operator_cost</varname> (<type>floating point</type>)</term>
2673 <primary><varname>cpu_operator_cost</> configuration parameter</primary>
2677 Sets the planner's estimate of the cost of processing each
2678 operator or function executed during a query.
2679 The default is 0.0025.
2684 <varlistentry id="guc-effective-cache-size" xreflabel="effective_cache_size">
2685 <term><varname>effective_cache_size</varname> (<type>integer</type>)</term>
2687 <primary><varname>effective_cache_size</> configuration parameter</primary>
2691 Sets the planner's assumption about the effective size of the
2692 disk cache that is available to a single query. This is
2693 factored into estimates of the cost of using an index; a
2694 higher value makes it more likely index scans will be used, a
2695 lower value makes it more likely sequential scans will be
2696 used. When setting this parameter you should consider both
2697 <productname>PostgreSQL</productname>'s shared buffers and the
2698 portion of the kernel's disk cache that will be used for
2699 <productname>PostgreSQL</productname> data files. Also, take
2700 into account the expected number of concurrent queries on different
2701 tables, since they will have to share the available
2702 space. This parameter has no effect on the size of shared
2703 memory allocated by <productname>PostgreSQL</productname>, nor
2704 does it reserve kernel disk cache; it is used only for estimation
2705 purposes. The system also does not assume data remains in
2706 the disk cache between queries. The default is 128 megabytes
2707 (<literal>128MB</>).
2715 <sect2 id="runtime-config-query-geqo">
2716 <title>Genetic Query Optimizer</title>
2719 The genetic query optimizer (GEQO) is an algorithm that does query
2720 planning using heuristic searching. This reduces planning time for
2721 complex queries (those joining many relations), at the cost of producing
2722 plans that are sometimes inferior to those found by the normal
2723 exhaustive-search algorithm. Also, GEQO's searching is randomized and
2724 therefore its plans may vary nondeterministically.
2725 For more information see <xref linkend="geqo">.
2730 <varlistentry id="guc-geqo" xreflabel="geqo">
2732 <primary>genetic query optimization</primary>
2735 <primary>GEQO</primary>
2736 <see>genetic query optimization</see>
2739 <primary><varname>geqo</> configuration parameter</primary>
2741 <term><varname>geqo</varname> (<type>boolean</type>)</term>
2744 Enables or disables genetic query optimization.
2745 This is on by default. It is usually best not to turn it off in
2746 production; the <varname>geqo_threshold</varname> variable provides
2747 more granular control of GEQO.
2752 <varlistentry id="guc-geqo-threshold" xreflabel="geqo_threshold">
2753 <term><varname>geqo_threshold</varname> (<type>integer</type>)</term>
2755 <primary><varname>geqo_threshold</> configuration parameter</primary>
2759 Use genetic query optimization to plan queries with at least
2760 this many <literal>FROM</> items involved. (Note that a
2761 <literal>FULL OUTER JOIN</> construct counts as only one <literal>FROM</>
2762 item.) The default is 12. For simpler queries it is usually best
2763 to use the deterministic, exhaustive planner, but for queries with
2764 many tables the deterministic planner takes too long, often
2765 longer than the penalty of executing a suboptimal plan.
2770 <varlistentry id="guc-geqo-effort" xreflabel="geqo_effort">
2771 <term><varname>geqo_effort</varname>
2772 (<type>integer</type>)</term>
2774 <primary><varname>geqo_effort</> configuration parameter</primary>
2778 Controls the trade-off between planning time and query plan
2779 quality in GEQO. This variable must be an integer in the
2780 range from 1 to 10. The default value is five. Larger values
2781 increase the time spent doing query planning, but also
2782 increase the likelihood that an efficient query plan will be
2787 <varname>geqo_effort</varname> doesn't actually do anything
2788 directly; it is only used to compute the default values for
2789 the other variables that influence GEQO behavior (described
2790 below). If you prefer, you can set the other parameters by
2796 <varlistentry id="guc-geqo-pool-size" xreflabel="geqo_pool_size">
2797 <term><varname>geqo_pool_size</varname> (<type>integer</type>)</term>
2799 <primary><varname>geqo_pool_size</> configuration parameter</primary>
2803 Controls the pool size used by GEQO, that is the
2804 number of individuals in the genetic population. It must be
2805 at least two, and useful values are typically 100 to 1000. If
2806 it is set to zero (the default setting) then a suitable
2807 value is chosen based on <varname>geqo_effort</varname> and
2808 the number of tables in the query.
2813 <varlistentry id="guc-geqo-generations" xreflabel="geqo_generations">
2814 <term><varname>geqo_generations</varname> (<type>integer</type>)</term>
2816 <primary><varname>geqo_generations</> configuration parameter</primary>
2820 Controls the number of generations used by GEQO, that is
2821 the number of iterations of the algorithm. It must
2822 be at least one, and useful values are in the same range as
2823 the pool size. If it is set to zero (the default setting)
2824 then a suitable value is chosen based on
2825 <varname>geqo_pool_size</varname>.
2830 <varlistentry id="guc-geqo-selection-bias" xreflabel="geqo_selection_bias">
2831 <term><varname>geqo_selection_bias</varname> (<type>floating point</type>)</term>
2833 <primary><varname>geqo_selection_bias</> configuration parameter</primary>
2837 Controls the selection bias used by GEQO. The selection bias
2838 is the selective pressure within the population. Values can be
2839 from 1.50 to 2.00; the latter is the default.
2844 <varlistentry id="guc-geqo-seed" xreflabel="geqo_seed">
2845 <term><varname>geqo_seed</varname> (<type>floating point</type>)</term>
2847 <primary><varname>geqo_seed</> configuration parameter</primary>
2851 Controls the initial value of the random number generator used
2852 by GEQO to select random paths through the join order search space.
2853 The value can range from zero (the default) to one. Varying the
2854 value changes the set of join paths explored, and may result in a
2855 better or worse best path being found.
2862 <sect2 id="runtime-config-query-other">
2863 <title>Other Planner Options</title>
2867 <varlistentry id="guc-default-statistics-target" xreflabel="default_statistics_target">
2868 <term><varname>default_statistics_target</varname> (<type>integer</type>)</term>
2870 <primary><varname>default_statistics_target</> configuration parameter</primary>
2874 Sets the default statistics target for table columns without
2875 a column-specific target set via <command>ALTER TABLE
2876 SET STATISTICS</>. Larger values increase the time needed to
2877 do <command>ANALYZE</>, but might improve the quality of the
2878 planner's estimates. The default is 100. For more information
2879 on the use of statistics by the <productname>PostgreSQL</>
2880 query planner, refer to <xref linkend="planner-stats">.
2885 <varlistentry id="guc-constraint-exclusion" xreflabel="constraint_exclusion">
2886 <term><varname>constraint_exclusion</varname> (<type>enum</type>)</term>
2888 <primary>constraint exclusion</primary>
2891 <primary><varname>constraint_exclusion</> configuration parameter</primary>
2895 Controls the query planner's use of table constraints to
2897 The allowed values of <varname>constraint_exclusion</> are
2898 <literal>on</> (examine constraints for all tables),
2899 <literal>off</> (never examine constraints), and
2900 <literal>partition</> (examine constraints only for inheritance child
2901 tables and <literal>UNION ALL</> subqueries).
2902 <literal>partition</> is the default setting.
2903 It is often used with inheritance and partitioned tables to
2904 improve performance.
2908 When this parameter allows it for a particular table, the planner
2909 compares query conditions with the table's <literal>CHECK</>
2910 constraints, and omits scanning tables for which the conditions
2911 contradict the constraints. For example:
2914 CREATE TABLE parent(key integer, ...);
2915 CREATE TABLE child1000(check (key between 1000 and 1999)) INHERITS(parent);
2916 CREATE TABLE child2000(check (key between 2000 and 2999)) INHERITS(parent);
2918 SELECT * FROM parent WHERE key = 2400;
2921 With constraint exclusion enabled, this <command>SELECT</>
2922 will not scan <structname>child1000</> at all, improving performance.
2926 Currently, constraint exclusion is enabled by default
2927 only for cases that are often used to implement table partitioning.
2928 Turning it on for all tables imposes extra planning overhead that is
2929 quite noticeable on simple queries, and most often will yield no
2930 benefit for simple queries. If you have no partitioned tables
2931 you might prefer to turn it off entirely.
2935 Refer to <xref linkend="ddl-partitioning-constraint-exclusion"> for
2936 more information on using constraint exclusion and partitioning.
2941 <varlistentry id="guc-cursor-tuple-fraction" xreflabel="cursor_tuple_fraction">
2942 <term><varname>cursor_tuple_fraction</varname> (<type>floating point</type>)</term>
2944 <primary><varname>cursor_tuple_fraction</> configuration parameter</primary>
2948 Sets the planner's estimate of the fraction of a cursor's rows that
2949 will be retrieved. The default is 0.1. Smaller values of this
2950 setting bias the planner towards using <quote>fast start</> plans
2951 for cursors, which will retrieve the first few rows quickly while
2952 perhaps taking a long time to fetch all rows. Larger values
2953 put more emphasis on the total estimated time. At the maximum
2954 setting of 1.0, cursors are planned exactly like regular queries,
2955 considering only the total estimated time and not how soon the
2956 first rows might be delivered.
2961 <varlistentry id="guc-from-collapse-limit" xreflabel="from_collapse_limit">
2962 <term><varname>from_collapse_limit</varname> (<type>integer</type>)</term>
2964 <primary><varname>from_collapse_limit</> configuration parameter</primary>
2968 The planner will merge sub-queries into upper queries if the
2969 resulting <literal>FROM</literal> list would have no more than
2970 this many items. Smaller values reduce planning time but might
2971 yield inferior query plans. The default is eight.
2972 For more information see <xref linkend="explicit-joins">.
2976 Setting this value to <xref linkend="guc-geqo-threshold"> or more
2977 may trigger use of the GEQO planner, resulting in nondeterministic
2978 plans. See <xref linkend="runtime-config-query-geqo">.
2983 <varlistentry id="guc-join-collapse-limit" xreflabel="join_collapse_limit">
2984 <term><varname>join_collapse_limit</varname> (<type>integer</type>)</term>
2986 <primary><varname>join_collapse_limit</> configuration parameter</primary>
2990 The planner will rewrite explicit <literal>JOIN</>
2991 constructs (except <literal>FULL JOIN</>s) into lists of
2992 <literal>FROM</> items whenever a list of no more than this many items
2993 would result. Smaller values reduce planning time but might
2994 yield inferior query plans.
2998 By default, this variable is set the same as
2999 <varname>from_collapse_limit</varname>, which is appropriate
3000 for most uses. Setting it to 1 prevents any reordering of
3001 explicit <literal>JOIN</>s. Thus, the explicit join order
3002 specified in the query will be the actual order in which the
3003 relations are joined. Because the query planner does not always choose
3004 the optimal join order, advanced users can elect to
3005 temporarily set this variable to 1, and then specify the join
3006 order they desire explicitly.
3007 For more information see <xref linkend="explicit-joins">.
3011 Setting this value to <xref linkend="guc-geqo-threshold"> or more
3012 may trigger use of the GEQO planner, resulting in nondeterministic
3013 plans. See <xref linkend="runtime-config-query-geqo">.
3022 <sect1 id="runtime-config-logging">
3023 <title>Error Reporting and Logging</title>
3025 <indexterm zone="runtime-config-logging">
3026 <primary>server log</primary>
3029 <sect2 id="runtime-config-logging-where">
3030 <title>Where To Log</title>
3032 <indexterm zone="runtime-config-logging-where">
3033 <primary>where to log</primary>
3038 <varlistentry id="guc-log-destination" xreflabel="log_destination">
3039 <term><varname>log_destination</varname> (<type>string</type>)</term>
3041 <primary><varname>log_destination</> configuration parameter</primary>
3045 <productname>PostgreSQL</productname> supports several methods
3046 for logging server messages, including
3047 <systemitem>stderr</systemitem>, <systemitem>csvlog</systemitem> and
3048 <systemitem>syslog</systemitem>. On Windows,
3049 <systemitem>eventlog</systemitem> is also supported. Set this
3050 parameter to a list of desired log destinations separated by
3051 commas. The default is to log to <systemitem>stderr</systemitem>
3053 This parameter can only be set in the <filename>postgresql.conf</>
3054 file or on the server command line.
3057 If <systemitem>csvlog</> is included in <varname>log_destination</>,
3058 log entries are output in <quote>comma separated
3059 value</> (<acronym>CSV</>) format, which is convenient for
3060 loading logs into programs.
3061 See <xref linkend="runtime-config-logging-csvlog"> for details.
3062 <varname>logging_collector</varname> must be enabled to generate
3063 CSV-format log output.
3068 On most Unix systems, you will need to alter the configuration of
3069 your system's <application>syslog</application> daemon in order
3070 to make use of the <systemitem>syslog</systemitem> option for
3071 <varname>log_destination</>. <productname>PostgreSQL</productname>
3072 can log to <application>syslog</application> facilities
3073 <literal>LOCAL0</> through <literal>LOCAL7</> (see <xref
3074 linkend="guc-syslog-facility">), but the default
3075 <application>syslog</application> configuration on most platforms
3076 will discard all such messages. You will need to add something like:
3078 local0.* /var/log/postgresql
3080 to the <application>syslog</application> daemon's configuration file
3084 On Windows, when you use the <literal>eventlog</literal>
3085 option for <varname>log_destination</>, you should
3086 register an event source and its library with the operating
3087 system so that the Windows Event Viewer can display event
3088 log messages cleanly.
3089 See <xref linkend="event-log-registration"> for details.
3095 <varlistentry id="guc-logging-collector" xreflabel="logging_collector">
3096 <term><varname>logging_collector</varname> (<type>boolean</type>)</term>
3098 <primary><varname>logging_collector</> configuration parameter</primary>
3102 This parameter captures plain and CSV-format log messages
3103 sent to <application>stderr</> and redirects them into log files.
3104 This approach is often more useful than
3105 logging to <application>syslog</>, since some types of messages
3106 might not appear in <application>syslog</> output (a common example
3107 is dynamic-linker failure messages).
3108 This parameter can only be set at server start.
3113 The logging collector is designed to never lose messages. This means
3114 that in case of extremely high load, server processes could be
3115 blocked due to trying to send additional log messages when the
3116 collector has fallen behind. In contrast, <application>syslog</>
3117 prefers to drop messages if it cannot write them, which means it's
3118 less reliable in those cases but it will not block the rest of the
3126 <varlistentry id="guc-log-directory" xreflabel="log_directory">
3127 <term><varname>log_directory</varname> (<type>string</type>)</term>
3129 <primary><varname>log_directory</> configuration parameter</primary>
3133 When <varname>logging_collector</> is enabled,
3134 this parameter determines the directory in which log files will be created.
3135 It can be specified as an absolute path, or relative to the
3136 cluster data directory.
3137 This parameter can only be set in the <filename>postgresql.conf</>
3138 file or on the server command line.
3143 <varlistentry id="guc-log-filename" xreflabel="log_filename">
3144 <term><varname>log_filename</varname> (<type>string</type>)</term>
3146 <primary><varname>log_filename</> configuration parameter</primary>
3150 When <varname>logging_collector</varname> is enabled,
3151 this parameter sets the file names of the created log files. The value
3152 is treated as a <systemitem>strftime</systemitem> pattern,
3153 so <literal>%</literal>-escapes can be used to specify time-varying
3154 file names. (Note that if there are
3155 any time-zone-dependent <literal>%</literal>-escapes, the computation
3156 is done in the zone specified
3157 by <xref linkend="guc-log-timezone">.)
3158 The supported <literal>%</literal>-escapes are similar to those
3159 listed in the Open Group's <ulink
3160 url="http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html">strftime
3161 </ulink> specification.
3162 Note that the system's <systemitem>strftime</systemitem> is not used
3163 directly, so platform-specific (nonstandard) extensions do not work.
3166 If you specify a file name without escapes, you should plan to
3167 use a log rotation utility to avoid eventually filling the
3168 entire disk. In releases prior to 8.4, if
3169 no <literal>%</literal> escapes were
3170 present, <productname>PostgreSQL</productname> would append
3171 the epoch of the new log file's creation time, but this is no
3175 If CSV-format output is enabled in <varname>log_destination</>,
3176 <literal>.csv</> will be appended to the timestamped
3177 log file name to create the file name for CSV-format output.
3178 (If <varname>log_filename</> ends in <literal>.log</>, the suffix is
3180 In the case of the example above, the CSV
3181 file name will be <literal>server_log.1093827753.csv</literal>.
3184 This parameter can only be set in the <filename>postgresql.conf</>
3185 file or on the server command line.
3190 <varlistentry id="guc-log-file-mode" xreflabel="log_file_mode">
3191 <term><varname>log_file_mode</varname> (<type>integer</type>)</term>
3193 <primary><varname>log_file_mode</> configuration parameter</primary>
3197 On Unix systems this parameter sets the permissions for log files
3198 when <varname>logging_collector</varname> is enabled. (On Microsoft
3199 Windows this parameter is ignored.)
3200 The parameter value is expected to be a numeric mode
3201 specified in the format accepted by the
3202 <function>chmod</function> and <function>umask</function>
3203 system calls. (To use the customary octal format the number
3204 must start with a <literal>0</literal> (zero).)
3207 The default permissions are <literal>0600</>, meaning only the
3208 server owner can read or write the log files. The other commonly
3209 useful setting is <literal>0640</>, allowing members of the owner's
3210 group to read the files. Note however that to make use of such a
3211 setting, you'll need to alter <xref linkend="guc-log-directory"> to
3212 store the files somewhere outside the cluster data directory. In
3213 any case, it's unwise to make the log files world-readable, since
3214 they might contain sensitive data.
3217 This parameter can only be set in the <filename>postgresql.conf</>
3218 file or on the server command line.
3223 <varlistentry id="guc-log-rotation-age" xreflabel="log_rotation_age">
3224 <term><varname>log_rotation_age</varname> (<type>integer</type>)</term>
3226 <primary><varname>log_rotation_age</> configuration parameter</primary>
3230 When <varname>logging_collector</varname> is enabled,
3231 this parameter determines the maximum lifetime of an individual log file.
3232 After this many minutes have elapsed, a new log file will
3233 be created. Set to zero to disable time-based creation of
3235 This parameter can only be set in the <filename>postgresql.conf</>
3236 file or on the server command line.
3241 <varlistentry id="guc-log-rotation-size" xreflabel="log_rotation_size">
3242 <term><varname>log_rotation_size</varname> (<type>integer</type>)</term>
3244 <primary><varname>log_rotation_size</> configuration parameter</primary>
3248 When <varname>logging_collector</varname> is enabled,
3249 this parameter determines the maximum size of an individual log file.
3250 After this many kilobytes have been emitted into a log file,
3251 a new log file will be created. Set to zero to disable size-based
3252 creation of new log files.
3253 This parameter can only be set in the <filename>postgresql.conf</>
3254 file or on the server command line.
3259 <varlistentry id="guc-log-truncate-on-rotation" xreflabel="log_truncate_on_rotation">
3260 <term><varname>log_truncate_on_rotation</varname> (<type>boolean</type>)</term>
3262 <primary><varname>log_truncate_on_rotation</> configuration parameter</primary>
3266 When <varname>logging_collector</varname> is enabled,
3267 this parameter will cause <productname>PostgreSQL</productname> to truncate (overwrite),
3268 rather than append to, any existing log file of the same name.
3269 However, truncation will occur only when a new file is being opened
3270 due to time-based rotation, not during server startup or size-based
3271 rotation. When off, pre-existing files will be appended to in
3272 all cases. For example, using this setting in combination with
3273 a <varname>log_filename</varname> like <literal>postgresql-%H.log</literal>
3274 would result in generating twenty-four hourly log files and then
3275 cyclically overwriting them.
3276 This parameter can only be set in the <filename>postgresql.conf</>
3277 file or on the server command line.
3280 Example: To keep 7 days of logs, one log file per day named
3281 <literal>server_log.Mon</literal>, <literal>server_log.Tue</literal>,
3282 etc, and automatically overwrite last week's log with this week's log,
3283 set <varname>log_filename</varname> to <literal>server_log.%a</literal>,
3284 <varname>log_truncate_on_rotation</varname> to <literal>on</literal>, and
3285 <varname>log_rotation_age</varname> to <literal>1440</literal>.
3288 Example: To keep 24 hours of logs, one log file per hour, but
3289 also rotate sooner if the log file size exceeds 1GB, set
3290 <varname>log_filename</varname> to <literal>server_log.%H%M</literal>,
3291 <varname>log_truncate_on_rotation</varname> to <literal>on</literal>,
3292 <varname>log_rotation_age</varname> to <literal>60</literal>, and
3293 <varname>log_rotation_size</varname> to <literal>1000000</literal>.
3294 Including <literal>%M</> in <varname>log_filename</varname> allows
3295 any size-driven rotations that might occur to select a file name
3296 different from the hour's initial file name.
3301 <varlistentry id="guc-syslog-facility" xreflabel="syslog_facility">
3302 <term><varname>syslog_facility</varname> (<type>enum</type>)</term>
3304 <primary><varname>syslog_facility</> configuration parameter</primary>
3308 When logging to <application>syslog</> is enabled, this parameter
3309 determines the <application>syslog</application>
3310 <quote>facility</quote> to be used. You can choose
3311 from <literal>LOCAL0</>, <literal>LOCAL1</>,
3312 <literal>LOCAL2</>, <literal>LOCAL3</>, <literal>LOCAL4</>,
3313 <literal>LOCAL5</>, <literal>LOCAL6</>, <literal>LOCAL7</>;
3314 the default is <literal>LOCAL0</>. See also the
3315 documentation of your system's
3316 <application>syslog</application> daemon.
3317 This parameter can only be set in the <filename>postgresql.conf</>
3318 file or on the server command line.
3323 <varlistentry id="guc-syslog-ident" xreflabel="syslog_ident">
3324 <term><varname>syslog_ident</varname> (<type>string</type>)</term>
3326 <primary><varname>syslog_identity</> configuration parameter</primary>
3330 When logging to <application>syslog</> is enabled, this parameter
3331 determines the program name used to identify
3332 <productname>PostgreSQL</productname> messages in
3333 <application>syslog</application> logs. The default is
3334 <literal>postgres</literal>.
3335 This parameter can only be set in the <filename>postgresql.conf</>
3336 file or on the server command line.
3341 <varlistentry id="guc-event-source" xreflabel="event_source">
3342 <term><varname>event_source</varname> (<type>string</type>)</term>
3344 <primary><varname>event_source</> configuration parameter</primary>
3348 When logging to <application>event log</> is enabled, this parameter
3349 determines the program name used to identify
3350 <productname>PostgreSQL</productname> messages in
3351 the log. The default is <literal>PostgreSQL</literal>.
3352 This parameter can only be set in the <filename>postgresql.conf</>
3353 file or on the server command line.
3360 <sect2 id="runtime-config-logging-when">
3361 <title>When To Log</title>
3365 <varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
3366 <term><varname>client_min_messages</varname> (<type>enum</type>)</term>
3368 <primary><varname>client_min_messages</> configuration parameter</primary>
3372 Controls which message levels are sent to the client.
3373 Valid values are <literal>DEBUG5</>,
3374 <literal>DEBUG4</>, <literal>DEBUG3</>, <literal>DEBUG2</>,
3375 <literal>DEBUG1</>, <literal>LOG</>, <literal>NOTICE</>,
3376 <literal>WARNING</>, <literal>ERROR</>, <literal>FATAL</>,
3377 and <literal>PANIC</>. Each level
3378 includes all the levels that follow it. The later the level,
3379 the fewer messages are sent. The default is
3380 <literal>NOTICE</>. Note that <literal>LOG</> has a different
3381 rank here than in <varname>log_min_messages</>.
3386 <varlistentry id="guc-log-min-messages" xreflabel="log_min_messages">
3387 <term><varname>log_min_messages</varname> (<type>enum</type>)</term>
3389 <primary><varname>log_min_messages</> configuration parameter</primary>
3393 Controls which message levels are written to the server log.
3394 Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
3395 <literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>,
3396 <literal>INFO</>, <literal>NOTICE</>, <literal>WARNING</>,
3397 <literal>ERROR</>, <literal>LOG</>, <literal>FATAL</>, and
3398 <literal>PANIC</>. Each level includes all the levels that
3399 follow it. The later the level, the fewer messages are sent
3400 to the log. The default is <literal>WARNING</>. Note that
3401 <literal>LOG</> has a different rank here than in
3402 <varname>client_min_messages</>.
3403 Only superusers can change this setting.
3408 <varlistentry id="guc-log-min-error-statement" xreflabel="log_min_error_statement">
3409 <term><varname>log_min_error_statement</varname> (<type>enum</type>)</term>
3411 <primary><varname>log_min_error_statement</> configuration parameter</primary>
3415 Controls which SQL statements that cause an error
3416 condition are recorded in the server log. The current
3417 SQL statement is included in the log entry for any message of
3418 the specified severity or higher.
3419 Valid values are <literal>DEBUG5</literal>,
3420 <literal>DEBUG4</literal>, <literal>DEBUG3</literal>,
3421 <literal>DEBUG2</literal>, <literal>DEBUG1</literal>,
3422 <literal>INFO</literal>, <literal>NOTICE</literal>,
3423 <literal>WARNING</literal>, <literal>ERROR</literal>,
3424 <literal>LOG</literal>,
3425 <literal>FATAL</literal>, and <literal>PANIC</literal>.
3426 The default is <literal>ERROR</literal>, which means statements
3427 causing errors, log messages, fatal errors, or panics will be logged.
3428 To effectively turn off logging of failing statements,
3429 set this parameter to <literal>PANIC</literal>.
3430 Only superusers can change this setting.
3435 <varlistentry id="guc-log-min-duration-statement" xreflabel="log_min_duration_statement">
3436 <term><varname>log_min_duration_statement</varname> (<type>integer</type>)</term>
3438 <primary><varname>log_min_duration_statement</> configuration parameter</primary>
3442 Causes the duration of each completed statement to be logged
3443 if the statement ran for at least the specified number of
3444 milliseconds. Setting this to zero prints all statement durations.
3445 Minus-one (the default) disables logging statement durations.
3446 For example, if you set it to <literal>250ms</literal>
3447 then all SQL statements that run 250ms or longer will be
3448 logged. Enabling this parameter can be helpful in tracking down
3449 unoptimized queries in your applications.
3450 Only superusers can change this setting.
3454 For clients using extended query protocol, durations of the Parse,
3455 Bind, and Execute steps are logged independently.
3460 When using this option together with
3461 <xref linkend="guc-log-statement">,
3462 the text of statements that are logged because of
3463 <varname>log_statement</> will not be repeated in the
3464 duration log message.
3465 If you are not using <application>syslog</>, it is recommended
3466 that you log the PID or session ID using
3467 <xref linkend="guc-log-line-prefix">
3468 so that you can link the statement message to the later
3469 duration message using the process ID or session ID.
3478 <xref linkend="runtime-config-severity-levels"> explains the message
3479 severity levels used by <productname>PostgreSQL</>. If logging output
3480 is sent to <systemitem>syslog</systemitem> or Windows'
3481 <systemitem>eventlog</systemitem>, the severity levels are translated
3482 as shown in the table.
3485 <table id="runtime-config-severity-levels">
3486 <title>Message Severity Levels</title>
3490 <entry>Severity</entry>
3491 <entry>Usage</entry>
3492 <entry><systemitem>syslog</></entry>
3493 <entry><systemitem>eventlog</></entry>
3499 <entry><literal>DEBUG1..DEBUG5</></entry>
3500 <entry>Provides successively-more-detailed information for use by
3502 <entry><literal>DEBUG</></entry>
3503 <entry><literal>INFORMATION</></entry>
3507 <entry><literal>INFO</></entry>
3508 <entry>Provides information implicitly requested by the user,
3509 e.g., output from <command>VACUUM VERBOSE</>.</entry>
3510 <entry><literal>INFO</></entry>
3511 <entry><literal>INFORMATION</></entry>
3515 <entry><literal>NOTICE</></entry>
3516 <entry>Provides information that might be helpful to users, e.g.,
3517 notice of truncation of long identifiers.</entry>
3518 <entry><literal>NOTICE</></entry>
3519 <entry><literal>INFORMATION</></entry>
3523 <entry><literal>WARNING</></entry>
3524 <entry>Provides warnings of likely problems, e.g., <command>COMMIT</>
3525 outside a transaction block.</entry>
3526 <entry><literal>NOTICE</></entry>
3527 <entry><literal>WARNING</></entry>
3531 <entry><literal>ERROR</></entry>
3532 <entry>Reports an error that caused the current command to
3534 <entry><literal>WARNING</></entry>
3535 <entry><literal>ERROR</></entry>
3539 <entry><literal>LOG</></entry>
3540 <entry>Reports information of interest to administrators, e.g.,
3541 checkpoint activity.</entry>
3542 <entry><literal>INFO</></entry>
3543 <entry><literal>INFORMATION</></entry>
3547 <entry><literal>FATAL</></entry>
3548 <entry>Reports an error that caused the current session to
3550 <entry><literal>ERR</></entry>
3551 <entry><literal>ERROR</></entry>
3555 <entry><literal>PANIC</></entry>
3556 <entry>Reports an error that caused all database sessions to abort.</entry>
3557 <entry><literal>CRIT</></entry>
3558 <entry><literal>ERROR</></entry>
3565 <sect2 id="runtime-config-logging-what">
3566 <title>What To Log</title>
3570 <varlistentry id="guc-application-name" xreflabel="application_name">
3571 <term><varname>application_name</varname> (<type>string</type>)</term>
3573 <primary><varname>application_name</> configuration parameter</primary>
3577 The <varname>application_name</varname> can be any string of less than
3578 <symbol>NAMEDATALEN</> characters (64 characters in a standard build).
3579 It is typically set by an application upon connection to the server.
3580 The name will be displayed in the <structname>pg_stat_activity</> view
3581 and included in CSV log entries. It can also be included in regular
3582 log entries via the <xref linkend="guc-log-line-prefix"> parameter.
3583 Only printable ASCII characters may be used in the
3584 <varname>application_name</varname> value. Other characters will be
3585 replaced with question marks (<literal>?</literal>).
3591 <term><varname>debug_print_parse</varname> (<type>boolean</type>)</term>
3592 <term><varname>debug_print_rewritten</varname> (<type>boolean</type>)</term>
3593 <term><varname>debug_print_plan</varname> (<type>boolean</type>)</term>
3595 <primary><varname>debug_print_parse</> configuration parameter</primary>
3598 <primary><varname>debug_print_rewritten</> configuration parameter</primary>
3601 <primary><varname>debug_print_plan</> configuration parameter</primary>
3605 These parameters enable various debugging output to be emitted.
3606 When set, they print the resulting parse tree, the query rewriter
3607 output, or the execution plan for each executed query.
3608 These messages are emitted at <literal>LOG</> message level, so by
3609 default they will appear in the server log but will not be sent to the
3610 client. You can change that by adjusting
3611 <xref linkend="guc-client-min-messages"> and/or
3612 <xref linkend="guc-log-min-messages">.
3613 These parameters are off by default.
3619 <term><varname>debug_pretty_print</varname> (<type>boolean</type>)</term>
3621 <primary><varname>debug_pretty_print</> configuration parameter</primary>
3625 When set, <varname>debug_pretty_print</varname> indents the messages
3626 produced by <varname>debug_print_parse</varname>,
3627 <varname>debug_print_rewritten</varname>, or
3628 <varname>debug_print_plan</varname>. This results in more readable
3629 but much longer output than the <quote>compact</> format used when
3630 it is off. It is on by default.
3635 <varlistentry id="guc-log-checkpoints" xreflabel="log_checkpoints">
3636 <term><varname>log_checkpoints</varname> (<type>boolean</type>)</term>
3638 <primary><varname>log_checkpoints</> configuration parameter</primary>
3642 Causes checkpoints and restartpoints to be logged in the server log.
3643 Some statistics are included in the log messages, including the number
3644 of buffers written and the time spent writing them.
3645 This parameter can only be set in the <filename>postgresql.conf</>
3646 file or on the server command line. The default is off.
3651 <varlistentry id="guc-log-connections" xreflabel="log_connections">
3652 <term><varname>log_connections</varname> (<type>boolean</type>)</term>
3654 <primary><varname>log_connections</> configuration parameter</primary>
3658 Causes each attempted connection to the server to be logged,
3659 as well as successful completion of client authentication.
3660 This parameter cannot be changed after session start.
3666 Some client programs, like <application>psql</>, attempt
3667 to connect twice while determining if a password is required, so
3668 duplicate <quote>connection received</> messages do not
3669 necessarily indicate a problem.
3675 <varlistentry id="guc-log-disconnections" xreflabel="log_disconnections">
3676 <term><varname>log_disconnections</varname> (<type>boolean</type>)</term>
3678 <primary><varname>log_disconnections</> configuration parameter</primary>
3682 This outputs a line in the server log similar to
3683 <varname>log_connections</varname> but at session termination,
3684 and includes the duration of the session. This is off by
3686 This parameter cannot be changed after session start.
3692 <varlistentry id="guc-log-duration" xreflabel="log_duration">
3693 <term><varname>log_duration</varname> (<type>boolean</type>)</term>
3695 <primary><varname>log_duration</> configuration parameter</primary>
3699 Causes the duration of every completed statement to be logged.
3700 The default is <literal>off</>.
3701 Only superusers can change this setting.
3705 For clients using extended query protocol, durations of the Parse,
3706 Bind, and Execute steps are logged independently.
3711 The difference between setting this option and setting
3712 <xref linkend="guc-log-min-duration-statement"> to zero is that
3713 exceeding <varname>log_min_duration_statement</> forces the text of
3714 the query to be logged, but this option doesn't. Thus, if
3715 <varname>log_duration</> is <literal>on</> and
3716 <varname>log_min_duration_statement</> has a positive value, all
3717 durations are logged but the query text is included only for
3718 statements exceeding the threshold. This behavior can be useful for
3719 gathering statistics in high-load installations.
3725 <varlistentry id="guc-log-error-verbosity" xreflabel="log_error_verbosity">
3726 <term><varname>log_error_verbosity</varname> (<type>enum</type>)</term>
3728 <primary><varname>log_error_verbosity</> configuration parameter</primary>
3732 Controls the amount of detail written in the server log for each
3733 message that is logged. Valid values are <literal>TERSE</>,
3734 <literal>DEFAULT</>, and <literal>VERBOSE</>, each adding more
3735 fields to displayed messages. <literal>TERSE</> excludes
3736 the logging of <literal>DETAIL</>, <literal>HINT</>,
3737 <literal>QUERY</>, and <literal>CONTEXT</> error information.
3738 <literal>VERBOSE</> output includes the <symbol>SQLSTATE</> error
3739 code (see also <xref linkend="errcodes-appendix">) and the source code file name, function name,
3740 and line number that generated the error.
3741 Only superusers can change this setting.
3746 <varlistentry id="guc-log-hostname" xreflabel="log_hostname">
3747 <term><varname>log_hostname</varname> (<type>boolean</type>)</term>
3749 <primary><varname>log_hostname</> configuration parameter</primary>
3753 By default, connection log messages only show the IP address of the
3754 connecting host. Turning this parameter on causes logging of the
3755 host name as well. Note that depending on your host name resolution
3756 setup this might impose a non-negligible performance penalty.
3757 This parameter can only be set in the <filename>postgresql.conf</>
3758 file or on the server command line.
3763 <varlistentry id="guc-log-line-prefix" xreflabel="log_line_prefix">
3764 <term><varname>log_line_prefix</varname> (<type>string</type>)</term>
3766 <primary><varname>log_line_prefix</> configuration parameter</primary>
3770 This is a <function>printf</>-style string that is output at the
3771 beginning of each log line.
3772 <literal>%</> characters begin <quote>escape sequences</>
3773 that are replaced with status information as outlined below.
3774 Unrecognized escapes are ignored. Other
3775 characters are copied straight to the log line. Some escapes are
3776 only recognized by session processes, and are ignored by
3777 background processes such as the main server process.
3778 This parameter can only be set in the <filename>postgresql.conf</>
3779 file or on the server command line. The default is an empty string.
3785 <entry>Escape</entry>
3786 <entry>Effect</entry>
3787 <entry>Session only</entry>
3792 <entry><literal>%a</literal></entry>
3793 <entry>Application name</entry>
3797 <entry><literal>%u</literal></entry>
3798 <entry>User name</entry>
3802 <entry><literal>%d</literal></entry>
3803 <entry>Database name</entry>
3807 <entry><literal>%r</literal></entry>
3808 <entry>Remote host name or IP address, and remote port</entry>
3812 <entry><literal>%h</literal></entry>
3813 <entry>Remote host name or IP address</entry>
3817 <entry><literal>%p</literal></entry>
3818 <entry>Process ID</entry>
3822 <entry><literal>%t</literal></entry>
3823 <entry>Time stamp without milliseconds</entry>
3827 <entry><literal>%m</literal></entry>
3828 <entry>Time stamp with milliseconds</entry>
3832 <entry><literal>%i</literal></entry>
3833 <entry>Command tag: type of session's current command</entry>
3837 <entry><literal>%e</literal></entry>
3838 <entry>SQLSTATE error code</entry>
3842 <entry><literal>%c</literal></entry>
3843 <entry>Session ID: see below</entry>
3847 <entry><literal>%l</literal></entry>
3848 <entry>Number of the log line for each session or process, starting at 1</entry>
3852 <entry><literal>%s</literal></entry>
3853 <entry>Process start time stamp</entry>
3857 <entry><literal>%v</literal></entry>
3858 <entry>Virtual transaction ID (backendID/localXID)</entry>
3862 <entry><literal>%x</literal></entry>
3863 <entry>Transaction ID (0 if none is assigned)</entry>
3867 <entry><literal>%q</literal></entry>
3868 <entry>Produces no output, but tells non-session
3869 processes to stop at this point in the string; ignored by
3870 session processes</entry>
3874 <entry><literal>%%</literal></entry>
3875 <entry>Literal <literal>%</></entry>
3882 The <literal>%c</> escape prints a quasi-unique session identifier,
3883 consisting of two 4-byte hexadecimal numbers (without leading zeros)
3884 separated by a dot. The numbers are the process start time and the
3885 process ID, so <literal>%c</> can also be used as a space saving way
3886 of printing those items. For example, to generate the session
3887 identifier from <literal>pg_stat_activity</>, use this query:
3889 SELECT to_hex(EXTRACT(EPOCH FROM backend_start)::integer) || '.' ||
3891 FROM pg_stat_activity;
3898 If you set a nonempty value for <varname>log_line_prefix</>,
3899 you should usually make its last character be a space, to provide
3900 visual separation from the rest of the log line. A punctuation
3901 character can be used too.
3907 <application>Syslog</> produces its own
3908 time stamp and process ID information, so you probably do not want to
3909 include those escapes if you are logging to <application>syslog</>.
3915 <varlistentry id="guc-log-lock-waits" xreflabel="log_lock_waits">
3916 <term><varname>log_lock_waits</varname> (<type>boolean</type>)</term>
3918 <primary><varname>log_lock_waits</> configuration parameter</primary>
3922 Controls whether a log message is produced when a session waits
3923 longer than <xref linkend="guc-deadlock-timeout"> to acquire a
3924 lock. This is useful in determining if lock waits are causing
3925 poor performance. The default is <literal>off</>.
3930 <varlistentry id="guc-log-statement" xreflabel="log_statement">
3931 <term><varname>log_statement</varname> (<type>enum</type>)</term>
3933 <primary><varname>log_statement</> configuration parameter</primary>
3937 Controls which SQL statements are logged. Valid values are
3938 <literal>none</> (off), <literal>ddl</>, <literal>mod</>, and
3939 <literal>all</> (all statements). <literal>ddl</> logs all data definition
3940 statements, such as <command>CREATE</>, <command>ALTER</>, and
3941 <command>DROP</> statements. <literal>mod</> logs all
3942 <literal>ddl</> statements, plus data-modifying statements
3943 such as <command>INSERT</>,
3944 <command>UPDATE</>, <command>DELETE</>, <command>TRUNCATE</>,
3945 and <command>COPY FROM</>.
3946 <command>PREPARE</>, <command>EXECUTE</>, and
3947 <command>EXPLAIN ANALYZE</> statements are also logged if their
3948 contained command is of an appropriate type. For clients using
3949 extended query protocol, logging occurs when an Execute message
3950 is received, and values of the Bind parameters are included
3951 (with any embedded single-quote marks doubled).
3955 The default is <literal>none</>. Only superusers can change this
3961 Statements that contain simple syntax errors are not logged
3962 even by the <varname>log_statement</> = <literal>all</> setting,
3963 because the log message is emitted only after basic parsing has
3964 been done to determine the statement type. In the case of extended
3965 query protocol, this setting likewise does not log statements that
3966 fail before the Execute phase (i.e., during parse analysis or
3967 planning). Set <varname>log_min_error_statement</> to
3968 <literal>ERROR</> (or lower) to log such statements.
3974 <varlistentry id="guc-log-temp-files" xreflabel="log_temp_files">
3975 <term><varname>log_temp_files</varname> (<type>integer</type>)</term>
3977 <primary><varname>log_temp_files</> configuration parameter</primary>
3981 Controls logging of temporary file names and sizes.
3982 Temporary files can be
3983 created for sorts, hashes, and temporary query results.
3984 A log entry is made for each temporary file when it is deleted.
3985 A value of zero logs all temporary file information, while positive
3986 values log only files whose size is greater than or equal to
3987 the specified number of kilobytes. The
3988 default setting is -1, which disables such logging.
3989 Only superusers can change this setting.
3994 <varlistentry id="guc-log-timezone" xreflabel="log_timezone">
3995 <term><varname>log_timezone</varname> (<type>string</type>)</term>
3997 <primary><varname>log_timezone</> configuration parameter</primary>
4001 Sets the time zone used for timestamps written in the server log.
4002 Unlike <xref linkend="guc-timezone">, this value is cluster-wide,
4003 so that all sessions will report timestamps consistently.
4004 The built-in default is <literal>GMT</>, but that is typically
4005 overridden in <filename>postgresql.conf</>; <application>initdb</>
4006 will install a setting there corresponding to its system environment.
4007 See <xref linkend="datatype-timezones"> for more information.
4008 This parameter can only be set in the <filename>postgresql.conf</>
4009 file or on the server command line.
4016 <sect2 id="runtime-config-logging-csvlog">
4017 <title>Using CSV-Format Log Output</title>
4020 Including <literal>csvlog</> in the <varname>log_destination</> list
4021 provides a convenient way to import log files into a database table.
4022 This option emits log lines in comma-separated-values
4023 (<acronym>CSV</>) format,
4025 time stamp with milliseconds,
4029 client host:port number,
4031 per-session line number,
4034 virtual transaction ID,
4035 regular transaction ID,
4039 error message detail,
4041 internal query that led to the error (if any),
4042 character count of the error position therein,
4044 user query that led to the error (if any and enabled by
4045 <varname>log_min_error_statement</>),
4046 character count of the error position therein,
4047 location of the error in the PostgreSQL source code
4048 (if <varname>log_error_verbosity</> is set to <literal>verbose</>),
4049 and application name.
4050 Here is a sample table definition for storing CSV-format log output:
4053 CREATE TABLE postgres_log
4055 log_time timestamp(3) with time zone,
4059 connection_from text,
4061 session_line_num bigint,
4063 session_start_time timestamp with time zone,
4064 virtual_transaction_id text,
4065 transaction_id bigint,
4066 error_severity text,
4067 sql_state_code text,
4071 internal_query text,
4072 internal_query_pos integer,
4077 application_name text,
4078 PRIMARY KEY (session_id, session_line_num)
4084 To import a log file into this table, use the <command>COPY FROM</>
4088 COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
4093 There are a few things you need to do to simplify importing CSV log
4099 Set <varname>log_filename</varname> and
4100 <varname>log_rotation_age</> to provide a consistent,
4101 predictable naming scheme for your log files. This lets you
4102 predict what the file name will be and know when an individual log
4103 file is complete and therefore ready to be imported.
4109 Set <varname>log_rotation_size</varname> to 0 to disable
4110 size-based log rotation, as it makes the log file name difficult
4117 Set <varname>log_truncate_on_rotation</varname> to <literal>on</> so
4118 that old log data isn't mixed with the new in the same file.
4124 The table definition above includes a primary key specification.
4125 This is useful to protect against accidentally importing the same
4126 information twice. The <command>COPY</> command commits all of the
4127 data it imports at one time, so any error will cause the entire
4128 import to fail. If you import a partial log file and later import
4129 the file again when it is complete, the primary key violation will
4130 cause the import to fail. Wait until the log is complete and
4131 closed before importing. This procedure will also protect against
4132 accidentally importing a partial line that hasn't been completely
4133 written, which would also cause <command>COPY</> to fail.
4142 <sect1 id="runtime-config-statistics">
4143 <title>Run-time Statistics</title>
4145 <sect2 id="runtime-config-statistics-collector">
4146 <title>Query and Index Statistics Collector</title>
4149 These parameters control server-wide statistics collection features.
4150 When statistics collection is enabled, the data that is produced can be
4151 accessed via the <structname>pg_stat</structname> and
4152 <structname>pg_statio</structname> family of system views.
4153 Refer to <xref linkend="monitoring"> for more information.
4158 <varlistentry id="guc-track-activities" xreflabel="track_activities">
4159 <term><varname>track_activities</varname> (<type>boolean</type>)</term>
4161 <primary><varname>track_activities</> configuration parameter</primary>
4165 Enables the collection of information on the currently
4166 executing command of each session, along with the time when
4167 that command began execution. This parameter is on by
4168 default. Note that even when enabled, this information is not
4169 visible to all users, only to superusers and the user owning
4170 the session being reported on, so it should not represent a
4172 Only superusers can change this setting.
4177 <varlistentry id="guc-track-activity-query-size" xreflabel="track_activity_query_size">
4178 <term><varname>track_activity_query_size</varname> (<type>integer</type>)</term>
4180 <primary><varname>track_activity_query_size</> configuration parameter</primary>
4184 Specifies the number of bytes reserved to track the currently
4185 executing command for each active session, for the
4186 <structname>pg_stat_activity</>.<structfield>query</> field.
4187 The default value is 1024. This parameter can only be set at server
4193 <varlistentry id="guc-track-counts" xreflabel="track_counts">
4194 <term><varname>track_counts</varname> (<type>boolean</type>)</term>
4196 <primary><varname>track_counts</> configuration parameter</primary>
4200 Enables collection of statistics on database activity.
4201 This parameter is on by default, because the autovacuum
4202 daemon needs the collected information.
4203 Only superusers can change this setting.
4208 <varlistentry id="guc-track-functions" xreflabel="track_functions">
4209 <term><varname>track_functions</varname> (<type>enum</type>)</term>
4211 <primary><varname>track_functions</> configuration parameter</primary>
4215 Enables tracking of function call counts and time used. Specify
4216 <literal>pl</literal> to track only procedural-language functions,
4217 <literal>all</literal> to also track SQL and C language functions.
4218 The default is <literal>none</literal>, which disables function
4219 statistics tracking. Only superusers can change this setting.
4224 SQL-language functions that are simple enough to be <quote>inlined</>
4225 into the calling query will not be tracked, regardless of this
4232 <varlistentry id="guc-update-process-title" xreflabel="update_process_title">
4233 <term><varname>update_process_title</varname> (<type>boolean</type>)</term>
4235 <primary><varname>update_process_title</> configuration parameter</primary>
4239 Enables updating of the process title every time a new SQL command
4240 is received by the server. The process title is typically viewed
4241 by the <command>ps</> command,
4242 or in Windows by using the <application>Process Explorer</>.
4243 Only superusers can change this setting.
4248 <varlistentry id="guc-stats-temp-directory" xreflabel="stats_temp_directory">
4249 <term><varname>stats_temp_directory</varname> (<type>string</type>)</term>
4251 <primary><varname>stats_temp_directory</> configuration parameter</primary>
4255 Sets the directory to store temporary statistics data in. This can be
4256 a path relative to the data directory or an absolute path. The default
4257 is <filename>pg_stat_tmp</filename>. Pointing this at a RAM-based
4258 file system will decrease physical I/O requirements and can lead to
4259 improved performance.
4260 This parameter can only be set in the <filename>postgresql.conf</>
4261 file or on the server command line.
4269 <sect2 id="runtime-config-statistics-monitor">
4270 <title>Statistics Monitoring</title>
4274 <term><varname>log_statement_stats</varname> (<type>boolean</type>)</term>
4275 <term><varname>log_parser_stats</varname> (<type>boolean</type>)</term>
4276 <term><varname>log_planner_stats</varname> (<type>boolean</type>)</term>
4277 <term><varname>log_executor_stats</varname> (<type>boolean</type>)</term>
4279 <primary><varname>log_statement_stats</> configuration parameter</primary>
4282 <primary><varname>log_parser_stats</> configuration parameter</primary>
4285 <primary><varname>log_planner_stats</> configuration parameter</primary>
4288 <primary><varname>log_executor_stats</> configuration parameter</primary>
4292 For each query, output performance statistics of the respective
4293 module to the server log. This is a crude profiling
4294 instrument, similar to the Unix <function>getrusage()</> operating
4295 system facility. <varname>log_statement_stats</varname> reports total
4296 statement statistics, while the others report per-module statistics.
4297 <varname>log_statement_stats</varname> cannot be enabled together with
4298 any of the per-module options. All of these options are disabled by
4299 default. Only superusers can change these settings.
4309 <sect1 id="runtime-config-autovacuum">
4310 <title>Automatic Vacuuming</title>
4313 <primary>autovacuum</primary>
4314 <secondary>configuration parameters</secondary>
4318 These settings control the behavior of the <firstterm>autovacuum</>
4319 feature. Refer to <xref linkend="autovacuum"> for
4325 <varlistentry id="guc-autovacuum" xreflabel="autovacuum">
4326 <term><varname>autovacuum</varname> (<type>boolean</type>)</term>
4328 <primary><varname>autovacuum</> configuration parameter</primary>
4332 Controls whether the server should run the
4333 autovacuum launcher daemon. This is on by default; however,
4334 <xref linkend="guc-track-counts"> must also be enabled for
4336 This parameter can only be set in the <filename>postgresql.conf</>
4337 file or on the server command line.
4340 Note that even when this parameter is disabled, the system
4341 will launch autovacuum processes if necessary to
4342 prevent transaction ID wraparound. See <xref
4343 linkend="vacuum-for-wraparound"> for more information.
4348 <varlistentry id="guc-log-autovacuum-min-duration" xreflabel="log_autovacuum_min_duration">
4349 <term><varname>log_autovacuum_min_duration</varname> (<type>integer</type>)</term>
4351 <primary><varname>log_autovacuum_min_duration</> configuration parameter</primary>
4355 Causes each action executed by autovacuum to be logged if it ran for at
4356 least the specified number of milliseconds. Setting this to zero logs
4357 all autovacuum actions. Minus-one (the default) disables logging
4358 autovacuum actions. For example, if you set this to
4359 <literal>250ms</literal> then all automatic vacuums and analyzes that run
4360 250ms or longer will be logged. In addition, when this parameter is
4361 set to any value other than <literal>-1</literal>, a message will be
4362 logged if an autovacuum action is skipped due to the existence of a
4363 conflicting lock. Enabling this parameter can be helpful
4364 in tracking autovacuum activity. This setting can only be set in
4365 the <filename>postgresql.conf</> file or on the server command line.
4370 <varlistentry id="guc-autovacuum-max-workers" xreflabel="autovacuum_max_workers">
4371 <term><varname>autovacuum_max_workers</varname> (<type>integer</type>)</term>
4373 <primary><varname>autovacuum_max_workers</> configuration parameter</primary>
4377 Specifies the maximum number of autovacuum processes (other than the
4378 autovacuum launcher) which may be running at any one time. The default
4379 is three. This parameter can only be set at server start.
4384 <varlistentry id="guc-autovacuum-naptime" xreflabel="autovacuum_naptime">
4385 <term><varname>autovacuum_naptime</varname> (<type>integer</type>)</term>
4387 <primary><varname>autovacuum_naptime</> configuration parameter</primary>
4391 Specifies the minimum delay between autovacuum runs on any given
4392 database. In each round the daemon examines the
4393 database and issues <command>VACUUM</> and <command>ANALYZE</> commands
4394 as needed for tables in that database. The delay is measured
4395 in seconds, and the default is one minute (<literal>1min</>).
4396 This parameter can only be set in the <filename>postgresql.conf</>
4397 file or on the server command line.
4402 <varlistentry id="guc-autovacuum-vacuum-threshold" xreflabel="autovacuum_vacuum_threshold">
4403 <term><varname>autovacuum_vacuum_threshold</varname> (<type>integer</type>)</term>
4405 <primary><varname>autovacuum_vacuum_threshold</> configuration parameter</primary>
4409 Specifies the minimum number of updated or deleted tuples needed
4410 to trigger a <command>VACUUM</> in any one table.
4411 The default is 50 tuples.
4412 This parameter can only be set in the <filename>postgresql.conf</>
4413 file or on the server command line.
4414 This setting can be overridden for individual tables by
4415 changing storage parameters.
4420 <varlistentry id="guc-autovacuum-analyze-threshold" xreflabel="autovacuum_analyze_threshold">
4421 <term><varname>autovacuum_analyze_threshold</varname> (<type>integer</type>)</term>
4423 <primary><varname>autovacuum_analyze_threshold</> configuration parameter</primary>
4427 Specifies the minimum number of inserted, updated or deleted tuples
4428 needed to trigger an <command>ANALYZE</> in any one table.
4429 The default is 50 tuples.
4430 This parameter can only be set in the <filename>postgresql.conf</>
4431 file or on the server command line.
4432 This setting can be overridden for individual tables by
4433 changing storage parameters.
4438 <varlistentry id="guc-autovacuum-vacuum-scale-factor" xreflabel="autovacuum_vacuum_scale_factor">
4439 <term><varname>autovacuum_vacuum_scale_factor</varname> (<type>floating point</type>)</term>
4441 <primary><varname>autovacuum_vacuum_scale_factor</> configuration parameter</primary>
4445 Specifies a fraction of the table size to add to
4446 <varname>autovacuum_vacuum_threshold</varname>
4447 when deciding whether to trigger a <command>VACUUM</>.
4448 The default is 0.2 (20% of table size).
4449 This parameter can only be set in the <filename>postgresql.conf</>
4450 file or on the server command line.
4451 This setting can be overridden for individual tables by
4452 changing storage parameters.
4457 <varlistentry id="guc-autovacuum-analyze-scale-factor" xreflabel="autovacuum_analyze_scale_factor">
4458 <term><varname>autovacuum_analyze_scale_factor</varname> (<type>floating point</type>)</term>
4460 <primary><varname>autovacuum_analyze_scale_factor</> configuration parameter</primary>
4464 Specifies a fraction of the table size to add to
4465 <varname>autovacuum_analyze_threshold</varname>
4466 when deciding whether to trigger an <command>ANALYZE</>.
4467 The default is 0.1 (10% of table size).
4468 This parameter can only be set in the <filename>postgresql.conf</>
4469 file or on the server command line.
4470 This setting can be overridden for individual tables by
4471 changing storage parameters.
4476 <varlistentry id="guc-autovacuum-freeze-max-age" xreflabel="autovacuum_freeze_max_age">
4477 <term><varname>autovacuum_freeze_max_age</varname> (<type>integer</type>)</term>
4479 <primary><varname>autovacuum_freeze_max_age</> configuration parameter</primary>
4483 Specifies the maximum age (in transactions) that a table's
4484 <structname>pg_class</>.<structfield>relfrozenxid</> field can
4485 attain before a <command>VACUUM</> operation is forced
4486 to prevent transaction ID wraparound within the table.
4487 Note that the system will launch autovacuum processes to
4488 prevent wraparound even when autovacuum is otherwise disabled.
4492 Vacuum also allows removal of old files from the
4493 <filename>pg_clog</> subdirectory, which is why the default
4494 is a relatively low 200 million transactions.
4495 This parameter can only be set at server start, but the setting
4496 can be reduced for individual tables by
4497 changing storage parameters.
4498 For more information see <xref linkend="vacuum-for-wraparound">.
4503 <varlistentry id="guc-autovacuum-vacuum-cost-delay" xreflabel="autovacuum_vacuum_cost_delay">
4504 <term><varname>autovacuum_vacuum_cost_delay</varname> (<type>integer</type>)</term>
4506 <primary><varname>autovacuum_vacuum_cost_delay</> configuration parameter</primary>
4510 Specifies the cost delay value that will be used in automatic
4511 <command>VACUUM</> operations. If -1 is specified, the regular
4512 <xref linkend="guc-vacuum-cost-delay"> value will be used.
4513 The default value is 20 milliseconds.
4514 This parameter can only be set in the <filename>postgresql.conf</>
4515 file or on the server command line.
4516 This setting can be overridden for individual tables by
4517 changing storage parameters.
4522 <varlistentry id="guc-autovacuum-vacuum-cost-limit" xreflabel="autovacuum_vacuum_cost_limit">
4523 <term><varname>autovacuum_vacuum_cost_limit</varname> (<type>integer</type>)</term>
4525 <primary><varname>autovacuum_vacuum_cost_limit</> configuration parameter</primary>
4529 Specifies the cost limit value that will be used in automatic
4530 <command>VACUUM</> operations. If -1 is specified (which is the
4531 default), the regular
4532 <xref linkend="guc-vacuum-cost-limit"> value will be used. Note that
4533 the value is distributed proportionally among the running autovacuum
4534 workers, if there is more than one, so that the sum of the limits of
4535 each worker never exceeds the limit on this variable.
4536 This parameter can only be set in the <filename>postgresql.conf</>
4537 file or on the server command line.
4538 This setting can be overridden for individual tables by
4539 changing storage parameters.
4547 <sect1 id="runtime-config-client">
4548 <title>Client Connection Defaults</title>
4550 <sect2 id="runtime-config-client-statement">
4551 <title>Statement Behavior</title>
4554 <varlistentry id="guc-search-path" xreflabel="search_path">
4555 <term><varname>search_path</varname> (<type>string</type>)</term>
4557 <primary><varname>search_path</> configuration parameter</primary>
4559 <indexterm><primary>path</><secondary>for schemas</></>
4562 This variable specifies the order in which schemas are searched
4563 when an object (table, data type, function, etc.) is referenced by a
4564 simple name with no schema specified. When there are objects of
4565 identical names in different schemas, the one found first
4566 in the search path is used. An object that is not in any of the
4567 schemas in the search path can only be referenced by specifying
4568 its containing schema with a qualified (dotted) name.
4572 The value for <varname>search_path</varname> must be a comma-separated
4573 list of schema names. If one of the list items is
4574 the special value <literal>$user</literal>, then the schema
4575 having the name returned by <function>SESSION_USER</> is substituted, if there
4576 is such a schema. (If not, <literal>$user</literal> is ignored.)
4580 The system catalog schema, <literal>pg_catalog</>, is always
4581 searched, whether it is mentioned in the path or not. If it is
4582 mentioned in the path then it will be searched in the specified
4583 order. If <literal>pg_catalog</> is not in the path then it will
4584 be searched <emphasis>before</> searching any of the path items.
4588 Likewise, the current session's temporary-table schema,
4589 <literal>pg_temp_<replaceable>nnn</></>, is always searched if it
4590 exists. It can be explicitly listed in the path by using the
4591 alias <literal>pg_temp</>. If it is not listed in the path then
4592 it is searched first (even before <literal>pg_catalog</>). However,
4593 the temporary schema is only searched for relation (table, view,
4594 sequence, etc) and data type names. It is never searched for
4595 function or operator names.
4599 When objects are created without specifying a particular target
4600 schema, they will be placed in the first schema listed
4601 in the search path. An error is reported if the search path is
4606 The default value for this parameter is
4607 <literal>'"$user", public'</literal> (where the second part will be
4608 ignored if there is no schema named <literal>public</>).
4609 This supports shared use of a database (where no users
4610 have private schemas, and all share use of <literal>public</>),
4611 private per-user schemas, and combinations of these. Other
4612 effects can be obtained by altering the default search path
4613 setting, either globally or per-user.
4617 The current effective value of the search path can be examined
4618 via the <acronym>SQL</acronym> function
4619 <function>current_schemas</>
4620 (see <xref linkend="functions-info">).
4621 This is not quite the same as
4622 examining the value of <varname>search_path</varname>, since
4623 <function>current_schemas</> shows how the items
4624 appearing in <varname>search_path</varname> were resolved.
4628 For more information on schema handling, see <xref linkend="ddl-schemas">.
4633 <varlistentry id="guc-default-tablespace" xreflabel="default_tablespace">
4634 <term><varname>default_tablespace</varname> (<type>string</type>)</term>
4636 <primary><varname>default_tablespace</> configuration parameter</primary>
4638 <indexterm><primary>tablespace</><secondary>default</></>
4641 This variable specifies the default tablespace in which to create
4642 objects (tables and indexes) when a <command>CREATE</> command does
4643 not explicitly specify a tablespace.
4647 The value is either the name of a tablespace, or an empty string
4648 to specify using the default tablespace of the current database.
4649 If the value does not match the name of any existing tablespace,
4650 <productname>PostgreSQL</> will automatically use the default
4651 tablespace of the current database. If a nondefault tablespace
4652 is specified, the user must have <literal>CREATE</> privilege
4653 for it, or creation attempts will fail.
4657 This variable is not used for temporary tables; for them,
4658 <xref linkend="guc-temp-tablespaces"> is consulted instead.
4662 This variable is also not used when creating databases.
4663 By default, a new database inherits its tablespace setting from
4664 the template database it is copied from.
4668 For more information on tablespaces,
4669 see <xref linkend="manage-ag-tablespaces">.
4674 <varlistentry id="guc-temp-tablespaces" xreflabel="temp_tablespaces">
4675 <term><varname>temp_tablespaces</varname> (<type>string</type>)</term>
4677 <primary><varname>temp_tablespaces</> configuration parameter</primary>
4679 <indexterm><primary>tablespace</><secondary>temporary</></>
4682 This variable specifies tablespaces in which to create temporary
4683 objects (temp tables and indexes on temp tables) when a
4684 <command>CREATE</> command does not explicitly specify a tablespace.
4685 Temporary files for purposes such as sorting large data sets
4686 are also created in these tablespaces.
4690 The value is a list of names of tablespaces. When there is more than
4691 one name in the list, <productname>PostgreSQL</> chooses a random
4692 member of the list each time a temporary object is to be created;
4693 except that within a transaction, successively created temporary
4694 objects are placed in successive tablespaces from the list.
4695 If the selected element of the list is an empty string,
4696 <productname>PostgreSQL</> will automatically use the default
4697 tablespace of the current database instead.
4701 When <varname>temp_tablespaces</> is set interactively, specifying a
4702 nonexistent tablespace is an error, as is specifying a tablespace for
4703 which the user does not have <literal>CREATE</> privilege. However,
4704 when using a previously set value, nonexistent tablespaces are
4705 ignored, as are tablespaces for which the user lacks
4706 <literal>CREATE</> privilege. In particular, this rule applies when
4707 using a value set in <filename>postgresql.conf</>.
4711 The default value is an empty string, which results in all temporary
4712 objects being created in the default tablespace of the current
4717 See also <xref linkend="guc-default-tablespace">.
4722 <varlistentry id="guc-check-function-bodies" xreflabel="check_function_bodies">
4723 <term><varname>check_function_bodies</varname> (<type>boolean</type>)</term>
4725 <primary><varname>check_function_bodies</> configuration parameter</primary>
4729 This parameter is normally on. When set to <literal>off</>, it
4730 disables validation of the function body string during <xref
4731 linkend="sql-createfunction">. Disabling validation is
4732 occasionally useful to avoid problems such as forward references
4733 when restoring function definitions from a dump.
4738 <varlistentry id="guc-default-transaction-isolation" xreflabel="default_transaction_isolation">
4740 <primary>transaction isolation level</primary>
4741 <secondary>setting default</secondary>
4744 <primary><varname>default_transaction_isolation</> configuration parameter</primary>
4746 <term><varname>default_transaction_isolation</varname> (<type>enum</type>)</term>
4749 Each SQL transaction has an isolation level, which can be
4750 either <quote>read uncommitted</quote>, <quote>read
4751 committed</quote>, <quote>repeatable read</quote>, or
4752 <quote>serializable</quote>. This parameter controls the
4753 default isolation level of each new transaction. The default
4754 is <quote>read committed</quote>.
4758 Consult <xref linkend="mvcc"> and <xref
4759 linkend="sql-set-transaction"> for more information.
4764 <varlistentry id="guc-default-transaction-read-only" xreflabel="default_transaction_read_only">
4766 <primary>read-only transaction</primary>
4767 <secondary>setting default</secondary>
4770 <primary><varname>default_transaction_read_only</> configuration parameter</primary>
4773 <term><varname>default_transaction_read_only</varname> (<type>boolean</type>)</term>
4776 A read-only SQL transaction cannot alter non-temporary tables.
4777 This parameter controls the default read-only status of each new
4778 transaction. The default is <literal>off</> (read/write).
4782 Consult <xref linkend="sql-set-transaction"> for more information.
4787 <varlistentry id="guc-default-transaction-deferrable" xreflabel="default_transaction_deferrable">
4789 <primary>deferrable transaction</primary>
4790 <secondary>setting default</secondary>
4793 <primary><varname>default_transaction_deferrable</> configuration parameter</primary>
4796 <term><varname>default_transaction_deferrable</varname> (<type>boolean</type>)</term>
4799 When running at the <literal>serializable</> isolation level,
4800 a deferrable read-only SQL transaction may be delayed before
4801 it is allowed to proceed. However, once it begins executing
4802 it does not incur any of the overhead required to ensure
4803 serializability; so serialization code will have no reason to
4804 force it to abort because of concurrent updates, making this
4805 option suitable for long-running read-only transactions.
4809 This parameter controls the default deferrable status of each
4810 new transaction. It currently has no effect on read-write
4811 transactions or those operating at isolation levels lower
4812 than <literal>serializable</>. The default is <literal>off</>.
4816 Consult <xref linkend="sql-set-transaction"> for more information.
4822 <varlistentry id="guc-session-replication-role" xreflabel="session_replication_role">
4823 <term><varname>session_replication_role</varname> (<type>enum</type>)</term>
4825 <primary><varname>session_replication_role</> configuration parameter</primary>
4829 Controls firing of replication-related triggers and rules for the
4830 current session. Setting this variable requires
4831 superuser privilege and results in discarding any previously cached
4832 query plans. Possible values are <literal>origin</> (the default),
4833 <literal>replica</> and <literal>local</>.
4834 See <xref linkend="sql-altertable"> for
4840 <varlistentry id="guc-statement-timeout" xreflabel="statement_timeout">
4841 <term><varname>statement_timeout</varname> (<type>integer</type>)</term>
4843 <primary><varname>statement_timeout</> configuration parameter</primary>
4847 Abort any statement that takes over the specified number of
4848 milliseconds, starting from the time the command arrives at the server
4849 from the client. If <varname>log_min_error_statement</> is set to
4850 <literal>ERROR</> or lower, the statement that timed out will also be
4851 logged. A value of zero (the default) turns this off.
4855 Setting <varname>statement_timeout</> in
4856 <filename>postgresql.conf</> is not recommended because it
4857 affects all sessions.
4862 <varlistentry id="guc-vacuum-freeze-table-age" xreflabel="vacuum_freeze_table_age">
4863 <term><varname>vacuum_freeze_table_age</varname> (<type>integer</type>)</term>
4865 <primary><varname>vacuum_freeze_table_age</> configuration parameter</primary>
4869 <command>VACUUM</> performs a whole-table scan if the table's
4870 <structname>pg_class</>.<structfield>relfrozenxid</> field has reached
4871 the age specified by this setting. The default is 150 million
4872 transactions. Although users can set this value anywhere from zero to
4873 one billion, <command>VACUUM</> will silently limit the effective value
4874 to 95% of <xref linkend="guc-autovacuum-freeze-max-age">, so that a
4875 periodical manual <command>VACUUM</> has a chance to run before an
4876 anti-wraparound autovacuum is launched for the table. For more
4878 <xref linkend="vacuum-for-wraparound">.
4883 <varlistentry id="guc-vacuum-freeze-min-age" xreflabel="vacuum_freeze_min_age">
4884 <term><varname>vacuum_freeze_min_age</varname> (<type>integer</type>)</term>
4886 <primary><varname>vacuum_freeze_min_age</> configuration parameter</primary>
4890 Specifies the cutoff age (in transactions) that <command>VACUUM</>
4891 should use to decide whether to replace transaction IDs with
4892 <literal>FrozenXID</> while scanning a table.
4893 The default is 50 million transactions. Although
4894 users can set this value anywhere from zero to one billion,
4895 <command>VACUUM</> will silently limit the effective value to half
4896 the value of <xref linkend="guc-autovacuum-freeze-max-age">, so
4897 that there is not an unreasonably short time between forced
4898 autovacuums. For more information see <xref
4899 linkend="vacuum-for-wraparound">.
4904 <varlistentry id="guc-bytea-output" xreflabel="bytea_output">
4905 <term><varname>bytea_output</varname> (<type>enum</type>)</term>
4907 <primary><varname>bytea_output</> configuration parameter</primary>
4911 Sets the output format for values of type <type>bytea</type>.
4912 Valid values are <literal>hex</literal> (the default)
4913 and <literal>escape</literal> (the traditional PostgreSQL
4914 format). See <xref linkend="datatype-binary"> for more
4915 information. The <type>bytea</type> type always
4916 accepts both formats on input, regardless of this setting.
4921 <varlistentry id="guc-xmlbinary" xreflabel="xmlbinary">
4922 <term><varname>xmlbinary</varname> (<type>enum</type>)</term>
4924 <primary><varname>xmlbinary</> configuration parameter</primary>
4928 Sets how binary values are to be encoded in XML. This applies
4929 for example when <type>bytea</type> values are converted to
4930 XML by the functions <function>xmlelement</function> or
4931 <function>xmlforest</function>. Possible values are
4932 <literal>base64</literal> and <literal>hex</literal>, which
4933 are both defined in the XML Schema standard. The default is
4934 <literal>base64</literal>. For further information about
4935 XML-related functions, see <xref linkend="functions-xml">.
4939 The actual choice here is mostly a matter of taste,
4940 constrained only by possible restrictions in client
4941 applications. Both methods support all possible values,
4942 although the hex encoding will be somewhat larger than the
4948 <varlistentry id="guc-xmloption" xreflabel="xmloption">
4949 <term><varname>xmloption</varname> (<type>enum</type>)</term>
4951 <primary><varname>xmloption</> configuration parameter</primary>
4954 <primary><varname>SET XML OPTION</></primary>
4957 <primary>XML option</primary>
4961 Sets whether <literal>DOCUMENT</literal> or
4962 <literal>CONTENT</literal> is implicit when converting between
4963 XML and character string values. See <xref
4964 linkend="datatype-xml"> for a description of this. Valid
4965 values are <literal>DOCUMENT</literal> and
4966 <literal>CONTENT</literal>. The default is
4967 <literal>CONTENT</literal>.
4971 According to the SQL standard, the command to set this option is
4973 SET XML OPTION { DOCUMENT | CONTENT };
4975 This syntax is also available in PostgreSQL.
4982 <sect2 id="runtime-config-client-format">
4983 <title>Locale and Formatting</title>
4987 <varlistentry id="guc-datestyle" xreflabel="DateStyle">
4988 <term><varname>DateStyle</varname> (<type>string</type>)</term>
4990 <primary><varname>DateStyle</> configuration parameter</primary>
4994 Sets the display format for date and time values, as well as the
4995 rules for interpreting ambiguous date input values. For
4996 historical reasons, this variable contains two independent
4997 components: the output format specification (<literal>ISO</>,
4998 <literal>Postgres</>, <literal>SQL</>, or <literal>German</>)
4999 and the input/output specification for year/month/day ordering
5000 (<literal>DMY</>, <literal>MDY</>, or <literal>YMD</>). These
5001 can be set separately or together. The keywords <literal>Euro</>
5002 and <literal>European</> are synonyms for <literal>DMY</>; the
5003 keywords <literal>US</>, <literal>NonEuro</>, and
5004 <literal>NonEuropean</> are synonyms for <literal>MDY</>. See
5005 <xref linkend="datatype-datetime"> for more information. The
5006 built-in default is <literal>ISO, MDY</>, but
5007 <application>initdb</application> will initialize the
5008 configuration file with a setting that corresponds to the
5009 behavior of the chosen <varname>lc_time</varname> locale.
5014 <varlistentry id="guc-intervalstyle" xreflabel="IntervalStyle">
5015 <term><varname>IntervalStyle</varname> (<type>enum</type>)</term>
5017 <primary><varname>IntervalStyle</> configuration parameter</primary>
5021 Sets the display format for interval values.
5022 The value <literal>sql_standard</> will produce
5023 output matching <acronym>SQL</acronym> standard interval literals.
5024 The value <literal>postgres</> (which is the default) will produce
5025 output matching <productname>PostgreSQL</> releases prior to 8.4
5026 when the <xref linkend="guc-datestyle">
5027 parameter was set to <literal>ISO</>.
5028 The value <literal>postgres_verbose</> will produce output
5029 matching <productname>PostgreSQL</> releases prior to 8.4
5030 when the <varname>DateStyle</>
5031 parameter was set to non-<literal>ISO</> output.
5032 The value <literal>iso_8601</> will produce output matching the time
5033 interval <quote>format with designators</> defined in section
5034 4.4.3.2 of ISO 8601.
5037 The <varname>IntervalStyle</> parameter also affects the
5038 interpretation of ambiguous interval input. See
5039 <xref linkend="datatype-interval-input"> for more information.
5044 <varlistentry id="guc-timezone" xreflabel="timezone">
5045 <term><varname>timezone</varname> (<type>string</type>)</term>
5047 <primary><varname>timezone</> configuration parameter</primary>
5049 <indexterm><primary>time zone</></>
5052 Sets the time zone for displaying and interpreting time stamps.
5053 The built-in default is <literal>GMT</>, but that is typically
5054 overridden in <filename>postgresql.conf</>; <application>initdb</>
5055 will install a setting there corresponding to its system environment.
5056 See <xref linkend="datatype-timezones"> for more information.
5061 <varlistentry id="guc-timezone-abbreviations" xreflabel="timezone_abbreviations">
5062 <term><varname>timezone_abbreviations</varname> (<type>string</type>)</term>
5064 <primary><varname>timezone_abbreviations</> configuration parameter</primary>
5066 <indexterm><primary>time zone names</></>
5069 Sets the collection of time zone abbreviations that will be accepted
5070 by the server for datetime input. The default is <literal>'Default'</>,
5071 which is a collection that works in most of the world; there are
5072 also <literal>'Australia'</literal> and <literal>'India'</literal>, and other collections can be defined
5073 for a particular installation. See <xref
5074 linkend="datetime-appendix"> for more information.
5079 <varlistentry id="guc-extra-float-digits" xreflabel="extra_float_digits">
5081 <primary>significant digits</primary>
5084 <primary>floating-point</primary>
5085 <secondary>display</secondary>
5088 <primary><varname>extra_float_digits</> configuration parameter</primary>
5091 <term><varname>extra_float_digits</varname> (<type>integer</type>)</term>
5094 This parameter adjusts the number of digits displayed for
5095 floating-point values, including <type>float4</>, <type>float8</>,
5096 and geometric data types. The parameter value is added to the
5097 standard number of digits (<literal>FLT_DIG</> or <literal>DBL_DIG</>
5098 as appropriate). The value can be set as high as 3, to include
5099 partially-significant digits; this is especially useful for dumping
5100 float data that needs to be restored exactly. Or it can be set
5101 negative to suppress unwanted digits.
5106 <varlistentry id="guc-client-encoding" xreflabel="client_encoding">
5107 <term><varname>client_encoding</varname> (<type>string</type>)</term>
5109 <primary><varname>client_encoding</> configuration parameter</primary>
5111 <indexterm><primary>character set</></>
5114 Sets the client-side encoding (character set).
5115 The default is to use the database encoding.
5116 The character sets supported by the <productname>PostgreSQL</productname>
5117 server are described in <xref linkend="multibyte-charset-supported">.
5122 <varlistentry id="guc-lc-messages" xreflabel="lc_messages">
5123 <term><varname>lc_messages</varname> (<type>string</type>)</term>
5125 <primary><varname>lc_messages</> configuration parameter</primary>
5129 Sets the language in which messages are displayed. Acceptable
5130 values are system-dependent; see <xref linkend="locale"> for
5131 more information. If this variable is set to the empty string
5132 (which is the default) then the value is inherited from the
5133 execution environment of the server in a system-dependent way.
5137 On some systems, this locale category does not exist. Setting
5138 this variable will still work, but there will be no effect.
5139 Also, there is a chance that no translated messages for the
5140 desired language exist. In that case you will continue to see
5141 the English messages.
5145 Only superusers can change this setting, because it affects the
5146 messages sent to the server log as well as to the client, and
5147 an improper value might obscure the readability of the server
5153 <varlistentry id="guc-lc-monetary" xreflabel="lc_monetary">
5154 <term><varname>lc_monetary</varname> (<type>string</type>)</term>
5156 <primary><varname>lc_monetary</> configuration parameter</primary>
5160 Sets the locale to use for formatting monetary amounts, for
5161 example with the <function>to_char</function> family of
5162 functions. Acceptable values are system-dependent; see <xref
5163 linkend="locale"> for more information. If this variable is
5164 set to the empty string (which is the default) then the value
5165 is inherited from the execution environment of the server in a
5166 system-dependent way.
5171 <varlistentry id="guc-lc-numeric" xreflabel="lc_numeric">
5172 <term><varname>lc_numeric</varname> (<type>string</type>)</term>
5174 <primary><varname>lc_numeric</> configuration parameter</primary>
5178 Sets the locale to use for formatting numbers, for example
5179 with the <function>to_char</function> family of
5180 functions. Acceptable values are system-dependent; see <xref
5181 linkend="locale"> for more information. If this variable is
5182 set to the empty string (which is the default) then the value
5183 is inherited from the execution environment of the server in a
5184 system-dependent way.
5189 <varlistentry id="guc-lc-time" xreflabel="lc_time">
5190 <term><varname>lc_time</varname> (<type>string</type>)</term>
5192 <primary><varname>lc_time</> configuration parameter</primary>
5196 Sets the locale to use for formatting dates and times, for example
5197 with the <function>to_char</function> family of
5198 functions. Acceptable values are system-dependent; see <xref
5199 linkend="locale"> for more information. If this variable is
5200 set to the empty string (which is the default) then the value
5201 is inherited from the execution environment of the server in a
5202 system-dependent way.
5207 <varlistentry id="guc-default-text-search-config" xreflabel="default_text_search_config">
5208 <term><varname>default_text_search_config</varname> (<type>string</type>)</term>
5210 <primary><varname>default_text_search_config</> configuration parameter</primary>
5214 Selects the text search configuration that is used by those variants
5215 of the text search functions that do not have an explicit argument
5216 specifying the configuration.
5217 See <xref linkend="textsearch"> for further information.
5218 The built-in default is <literal>pg_catalog.simple</>, but
5219 <application>initdb</application> will initialize the
5220 configuration file with a setting that corresponds to the
5221 chosen <varname>lc_ctype</varname> locale, if a configuration
5222 matching that locale can be identified.
5230 <sect2 id="runtime-config-client-other">
5231 <title>Other Defaults</title>
5235 <varlistentry id="guc-dynamic-library-path" xreflabel="dynamic_library_path">
5236 <term><varname>dynamic_library_path</varname> (<type>string</type>)</term>
5238 <primary><varname>dynamic_library_path</> configuration parameter</primary>
5240 <indexterm><primary>dynamic loading</></>
5243 If a dynamically loadable module needs to be opened and the
5244 file name specified in the <command>CREATE FUNCTION</command> or
5245 <command>LOAD</command> command
5246 does not have a directory component (i.e., the
5247 name does not contain a slash), the system will search this
5248 path for the required file.
5252 The value for <varname>dynamic_library_path</varname> must be a
5253 list of absolute directory paths separated by colons (or semi-colons
5254 on Windows). If a list element starts
5255 with the special string <literal>$libdir</literal>, the
5256 compiled-in <productname>PostgreSQL</productname> package
5257 library directory is substituted for <literal>$libdir</literal>; this
5258 is where the modules provided by the standard
5259 <productname>PostgreSQL</productname> distribution are installed.
5260 (Use <literal>pg_config --pkglibdir</literal> to find out the name of
5261 this directory.) For example:
5263 dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
5265 or, in a Windows environment:
5267 dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
5272 The default value for this parameter is
5273 <literal>'$libdir'</literal>. If the value is set to an empty
5274 string, the automatic path search is turned off.
5278 This parameter can be changed at run time by superusers, but a
5279 setting done that way will only persist until the end of the
5280 client connection, so this method should be reserved for
5281 development purposes. The recommended way to set this parameter
5282 is in the <filename>postgresql.conf</filename> configuration
5288 <varlistentry id="guc-gin-fuzzy-search-limit" xreflabel="gin_fuzzy_search_limit">
5289 <term><varname>gin_fuzzy_search_limit</varname> (<type>integer</type>)</term>
5291 <primary><varname>gin_fuzzy_search_limit</> configuration parameter</primary>
5295 Soft upper limit of the size of the set returned by GIN index scans. For more
5296 information see <xref linkend="gin-tips">.
5301 <varlistentry id="guc-local-preload-libraries" xreflabel="local_preload_libraries">
5302 <term><varname>local_preload_libraries</varname> (<type>string</type>)</term>
5304 <primary><varname>local_preload_libraries</> configuration parameter</primary>
5307 <primary><filename>$libdir/plugins</></primary>
5311 This variable specifies one or more shared libraries that are
5312 to be preloaded at connection start. If more than one library
5313 is to be loaded, separate their names with commas. All library
5314 names are converted to lower case unless double-quoted.
5315 This parameter cannot be changed after the start of a particular
5320 Because this is not a superuser-only option, the libraries
5321 that can be loaded are restricted to those appearing in the
5322 <filename>plugins</> subdirectory of the installation's
5323 standard library directory. (It is the database administrator's
5324 responsibility to ensure that only <quote>safe</> libraries
5325 are installed there.) Entries in <varname>local_preload_libraries</>
5326 can specify this directory explicitly, for example
5327 <literal>$libdir/plugins/mylib</literal>, or just specify
5328 the library name — <literal>mylib</literal> would have
5329 the same effect as <literal>$libdir/plugins/mylib</literal>.
5333 Unlike <xref linkend="guc-shared-preload-libraries">, there is no
5334 performance advantage to loading a library at session
5335 start rather than when it is first used. Rather, the intent of
5336 this feature is to allow debugging or performance-measurement
5337 libraries to be loaded into specific sessions without an explicit
5338 <command>LOAD</> command being given. For example, debugging could
5339 be enabled for all sessions under a given user name by setting
5340 this parameter with <command>ALTER ROLE SET</>.
5344 If a specified library is not found,
5345 the connection attempt will fail.
5349 Every PostgreSQL-supported library has a <quote>magic
5350 block</> that is checked to guarantee compatibility.
5351 For this reason, non-PostgreSQL libraries cannot be
5361 <sect1 id="runtime-config-locks">
5362 <title>Lock Management</title>
5366 <varlistentry id="guc-deadlock-timeout" xreflabel="deadlock_timeout">
5368 <primary>deadlock</primary>
5369 <secondary>timeout during</secondary>
5372 <primary>timeout</primary>
5373 <secondary>deadlock</secondary>
5376 <primary><varname>deadlock_timeout</> configuration parameter</primary>
5379 <term><varname>deadlock_timeout</varname> (<type>integer</type>)</term>
5382 This is the amount of time, in milliseconds, to wait on a lock
5383 before checking to see if there is a deadlock condition. The
5384 check for deadlock is relatively expensive, so the server doesn't run
5385 it every time it waits for a lock. We optimistically assume
5386 that deadlocks are not common in production applications and
5387 just wait on the lock for a while before checking for a
5388 deadlock. Increasing this value reduces the amount of time
5389 wasted in needless deadlock checks, but slows down reporting of
5390 real deadlock errors. The default is one second (<literal>1s</>),
5391 which is probably about the smallest value you would want in
5392 practice. On a heavily loaded server you might want to raise it.
5393 Ideally the setting should exceed your typical transaction time,
5394 so as to improve the odds that a lock will be released before
5395 the waiter decides to check for deadlock. Only superusers can change
5400 When <xref linkend="guc-log-lock-waits"> is set,
5401 this parameter also determines the length of time to wait before
5402 a log message is issued about the lock wait. If you are trying
5403 to investigate locking delays you might want to set a shorter than
5404 normal <varname>deadlock_timeout</varname>.
5409 <varlistentry id="guc-max-locks-per-transaction" xreflabel="max_locks_per_transaction">
5410 <term><varname>max_locks_per_transaction</varname> (<type>integer</type>)</term>
5412 <primary><varname>max_locks_per_transaction</> configuration parameter</primary>
5416 The shared lock table tracks locks on
5417 <varname>max_locks_per_transaction</varname> * (<xref
5418 linkend="guc-max-connections"> + <xref
5419 linkend="guc-max-prepared-transactions">) objects (e.g., tables);
5420 hence, no more than this many distinct objects can be locked at
5421 any one time. This parameter controls the average number of object
5422 locks allocated for each transaction; individual transactions
5423 can lock more objects as long as the locks of all transactions
5424 fit in the lock table. This is <emphasis>not</> the number of
5425 rows that can be locked; that value is unlimited. The default,
5426 64, has historically proven sufficient, but you might need to
5427 raise this value if you have clients that touch many different
5428 tables in a single transaction. This parameter can only be set at
5433 Increasing this parameter might cause <productname>PostgreSQL</>
5434 to request more <systemitem class="osname">System V</> shared
5435 memory than your operating system's default configuration
5436 allows. See <xref linkend="sysvipc"> for information on how to
5437 adjust those parameters, if necessary.
5441 When running a standby server, you must set this parameter to the
5442 same or higher value than on the master server. Otherwise, queries
5443 will not be allowed in the standby server.
5448 <varlistentry id="guc-max-pred-locks-per-transaction" xreflabel="max_pred_locks_per_transaction">
5449 <term><varname>max_pred_locks_per_transaction</varname> (<type>integer</type>)</term>
5451 <primary><varname>max_pred_locks_per_transaction</> configuration parameter</primary>
5455 The shared predicate lock table tracks locks on
5456 <varname>max_pred_locks_per_transaction</varname> * (<xref
5457 linkend="guc-max-connections"> + <xref
5458 linkend="guc-max-prepared-transactions">) objects (e.g., tables);
5459 hence, no more than this many distinct objects can be locked at
5460 any one time. This parameter controls the average number of object
5461 locks allocated for each transaction; individual transactions
5462 can lock more objects as long as the locks of all transactions
5463 fit in the lock table. This is <emphasis>not</> the number of
5464 rows that can be locked; that value is unlimited. The default,
5465 64, has generally been sufficient in testing, but you might need to
5466 raise this value if you have clients that touch many different
5467 tables in a single serializable transaction. This parameter can
5468 only be set at server start.
5472 Increasing this parameter might cause <productname>PostgreSQL</>
5473 to request more <systemitem class="osname">System V</> shared
5474 memory than your operating system's default configuration
5475 allows. See <xref linkend="sysvipc"> for information on how to
5476 adjust those parameters, if necessary.
5484 <sect1 id="runtime-config-compatible">
5485 <title>Version and Platform Compatibility</title>
5487 <sect2 id="runtime-config-compatible-version">
5488 <title>Previous PostgreSQL Versions</title>
5492 <varlistentry id="guc-array-nulls" xreflabel="array_nulls">
5493 <term><varname>array_nulls</varname> (<type>boolean</type>)</term>
5495 <primary><varname>array_nulls</> configuration parameter</primary>
5499 This controls whether the array input parser recognizes
5500 unquoted <literal>NULL</> as specifying a null array element.
5501 By default, this is <literal>on</>, allowing array values containing
5502 null values to be entered. However, <productname>PostgreSQL</> versions
5503 before 8.2 did not support null values in arrays, and therefore would
5504 treat <literal>NULL</> as specifying a normal array element with
5505 the string value <quote>NULL</>. For backward compatibility with
5506 applications that require the old behavior, this variable can be
5507 turned <literal>off</>.
5511 Note that it is possible to create array values containing null values
5512 even when this variable is <literal>off</>.
5517 <varlistentry id="guc-backslash-quote" xreflabel="backslash_quote">
5518 <term><varname>backslash_quote</varname> (<type>enum</type>)</term>
5519 <indexterm><primary>strings</><secondary>backslash quotes</></>
5521 <primary><varname>backslash_quote</> configuration parameter</primary>
5525 This controls whether a quote mark can be represented by
5526 <literal>\'</> in a string literal. The preferred, SQL-standard way
5527 to represent a quote mark is by doubling it (<literal>''</>) but
5528 <productname>PostgreSQL</> has historically also accepted
5529 <literal>\'</>. However, use of <literal>\'</> creates security risks
5530 because in some client character set encodings, there are multibyte
5531 characters in which the last byte is numerically equivalent to ASCII
5532 <literal>\</>. If client-side code does escaping incorrectly then a
5533 SQL-injection attack is possible. This risk can be prevented by
5534 making the server reject queries in which a quote mark appears to be
5535 escaped by a backslash.
5536 The allowed values of <varname>backslash_quote</> are
5537 <literal>on</> (allow <literal>\'</> always),
5538 <literal>off</> (reject always), and
5539 <literal>safe_encoding</> (allow only if client encoding does not
5540 allow ASCII <literal>\</> within a multibyte character).
5541 <literal>safe_encoding</> is the default setting.
5545 Note that in a standard-conforming string literal, <literal>\</> just
5546 means <literal>\</> anyway. This parameter only affects the handling of
5547 non-standard-conforming literals, including
5548 escape string syntax (<literal>E'...'</>).
5553 <varlistentry id="guc-default-with-oids" xreflabel="default_with_oids">
5554 <term><varname>default_with_oids</varname> (<type>boolean</type>)</term>
5556 <primary><varname>default_with_oids</> configuration parameter</primary>
5560 This controls whether <command>CREATE TABLE</command> and
5561 <command>CREATE TABLE AS</command> include an OID column in
5562 newly-created tables, if neither <literal>WITH OIDS</literal>
5563 nor <literal>WITHOUT OIDS</literal> is specified. It also
5564 determines whether OIDs will be included in tables created by
5565 <command>SELECT INTO</command>. The parameter is <literal>off</>
5566 by default; in <productname>PostgreSQL</> 8.0 and earlier, it
5571 The use of OIDs in user tables is considered deprecated, so
5572 most installations should leave this variable disabled.
5573 Applications that require OIDs for a particular table should
5574 specify <literal>WITH OIDS</literal> when creating the
5575 table. This variable can be enabled for compatibility with old
5576 applications that do not follow this behavior.
5581 <varlistentry id="guc-escape-string-warning" xreflabel="escape_string_warning">
5582 <term><varname>escape_string_warning</varname> (<type>boolean</type>)</term>
5583 <indexterm><primary>strings</><secondary>escape warning</></>
5585 <primary><varname>escape_string_warning</> configuration parameter</primary>
5589 When on, a warning is issued if a backslash (<literal>\</>)
5590 appears in an ordinary string literal (<literal>'...'</>
5591 syntax) and <varname>standard_conforming_strings</varname> is off.
5592 The default is <literal>on</>.
5595 Applications that wish to use backslash as escape should be
5596 modified to use escape string syntax (<literal>E'...'</>),
5597 because the default behavior of ordinary strings is now to treat
5598 backslash as an ordinary character, per SQL standard. This variable
5599 can be enabled to help locate code that needs to be changed.
5604 <varlistentry id="guc-lo-compat-privileges" xreflabel="lo_compat_privileges">
5605 <term><varname>lo_compat_privileges</varname> (<type>boolean</type>)</term>
5607 <primary><varname>lo_compat_privileges</> configuration parameter</primary>
5611 In <productname>PostgreSQL</> releases prior to 9.0, large objects
5612 did not have access privileges and were, in effect, readable and
5613 writable by all users. Setting this variable to <literal>on</>
5614 disables the new privilege checks, for compatibility with prior
5615 releases. The default is <literal>off</>.
5618 Setting this variable does not disable all security checks related to
5619 large objects — only those for which the default behavior has
5620 changed in <productname>PostgreSQL</> 9.0.
5621 For example, <literal>lo_import()</literal> and
5622 <literal>lo_export()</literal> need superuser privileges independent
5628 <varlistentry id="guc-quote-all-identifiers" xreflabel="quote-all-identifiers">
5629 <term><varname>quote_all_identifiers</varname> (<type>boolean</type>)</term>
5631 <primary><varname>quote_all_identifiers</> configuration parameter</primary>
5635 When the database generates SQL, force all identifiers to be quoted,
5636 even if they are not (currently) keywords. This will affect the
5637 output of <command>EXPLAIN</> as well as the results of functions
5638 like <function>pg_get_viewdef</>. See also the
5639 <option>--quote-all-identifiers</option> option of
5640 <xref linkend="app-pgdump"> and <xref linkend="app-pg-dumpall">.
5645 <varlistentry id="guc-sql-inheritance" xreflabel="sql_inheritance">
5646 <term><varname>sql_inheritance</varname> (<type>boolean</type>)</term>
5648 <primary><varname>sql_inheritance</> configuration parameter</primary>
5650 <indexterm><primary>inheritance</></>
5653 This controls the inheritance semantics. If turned <literal>off</>,
5654 subtables are not accessed by various commands by default; basically
5655 an implied <literal>ONLY</literal> key word. This was added for
5656 compatibility with releases prior to 7.1. See
5657 <xref linkend="ddl-inherit"> for more information.
5662 <varlistentry id="guc-standard-conforming-strings" xreflabel="standard_conforming_strings">
5663 <term><varname>standard_conforming_strings</varname> (<type>boolean</type>)</term>
5664 <indexterm><primary>strings</><secondary>standard conforming</></>
5666 <primary><varname>standard_conforming_strings</> configuration parameter</primary>
5670 This controls whether ordinary string literals
5671 (<literal>'...'</>) treat backslashes literally, as specified in
5673 Beginning in <productname>PostgreSQL</productname> 9.1, the default is
5674 <literal>on</> (prior releases defaulted to <literal>off</>).
5675 Applications can check this
5676 parameter to determine how string literals will be processed.
5677 The presence of this parameter can also be taken as an indication
5678 that the escape string syntax (<literal>E'...'</>) is supported.
5679 Escape string syntax (<xref linkend="sql-syntax-strings-escape">)
5680 should be used if an application desires
5681 backslashes to be treated as escape characters.
5686 <varlistentry id="guc-synchronize-seqscans" xreflabel="synchronize_seqscans">
5687 <term><varname>synchronize_seqscans</varname> (<type>boolean</type>)</term>
5689 <primary><varname>synchronize_seqscans</> configuration parameter</primary>
5693 This allows sequential scans of large tables to synchronize with each
5694 other, so that concurrent scans read the same block at about the
5695 same time and hence share the I/O workload. When this is enabled,
5696 a scan might start in the middle of the table and then <quote>wrap
5697 around</> the end to cover all rows, so as to synchronize with the
5698 activity of scans already in progress. This can result in
5699 unpredictable changes in the row ordering returned by queries that
5700 have no <literal>ORDER BY</> clause. Setting this parameter to
5701 <literal>off</> ensures the pre-8.3 behavior in which a sequential
5702 scan always starts from the beginning of the table. The default
5711 <sect2 id="runtime-config-compatible-clients">
5712 <title>Platform and Client Compatibility</title>
5715 <varlistentry id="guc-transform-null-equals" xreflabel="transform_null_equals">
5716 <term><varname>transform_null_equals</varname> (<type>boolean</type>)</term>
5717 <indexterm><primary>IS NULL</></>
5719 <primary><varname>transform_null_equals</> configuration parameter</primary>
5723 When on, expressions of the form <literal><replaceable>expr</> =
5724 NULL</literal> (or <literal>NULL =
5725 <replaceable>expr</></literal>) are treated as
5726 <literal><replaceable>expr</> IS NULL</literal>, that is, they
5727 return true if <replaceable>expr</> evaluates to the null value,
5728 and false otherwise. The correct SQL-spec-compliant behavior of
5729 <literal><replaceable>expr</> = NULL</literal> is to always
5730 return null (unknown). Therefore this parameter defaults to
5735 However, filtered forms in <productname>Microsoft
5736 Access</productname> generate queries that appear to use
5737 <literal><replaceable>expr</> = NULL</literal> to test for
5738 null values, so if you use that interface to access the database you
5739 might want to turn this option on. Since expressions of the
5740 form <literal><replaceable>expr</> = NULL</literal> always
5741 return the null value (using the SQL standard interpretation), they are not
5742 very useful and do not appear often in normal applications so
5743 this option does little harm in practice. But new users are
5744 frequently confused about the semantics of expressions
5745 involving null values, so this option is off by default.
5749 Note that this option only affects the exact form <literal>= NULL</>,
5750 not other comparison operators or other expressions
5751 that are computationally equivalent to some expression
5752 involving the equals operator (such as <literal>IN</literal>).
5753 Thus, this option is not a general fix for bad programming.
5757 Refer to <xref linkend="functions-comparison"> for related information.
5766 <sect1 id="runtime-config-error-handling">
5767 <title>Error Handling</title>
5771 <varlistentry id="guc-exit-on-error" xreflabel="exit_on_error">
5772 <term><varname>exit_on_error</varname> (<type>boolean</type>)</term>
5774 <primary><varname>exit_on_error</> configuration parameter</primary>
5778 If true, any error will terminate the current session. By default,
5779 this is set to false, so that only FATAL errors will terminate the
5785 <varlistentry id="guc-restart-after-crash" xreflabel="restart_after_crash">
5786 <term><varname>restart_after_crash</varname> (<type>boolean</type>)</term>
5788 <primary><varname>restart_after_crash</> configuration parameter</primary>
5792 When set to true, which is the default, <productname>PostgreSQL</>
5793 will automatically reinitialize after a backend crash. Leaving this
5794 value set to true is normally the best way to maximize the availability
5795 of the database. However, in some circumstances, such as when
5796 <productname>PostgreSQL</> is being invoked by clusterware, it may be
5797 useful to disable the restart so that the clusterware can gain
5798 control and take any actions it deems appropriate.
5807 <sect1 id="runtime-config-preset">
5808 <title>Preset Options</title>
5811 The following <quote>parameters</> are read-only, and are determined
5812 when <productname>PostgreSQL</productname> is compiled or when it is
5813 installed. As such, they have been excluded from the sample
5814 <filename>postgresql.conf</> file. These options report
5815 various aspects of <productname>PostgreSQL</productname> behavior
5816 that might be of interest to certain applications, particularly
5817 administrative front-ends.
5822 <varlistentry id="guc-block-size" xreflabel="block_size">
5823 <term><varname>block_size</varname> (<type>integer</type>)</term>
5825 <primary><varname>block_size</> configuration parameter</primary>
5829 Reports the size of a disk block. It is determined by the value
5830 of <literal>BLCKSZ</> when building the server. The default
5831 value is 8192 bytes. The meaning of some configuration
5832 variables (such as <xref linkend="guc-shared-buffers">) is
5833 influenced by <varname>block_size</varname>. See <xref
5834 linkend="runtime-config-resource"> for information.
5839 <varlistentry id="guc-integer-datetimes" xreflabel="integer_datetimes">
5840 <term><varname>integer_datetimes</varname> (<type>boolean</type>)</term>
5842 <primary><varname>integer_datetimes</> configuration parameter</primary>
5846 Reports whether <productname>PostgreSQL</> was built with
5847 support for 64-bit-integer dates and times. This can be
5848 disabled by configuring with <literal>--disable-integer-datetimes</>
5849 when building <productname>PostgreSQL</>. The default value is
5850 <literal>on</literal>.
5855 <varlistentry id="guc-lc-collate" xreflabel="lc_collate">
5856 <term><varname>lc_collate</varname> (<type>string</type>)</term>
5858 <primary><varname>lc_collate</> configuration parameter</primary>
5862 Reports the locale in which sorting of textual data is done.
5863 See <xref linkend="locale"> for more information.
5864 This value is determined when a database is created.
5869 <varlistentry id="guc-lc-ctype" xreflabel="lc_ctype">
5870 <term><varname>lc_ctype</varname> (<type>string</type>)</term>
5872 <primary><varname>lc_ctype</> configuration parameter</primary>
5876 Reports the locale that determines character classifications.
5877 See <xref linkend="locale"> for more information.
5878 This value is determined when a database is created.
5879 Ordinarily this will be the same as <varname>lc_collate</varname>,
5880 but for special applications it might be set differently.
5885 <varlistentry id="guc-max-function-args" xreflabel="max_function_args">
5886 <term><varname>max_function_args</varname> (<type>integer</type>)</term>
5888 <primary><varname>max_function_args</> configuration parameter</primary>
5892 Reports the maximum number of function arguments. It is determined by
5893 the value of <literal>FUNC_MAX_ARGS</> when building the server. The
5894 default value is 100 arguments.
5899 <varlistentry id="guc-max-identifier-length" xreflabel="max_identifier_length">
5900 <term><varname>max_identifier_length</varname> (<type>integer</type>)</term>
5902 <primary><varname>max_identifier_length</> configuration parameter</primary>
5906 Reports the maximum identifier length. It is determined as one
5907 less than the value of <literal>NAMEDATALEN</> when building
5908 the server. The default value of <literal>NAMEDATALEN</> is
5909 64; therefore the default
5910 <varname>max_identifier_length</varname> is 63 bytes, which
5911 can be less than 63 characters when using multibyte encodings.
5916 <varlistentry id="guc-max-index-keys" xreflabel="max_index_keys">
5917 <term><varname>max_index_keys</varname> (<type>integer</type>)</term>
5919 <primary><varname>max_index_keys</> configuration parameter</primary>
5923 Reports the maximum number of index keys. It is determined by
5924 the value of <literal>INDEX_MAX_KEYS</> when building the server. The
5925 default value is 32 keys.
5930 <varlistentry id="guc-segment-size" xreflabel="segment_size">
5931 <term><varname>segment_size</varname> (<type>integer</type>)</term>
5933 <primary><varname>segment_size</> configuration parameter</primary>
5937 Reports the number of blocks (pages) that can be stored within a file
5938 segment. It is determined by the value of <literal>RELSEG_SIZE</>
5939 when building the server. The maximum size of a segment file in bytes
5940 is equal to <varname>segment_size</> multiplied by
5941 <varname>block_size</>; by default this is 1GB.
5946 <varlistentry id="guc-server-encoding" xreflabel="server_encoding">
5947 <term><varname>server_encoding</varname> (<type>string</type>)</term>
5949 <primary><varname>server_encoding</> configuration parameter</primary>
5951 <indexterm><primary>character set</></>
5954 Reports the database encoding (character set).
5955 It is determined when the database is created. Ordinarily,
5956 clients need only be concerned with the value of <xref
5957 linkend="guc-client-encoding">.
5962 <varlistentry id="guc-server-version" xreflabel="server_version">
5963 <term><varname>server_version</varname> (<type>string</type>)</term>
5965 <primary><varname>server_version</> configuration parameter</primary>
5969 Reports the version number of the server. It is determined by the
5970 value of <literal>PG_VERSION</> when building the server.
5975 <varlistentry id="guc-server-version-num" xreflabel="server_version_num">
5976 <term><varname>server_version_num</varname> (<type>integer</type>)</term>
5978 <primary><varname>server_version_num</> configuration parameter</primary>
5982 Reports the version number of the server as an integer. It is determined
5983 by the value of <literal>PG_VERSION_NUM</> when building the server.
5988 <varlistentry id="guc-wal-block-size" xreflabel="wal_block_size">
5989 <term><varname>wal_block_size</varname> (<type>integer</type>)</term>
5991 <primary><varname>wal_block_size</> configuration parameter</primary>
5995 Reports the size of a WAL disk block. It is determined by the value
5996 of <literal>XLOG_BLCKSZ</> when building the server. The default value
6002 <varlistentry id="guc-wal-segment-size" xreflabel="wal_segment_size">
6003 <term><varname>wal_segment_size</varname> (<type>integer</type>)</term>
6005 <primary><varname>wal_segment_size</> configuration parameter</primary>
6009 Reports the number of blocks (pages) in a WAL segment file.
6010 The total size of a WAL segment file in bytes is equal to
6011 <varname>wal_segment_size</> multiplied by <varname>wal_block_size</>;
6012 by default this is 16MB. See <xref linkend="wal-configuration"> for
6021 <sect1 id="runtime-config-custom">
6022 <title>Customized Options</title>
6025 This feature was designed to allow parameters not normally known to
6026 <productname>PostgreSQL</productname> to be added by add-on modules
6027 (such as procedural languages). This allows extension modules to be
6028 configured in the standard ways.
6032 Custom options have two-part names: an extension name, then a dot, then
6033 the parameter name proper, much like qualified names in SQL. An example
6034 is <literal>plpgsql.variable_conflict</>.
6038 Because custom options may need to be set in processes that have not
6039 loaded the relevant extension module, <productname>PostgreSQL</>
6040 will accept a setting for any two-part parameter name. Such variables
6041 are treated as placeholders and have no function until the module that
6042 defines them is loaded. When an extension module is loaded, it will add
6043 its variable definitions, convert any placeholder values according to
6044 those definitions, and issue warnings for any unrecognized placeholders
6045 that begin with its extension name.
6049 <sect1 id="runtime-config-developer">
6050 <title>Developer Options</title>
6053 The following parameters are intended for work on the
6054 <productname>PostgreSQL</productname> source code, and in some cases
6055 to assist with recovery of severely damaged databases. There
6056 should be no reason to use them on a production database.
6057 As such, they have been excluded from the sample
6058 <filename>postgresql.conf</> file. Note that many of these
6059 parameters require special source compilation flags to work at all.
6063 <varlistentry id="guc-allow-system-table-mods" xreflabel="allow_system_table_mods">
6064 <term><varname>allow_system_table_mods</varname> (<type>boolean</type>)</term>
6066 <primary><varname>allow_system_table_mods</varname> configuration parameter</primary>
6070 Allows modification of the structure of system tables.
6071 This is used by <command>initdb</command>.
6072 This parameter can only be set at server start.
6077 <varlistentry id="guc-debug-assertions" xreflabel="debug_assertions">
6078 <term><varname>debug_assertions</varname> (<type>boolean</type>)</term>
6080 <primary><varname>debug_assertions</> configuration parameter</primary>
6084 Turns on various assertion checks. This is a debugging aid. If
6085 you are experiencing strange problems or crashes you might want
6086 to turn this on, as it might expose programming mistakes. To use
6087 this parameter, the macro <symbol>USE_ASSERT_CHECKING</symbol>
6088 must be defined when <productname>PostgreSQL</productname> is
6089 built (accomplished by the <command>configure</command> option
6090 <option>--enable-cassert</option>). Note that
6091 <varname>debug_assertions</varname> defaults to <literal>on</>
6092 if <productname>PostgreSQL</productname> has been built with
6098 <varlistentry id="guc-ignore-system-indexes" xreflabel="ignore_system_indexes">
6099 <term><varname>ignore_system_indexes</varname> (<type>boolean</type>)</term>
6101 <primary><varname>ignore_system_indexes</varname> configuration parameter</primary>
6105 Ignore system indexes when reading system tables (but still
6106 update the indexes when modifying the tables). This is useful
6107 when recovering from damaged system indexes.
6108 This parameter cannot be changed after session start.
6113 <varlistentry id="guc-post-auth-delay" xreflabel="post_auth_delay">
6114 <term><varname>post_auth_delay</varname> (<type>integer</type>)</term>
6116 <primary><varname>post_auth_delay</> configuration parameter</primary>
6120 If nonzero, a delay of this many seconds occurs when a new
6121 server process is started, after it conducts the
6122 authentication procedure. This is intended to give developers an
6123 opportunity to attach to the server process with a debugger.
6124 This parameter cannot be changed after session start.
6129 <varlistentry id="guc-pre-auth-delay" xreflabel="pre_auth_delay">
6130 <term><varname>pre_auth_delay</varname> (<type>integer</type>)</term>
6132 <primary><varname>pre_auth_delay</> configuration parameter</primary>
6136 If nonzero, a delay of this many seconds occurs just after a
6137 new server process is forked, before it conducts the
6138 authentication procedure. This is intended to give developers an
6139 opportunity to attach to the server process with a debugger to
6140 trace down misbehavior in authentication.
6141 This parameter can only be set in the <filename>postgresql.conf</>
6142 file or on the server command line.
6147 <varlistentry id="guc-trace-notify" xreflabel="trace_notify">
6148 <term><varname>trace_notify</varname> (<type>boolean</type>)</term>
6150 <primary><varname>trace_notify</> configuration parameter</primary>
6154 Generates a great amount of debugging output for the
6155 <command>LISTEN</command> and <command>NOTIFY</command>
6156 commands. <xref linkend="guc-client-min-messages"> or
6157 <xref linkend="guc-log-min-messages"> must be
6158 <literal>DEBUG1</literal> or lower to send this output to the
6159 client or server logs, respectively.
6164 <varlistentry id="guc-trace-recovery-messages" xreflabel="trace_recovery_messages">
6165 <term><varname>trace_recovery_messages</varname> (<type>enum</type>)</term>
6167 <primary><varname>trace_recovery_messages</> configuration parameter</primary>
6171 Enables logging of recovery-related debugging output that otherwise
6172 would not be logged. This parameter allows the user to override the
6173 normal setting of <xref linkend="guc-log-min-messages">, but only for
6174 specific messages. This is intended for use in debugging Hot Standby.
6175 Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
6176 <literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>, and
6177 <literal>LOG</>. The default, <literal>LOG</>, does not affect
6178 logging decisions at all. The other values cause recovery-related
6179 debug messages of that priority or higher to be logged as though they
6180 had <literal>LOG</> priority; for common settings of
6181 <varname>log_min_messages</> this results in unconditionally sending
6182 them to the server log.
6183 This parameter can only be set in the <filename>postgresql.conf</>
6184 file or on the server command line.
6189 <varlistentry id="guc-trace-sort" xreflabel="trace_sort">
6190 <term><varname>trace_sort</varname> (<type>boolean</type>)</term>
6192 <primary><varname>trace_sort</> configuration parameter</primary>
6196 If on, emit information about resource usage during sort operations.
6197 This parameter is only available if the <symbol>TRACE_SORT</symbol> macro
6198 was defined when <productname>PostgreSQL</productname> was compiled.
6199 (However, <symbol>TRACE_SORT</symbol> is currently defined by default.)
6205 <term><varname>trace_locks</varname> (<type>boolean</type>)</term>
6207 <primary><varname>trace_locks</> configuration parameter</primary>
6211 If on, emit information about lock usage. Information dumped
6212 includes the type of lock operation, the type of lock and the unique
6213 identifier of the object being locked or unlocked. Also included
6214 are bit masks for the lock types already granted on this object as
6215 well as for the lock types awaited on this object. For each lock
6216 type a count of the number of granted locks and waiting locks is
6217 also dumped as well as the totals. An example of the log file output
6220 LOG: LockAcquire: new: lock(0xb7acd844) id(24688,24696,0,0,0,1)
6221 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
6222 wait(0) type(AccessShareLock)
6223 LOG: GrantLock: lock(0xb7acd844) id(24688,24696,0,0,0,1)
6224 grantMask(2) req(1,0,0,0,0,0,0)=1 grant(1,0,0,0,0,0,0)=1
6225 wait(0) type(AccessShareLock)
6226 LOG: UnGrantLock: updated: lock(0xb7acd844) id(24688,24696,0,0,0,1)
6227 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
6228 wait(0) type(AccessShareLock)
6229 LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
6230 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
6231 wait(0) type(INVALID)
6233 Details of the structure being dumped may be found in
6234 <filename>src/include/storage/lock.h</filename>.
6237 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6238 macro was defined when <productname>PostgreSQL</productname> was
6245 <term><varname>trace_lwlocks</varname> (<type>boolean</type>)</term>
6247 <primary><varname>trace_lwlocks</> configuration parameter</primary>
6251 If on, emit information about lightweight lock usage. Lightweight
6252 locks are intended primarily to provide mutual exclusion of access
6253 to shared-memory data structures.
6256 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6257 macro was defined when <productname>PostgreSQL</productname> was
6264 <term><varname>trace_userlocks</varname> (<type>boolean</type>)</term>
6266 <primary><varname>trace_userlocks</> configuration parameter</primary>
6270 If on, emit information about user lock usage. Output is the same
6271 as for <symbol>trace_locks</symbol>, only for advisory locks.
6274 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6275 macro was defined when <productname>PostgreSQL</productname> was
6282 <term><varname>trace_lock_oidmin</varname> (<type>integer</type>)</term>
6284 <primary><varname>trace_lock_oidmin</> configuration parameter</primary>
6288 If set, do not trace locks for tables below this OID. (use to avoid
6289 output on system tables)
6292 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6293 macro was defined when <productname>PostgreSQL</productname> was
6300 <term><varname>trace_lock_table</varname> (<type>integer</type>)</term>
6302 <primary><varname>trace_lock_table</> configuration parameter</primary>
6306 Unconditionally trace locks on this table (OID).
6309 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6310 macro was defined when <productname>PostgreSQL</productname> was
6317 <term><varname>debug_deadlocks</varname> (<type>boolean</type>)</term>
6319 <primary><varname>debug_deadlocks</> configuration parameter</primary>
6323 If set, dumps information about all current locks when a
6324 deadlock timeout occurs.
6327 This parameter is only available if the <symbol>LOCK_DEBUG</symbol>
6328 macro was defined when <productname>PostgreSQL</productname> was
6335 <term><varname>log_btree_build_stats</varname> (<type>boolean</type>)</term>
6337 <primary><varname>log_btree_build_stats</> configuration parameter</primary>
6341 If set, logs system resource usage statistics (memory and CPU) on
6342 various B-tree operations.
6345 This parameter is only available if the <symbol>BTREE_BUILD_STATS</symbol>
6346 macro was defined when <productname>PostgreSQL</productname> was
6352 <varlistentry id="guc-wal-debug" xreflabel="wal_debug">
6353 <term><varname>wal_debug</varname> (<type>boolean</type>)</term>
6355 <primary><varname>wal_debug</> configuration parameter</primary>
6359 If on, emit WAL-related debugging output. This parameter is
6360 only available if the <symbol>WAL_DEBUG</symbol> macro was
6361 defined when <productname>PostgreSQL</productname> was
6367 <varlistentry id="guc-zero-damaged-pages" xreflabel="zero_damaged_pages">
6368 <term><varname>zero_damaged_pages</varname> (<type>boolean</type>)</term>
6370 <primary><varname>zero_damaged_pages</> configuration parameter</primary>
6374 Detection of a damaged page header normally causes
6375 <productname>PostgreSQL</> to report an error, aborting the current
6376 transaction. Setting <varname>zero_damaged_pages</> to on causes
6377 the system to instead report a warning, zero out the damaged
6378 page in memory, and continue processing. This behavior <emphasis>will destroy data</>,
6379 namely all the rows on the damaged page. However, it does allow you to get
6380 past the error and retrieve rows from any undamaged pages that might
6381 be present in the table. It is useful for recovering data if
6382 corruption has occurred due to a hardware or software error. You should
6383 generally not set this on until you have given up hope of recovering
6384 data from the damaged pages of a table. Zeroed-out pages are not
6385 forced to disk so it is recommended to recreate the table or
6386 the index before turning this parameter off again. The
6387 default setting is <literal>off</>, and it can only be changed
6394 <sect1 id="runtime-config-short">
6395 <title>Short Options</title>
6398 For convenience there are also single letter command-line option
6399 switches available for some parameters. They are described in
6400 <xref linkend="runtime-config-short-table">. Some of these
6401 options exist for historical reasons, and their presence as a
6402 single-letter option does not necessarily indicate an endorsement
6403 to use the option heavily.
6406 <table id="runtime-config-short-table">
6407 <title>Short Option Key</title>
6411 <entry>Short Option</entry>
6412 <entry>Equivalent</entry>
6418 <entry><option>-A <replaceable>x</replaceable></option></entry>
6419 <entry><literal>debug_assertions = <replaceable>x</replaceable></></entry>
6422 <entry><option>-B <replaceable>x</replaceable></option></entry>
6423 <entry><literal>shared_buffers = <replaceable>x</replaceable></></entry>
6426 <entry><option>-d <replaceable>x</replaceable></option></entry>
6427 <entry><literal>log_min_messages = DEBUG<replaceable>x</replaceable></></entry>
6430 <entry><option>-e</option></entry>
6431 <entry><literal>datestyle = euro</></entry>
6435 <option>-fb</option>, <option>-fh</option>, <option>-fi</option>,
6436 <option>-fm</option>, <option>-fn</option>, <option>-fo</option>,
6437 <option>-fs</option>, <option>-ft</option>
6440 <literal>enable_bitmapscan = off</>,
6441 <literal>enable_hashjoin = off</>,
6442 <literal>enable_indexscan = off</>,
6443 <literal>enable_mergejoin = off</>,
6444 <literal>enable_nestloop = off</>,
6445 <literal>enable_indexonlyscan = off</>,
6446 <literal>enable_seqscan = off</>,
6447 <literal>enable_tidscan = off</>
6451 <entry><option>-F</option></entry>
6452 <entry><literal>fsync = off</></entry>
6455 <entry><option>-h <replaceable>x</replaceable></option></entry>
6456 <entry><literal>listen_addresses = <replaceable>x</replaceable></></entry>
6459 <entry><option>-i</option></entry>
6460 <entry><literal>listen_addresses = '*'</></entry>
6463 <entry><option>-k <replaceable>x</replaceable></option></entry>
6464 <entry><literal>unix_socket_directory = <replaceable>x</replaceable></></entry>
6467 <entry><option>-l</option></entry>
6468 <entry><literal>ssl = on</></entry>
6471 <entry><option>-N <replaceable>x</replaceable></option></entry>
6472 <entry><literal>max_connections = <replaceable>x</replaceable></></entry>
6475 <entry><option>-O</option></entry>
6476 <entry><literal>allow_system_table_mods = on</></entry>
6479 <entry><option>-p <replaceable>x</replaceable></option></entry>
6480 <entry><literal>port = <replaceable>x</replaceable></></entry>
6483 <entry><option>-P</option></entry>
6484 <entry><literal>ignore_system_indexes = on</></entry>
6487 <entry><option>-s</option></entry>
6488 <entry><literal>log_statement_stats = on</></entry>
6491 <entry><option>-S <replaceable>x</replaceable></option></entry>
6492 <entry><literal>work_mem = <replaceable>x</replaceable></></entry>
6495 <entry><option>-tpa</option>, <option>-tpl</option>, <option>-te</option></entry>
6496 <entry><literal>log_parser_stats = on</>,
6497 <literal>log_planner_stats = on</>,
6498 <literal>log_executor_stats = on</></entry>
6501 <entry><option>-W <replaceable>x</replaceable></option></entry>
6502 <entry><literal>post_auth_delay = <replaceable>x</replaceable></></entry>