Server Configurationconfigurationof the server
There are many configuration parameters that affect the behavior of
the database system. In the first section of this chapter we
describe how to interact with configuration parameters. The subsequent sections
discuss each parameter in detail.
Setting ParametersParameter Names and Values
All parameter names are case-insensitive. Every parameter takes a
value of one of five types: boolean, string, integer, floating point,
or enumerated (enum). The type determines the syntax for setting the
parameter:
Boolean:
Values can be written as
on,
off,
true,
false,
yes,
no,
1,
0
(all case-insensitive) or any unambiguous prefix of one of these.
String:
In general, enclose the value in single quotes, doubling any single
quotes within the value. Quotes can usually be omitted if the value
is a simple number or identifier, however.
Numeric (integer and floating point):
A decimal point is permitted only for floating-point parameters.
Do not use thousands separators. Quotes are not required.
Numeric with Unit:
Some numeric parameters have an implicit unit, because they describe
quantities of memory or time. The unit might be kilobytes, blocks
(typically eight kilobytes), milliseconds, seconds, or minutes.
An unadorned numeric value for one of these settings will use the
setting's default unit, which can be learned from
pg_settings>.unit>.
For convenience, settings can be given with a unit specified explicitly,
for example '120 ms'> for a time value, and they will be
converted to whatever the parameter's actual unit is. Note that the
value must be written as a string (with quotes) to use this feature.
The unit name is case-sensitive, and there can be whitespace between
the numeric value and the unit.
Valid memory units are kB (kilobytes),
MB (megabytes), GB
(gigabytes), and TB (terabytes).
The multiplier for memory units is 1024, not 1000.
Valid time units are ms (milliseconds),
s (seconds), min (minutes),
h (hours), and d (days).
Enumerated:
Enumerated-type parameters are written in the same way as string
parameters, but are restricted to have one of a limited set of
values. The values allowable for such a parameter can be found from
pg_settings>.enumvals>.
Enum parameter values are case-insensitive.
Parameter Interaction via the Configuration File
The most fundamental way to set these parameters is to edit the file
postgresql.conf>postgresql.conf>>,
which is normally kept in the data directory. A default copy is
installed when the database cluster directory is initialized.
An example of what this file might look like is:
# This is a comment
log_connections = yes
log_destination = 'syslog'
search_path = '"$user", public'
shared_buffers = 128MB
One parameter is specified per line. The equal sign between name and
value is optional. Whitespace is insignificant (except within a quoted
parameter value) and blank lines are
ignored. Hash marks (#) designate the remainder
of the line as a comment. Parameter values that are not simple
identifiers or numbers must be single-quoted. To embed a single
quote in a parameter value, write either two quotes (preferred)
or backslash-quote.
Parameters set in this way provide default values for the cluster.
The settings seen by active sessions will be these values unless they
are overridden. The following sections describe ways in which the
administrator or user can override these defaults.
SIGHUP
The configuration file is reread whenever the main server process
receives a SIGHUP> signal; this signal is most easily
sent by running pg_ctl reload> from the command line or by
calling the SQL function pg_reload_conf(). The main
server process also propagates this signal to all currently running
server processes, so that existing sessions also adopt the new values
(this will happen after they complete any currently-executing client
command). Alternatively, you can
send the signal to a single server process directly. Some parameters
can only be set at server start; any changes to their entries in the
configuration file will be ignored until the server is restarted.
Invalid parameter settings in the configuration file are likewise
ignored (but logged) during SIGHUP> processing.
In addition to postgresql.conf>,
a PostgreSQL data directory contains a file
postgresql.auto.conf>postgresql.auto.conf>>,
which has the same format as postgresql.conf> but should
never be edited manually. This file holds settings provided through
the command. This file is automatically
read whenever postgresql.conf> is, and its settings take
effect in the same way. Settings in postgresql.auto.conf>
override those in postgresql.conf>.
The system view
pg_file_settings
can be helpful for pre-testing changes to the configuration file, or for
diagnosing problems if a SIGHUP> signal did not have the
desired effects.
Parameter Interaction via SQLPostgreSQL provides three SQL
commands to establish configuration defaults.
The already-mentioned command
provides a SQL-accessible means of changing global defaults; it is
functionally equivalent to editing postgresql.conf>.
In addition, there are two commands that allow setting of defaults
on a per-database or per-role basis:
The command allows global
settings to be overridden on a per-database basis.
The command allows both global and
per-database settings to be overridden with user-specific values.
Values set with ALTER DATABASE> and ALTER ROLE>
are applied only when starting a fresh database session. They
override values obtained from the configuration files or server
command line, and constitute defaults for the rest of the session.
Note that some settings cannot be changed after server start, and
so cannot be set with these commands (or the ones listed below).
Once a client is connected to the database, PostgreSQL>
provides two additional SQL commands (and equivalent functions) to
interact with session-local configuration settings:
The command allows inspection of the
current value of all parameters. The corresponding function is
current_setting(setting_name text).
The command allows modification of the
current value of those parameters that can be set locally to a
session; it has no effect on other sessions.
The corresponding function is
set_config(setting_name, new_value, is_local).
In addition, the system view pg_settings>> can be
used to view and change session-local values:
Querying this view is similar to using SHOW ALL> but
provides more detail. It is also more flexible, since it's possible
to specify filter conditions or join against other relations.
Using on this view, specifically
updating the setting> column, is the equivalent
of issuing SET> commands. For example, the equivalent of
SET configuration_parameter TO DEFAULT;
is:
UPDATE pg_settings SET setting = reset_val WHERE name = 'configuration_parameter';
Parameter Interaction via the Shell
In addition to setting global defaults or attaching
overrides at the database or role level, you can pass settings to
PostgreSQL via shell facilities.
Both the server and libpq> client library
accept parameter values via the shell.
During server startup, parameter settings can be
passed to the postgres command via the
When starting a client session via libpq>,
parameter settings can be
specified using the PGOPTIONS environment variable.
Settings established in this way constitute defaults for the life
of the session, but do not affect other sessions.
For historical reasons, the format of PGOPTIONS is
similar to that used when launching the postgres
command; specifically, the
Other clients and libraries might provide their own mechanisms,
via the shell or otherwise, that allow the user to alter session
settings without direct use of SQL commands.
Managing Configuration File ContentsPostgreSQL> provides several features for breaking
down complex postgresql.conf> files into sub-files.
These features are especially useful when managing multiple servers
with related, but not identical, configurations.
include>in configuration file
In addition to individual parameter settings,
the postgresql.conf> file can contain include
directives>, which specify another file to read and process as if
it were inserted into the configuration file at this point. This
feature allows a configuration file to be divided into physically
separate parts. Include directives simply look like:
include 'filename'
If the file name is not an absolute path, it is taken as relative to
the directory containing the referencing configuration file.
Inclusions can be nested.
include_if_exists>in configuration file
There is also an include_if_exists> directive, which acts
the same as the include> directive, except
when the referenced file does not exist or cannot be read. A regular
include> will consider this an error condition, but
include_if_exists> merely logs a message and continues
processing the referencing configuration file.
include_dir>in configuration file
The postgresql.conf> file can also contain
include_dir directives, which specify an entire
directory of configuration files to include. These look like
include_dir 'directory'
Non-absolute directory names are taken as relative to the directory
containing the referencing configuration file. Within the specified
directory, only non-directory files whose names end with the
suffix .conf will be included. File names that
start with the . character are also ignored, to
prevent mistakes since such files are hidden on some platforms. Multiple
files within an include directory are processed in file name order
(according to C locale rules, i.e. numbers before letters, and
uppercase letters before lowercase ones).
Include files or directories can be used to logically separate portions
of the database configuration, rather than having a single large
postgresql.conf> file. Consider a company that has two
database servers, each with a different amount of memory. There are
likely elements of the configuration both will share, for things such
as logging. But memory-related parameters on the server will vary
between the two. And there might be server specific customizations,
too. One way to manage this situation is to break the custom
configuration changes for your site into three files. You could add
this to the end of your postgresql.conf> file to include
them:
include 'shared.conf'
include 'memory.conf'
include 'server.conf'
All systems would have the same shared.conf>. Each
server with a particular amount of memory could share the
same memory.conf>; you might have one for all servers
with 8GB of RAM, another for those having 16GB. And
finally server.conf> could have truly server-specific
configuration information in it.
Another possibility is to create a configuration file directory and
put this information into files there. For example, a conf.d>
directory could be referenced at the end of postgresql.conf>:
include_dir 'conf.d'
Then you could name the files in the conf.d> directory
like this:
00shared.conf
01memory.conf
02server.conf
This naming convention establishes a clear order in which these
files will be loaded. This is important because only the last
setting encountered for a particular parameter while the server is
reading configuration files will be used. In this example,
something set in conf.d/02server.conf> would override a
value set in conf.d/01memory.conf>.
You might instead use this approach to naming the files
descriptively:
00shared.conf
01memory-8GB.conf
02server-foo.conf
This sort of arrangement gives a unique name for each configuration file
variation. This can help eliminate ambiguity when several servers have
their configurations all stored in one place, such as in a version
control repository. (Storing database configuration files under version
control is another good practice to consider.)
File Locations
In addition to the postgresql.conf file
already mentioned, PostgreSQL uses
two other manually-edited configuration files, which control
client authentication (their use is discussed in ). By default, all three
configuration files are stored in the database cluster's data
directory. The parameters described in this section allow the
configuration files to be placed elsewhere. (Doing so can ease
administration. In particular it is often easier to ensure that
the configuration files are properly backed-up when they are
kept separate.)
data_directory (string)
data_directory> configuration parameter
Specifies the directory to use for data storage.
This parameter can only be set at server start.
config_file (string)
config_file> configuration parameter
Specifies the main server configuration file
(customarily called postgresql.conf>).
This parameter can only be set on the postgres command line.
hba_file (string)
hba_file> configuration parameter
Specifies the configuration file for host-based authentication
(customarily called pg_hba.conf>).
This parameter can only be set at server start.
ident_file (string)
ident_file> configuration parameter
Specifies the configuration file for
user name mapping
(customarily called pg_ident.conf>).
This parameter can only be set at server start.
external_pid_file (string)
external_pid_file> configuration parameter
Specifies the name of an additional process-ID (PID) file that the
server should create for use by server administration programs.
This parameter can only be set at server start.
In a default installation, none of the above parameters are set
explicitly. Instead, the
data directory is specified by the command-line
option or the PGDATA environment variable, and the
configuration files are all found within the data directory.
If you wish to keep the configuration files elsewhere than the
data directory, the postgres
command-line option or PGDATA environment variable
must point to the directory containing the configuration files,
and the data_directory> parameter must be set in
postgresql.conf (or on the command line) to show
where the data directory is actually located. Notice that
data_directory> overrides and
PGDATA for the location
of the data directory, but not for the location of the configuration
files.
If you wish, you can specify the configuration file names and locations
individually using the parameters config_file>,
hba_file> and/or ident_file>.
config_file> can only be specified on the
postgres command line, but the others can be
set within the main configuration file. If all three parameters plus
data_directory> are explicitly set, then it is not necessary
to specify or PGDATA.
When setting any of these parameters, a relative path will be interpreted
with respect to the directory in which postgres
is started.
Connections and AuthenticationConnection Settingslisten_addresses (string)
listen_addresses> configuration parameter
Specifies the TCP/IP address(es) on which the server is
to listen for connections from client applications.
The value takes the form of a comma-separated list of host names
and/or numeric IP addresses. The special entry *>
corresponds to all available IP interfaces. The entry
0.0.0.0> allows listening for all IPv4 addresses and
::> allows listening for all IPv6 addresses.
If the list is empty, the server does not listen on any IP interface
at all, in which case only Unix-domain sockets can be used to connect
to it.
The default value is localhost>,
which allows only local TCP/IP loopback> connections to be
made. While client authentication () allows fine-grained control
over who can access the server, listen_addresses
controls which interfaces accept connection attempts, which
can help prevent repeated malicious connection requests on
insecure network interfaces. This parameter can only be set
at server start.
port (integer)
port> configuration parameter
The TCP port the server listens on; 5432 by default. Note that the
same port number is used for all IP addresses the server listens on.
This parameter can only be set at server start.
max_connections (integer)
max_connections> configuration parameter
Determines the maximum number of concurrent connections to the
database server. The default is typically 100 connections, but
might be less if your kernel settings will not support it (as
determined during initdb>). This parameter can
only be set at server start.
When running a standby server, you must set this parameter to the
same or higher value than on the master server. Otherwise, queries
will not be allowed in the standby server.
superuser_reserved_connections
(integer)
superuser_reserved_connections> configuration parameter
Determines the number of connection slots that
are reserved for connections by PostgreSQL>
superusers. At most
connections can ever be active simultaneously. Whenever the
number of active concurrent connections is at least
max_connections> minus
superuser_reserved_connections, new
connections will be accepted only for superusers, and no
new replication connections will be accepted.
The default value is three connections. The value must be less
than the value of max_connections. This
parameter can only be set at server start.
unix_socket_directories (string)
unix_socket_directories> configuration parameter
Specifies the directory of the Unix-domain socket(s) on which the
server is to listen for connections from client applications.
Multiple sockets can be created by listing multiple directories
separated by commas. Whitespace between entries is
ignored; surround a directory name with double quotes if you need
to include whitespace or commas in the name.
An empty value
specifies not listening on any Unix-domain sockets, in which case
only TCP/IP sockets can be used to connect to the server.
The default value is normally
/tmp, but that can be changed at build time.
This parameter can only be set at server start.
In addition to the socket file itself, which is named
.s.PGSQL.nnnn> where
nnnn> is the server's port number, an ordinary file
named .s.PGSQL.nnnn>.lock will be
created in each of the unix_socket_directories> directories.
Neither file should ever be removed manually.
This parameter is irrelevant on Windows, which does not have
Unix-domain sockets.
unix_socket_group (string)
unix_socket_group> configuration parameter
Sets the owning group of the Unix-domain socket(s). (The owning
user of the sockets is always the user that starts the
server.) In combination with the parameter
unix_socket_permissions this can be used as
an additional access control mechanism for Unix-domain connections.
By default this is the empty string, which uses the default
group of the server user. This parameter can only be set at
server start.
This parameter is irrelevant on Windows, which does not have
Unix-domain sockets.
unix_socket_permissions (integer)
unix_socket_permissions> configuration parameter
Sets the access permissions of the Unix-domain socket(s). Unix-domain
sockets use the usual Unix file system permission set.
The parameter value is expected to be a numeric mode
specified in the format accepted by the
chmod and umask
system calls. (To use the customary octal format the number
must start with a 0 (zero).)
The default permissions are 0777, meaning
anyone can connect. Reasonable alternatives are
0770 (only user and group, see also
unix_socket_group) and 0700
(only user). (Note that for a Unix-domain socket, only write
permission matters, so there is no point in setting or revoking
read or execute permissions.)
This access control mechanism is independent of the one
described in .
This parameter can only be set at server start.
This parameter is irrelevant on systems, notably Solaris as of Solaris
10, that ignore socket permissions entirely. There, one can achieve a
similar effect by pointing unix_socket_directories> to a
directory having search permission limited to the desired audience.
This parameter is also irrelevant on Windows, which does not have
Unix-domain sockets.
bonjour (boolean)
bonjour> configuration parameter
Enables advertising the server's existence via
Bonjour. The default is off.
This parameter can only be set at server start.
bonjour_name (string)
bonjour_name> configuration parameter
Specifies the Bonjour service
name. The computer name is used if this parameter is set to the
empty string ''> (which is the default). This parameter is
ignored if the server was not compiled with
Bonjour support.
This parameter can only be set at server start.
tcp_keepalives_idle (integer)
tcp_keepalives_idle> configuration parameter
Specifies the number of seconds of inactivity after which TCP
should send a keepalive message to the client. A value of 0 uses
the system default.
This parameter is supported only on systems that support the
TCP_KEEPIDLE> or TCP_KEEPALIVE> symbols, and on
Windows; on other systems, it must be zero.
In sessions connected via a Unix-domain socket, this parameter is
ignored and always reads as zero.
On Windows, a value of 0 will set this parameter to 2 hours,
since Windows does not provide a way to read the system default value.
tcp_keepalives_interval (integer)
tcp_keepalives_interval> configuration parameter
Specifies the number of seconds after which a TCP keepalive message
that is not acknowledged by the client should be retransmitted.
A value of 0 uses the system default.
This parameter is supported only on systems that support the
TCP_KEEPINTVL> symbol, and on Windows; on other systems, it
must be zero.
In sessions connected via a Unix-domain socket, this parameter is
ignored and always reads as zero.
On Windows, a value of 0 will set this parameter to 1 second,
since Windows does not provide a way to read the system default value.
tcp_keepalives_count (integer)
tcp_keepalives_count> configuration parameter
Specifies the number of TCP keepalives that can be lost before
the server's connection to the client is considered dead. A value of 0
uses the system default. This parameter is
supported only on systems that support the TCP_KEEPCNT>
symbol; on other systems, it must be zero.
In sessions connected via a Unix-domain socket, this parameter is
ignored and always reads as zero.
This parameter is not supported on Windows, and must be zero.
Security and Authenticationauthentication_timeout (integer)
timeout>client authentication>client authentication>timeout during>authentication_timeout> configuration parameter
Maximum time to complete client authentication, in seconds. If a
would-be client has not completed the authentication protocol in
this much time, the server closes the connection. This prevents
hung clients from occupying a connection indefinitely.
The default is one minute (1m>).
This parameter can only be set in the postgresql.conf>
file or on the server command line.
ssl (boolean)
ssl> configuration parameter
Enables SSL> connections. Please read
before using this. The default
is off>. This parameter can only be set at server
start. SSL> communication is only possible with
TCP/IP connections.
ssl_ca_file (string)
ssl_ca_file> configuration parameter
Specifies the name of the file containing the SSL server certificate
authority (CA). The default is empty, meaning no CA file is loaded,
and client certificate verification is not performed. (In previous
releases of PostgreSQL, the name of this file was hard-coded
as root.crt.) Relative paths are relative to the
data directory. This parameter can only be set at server start.
ssl_cert_file (string)
ssl_cert_file> configuration parameter
Specifies the name of the file containing the SSL server certificate.
The default is server.crt. Relative paths are
relative to the data directory. This parameter can only be set at
server start.
ssl_crl_file (string)
ssl_crl_file> configuration parameter
Specifies the name of the file containing the SSL server certificate
revocation list (CRL). The default is empty, meaning no CRL file is
loaded. (In previous releases of PostgreSQL, the name of this file was
hard-coded as root.crl.) Relative paths are
relative to the data directory. This parameter can only be set at
server start.
ssl_key_file (string)
ssl_key_file> configuration parameter
Specifies the name of the file containing the SSL server private key.
The default is server.key. Relative paths are
relative to the data directory. This parameter can only be set at
server start.
ssl_ciphers (string)
ssl_ciphers> configuration parameter
Specifies a list of SSL> cipher suites that are allowed to be
used on secure connections. See
the ciphers> manual page
in the OpenSSL> package for the syntax of this setting
and a list of supported values. The default value is
HIGH:MEDIUM:+3DES:!aNULL>. It is usually reasonable,
unless you have specific security requirements.
Explanation of the default value:
HIGH
Cipher suites that use ciphers from HIGH> group (e.g.,
AES, Camellia, 3DES)
MEDIUM
Cipher suites that use ciphers from MEDIUM> group
(e.g., RC4, SEED)
+3DES
The OpenSSL default order for HIGH> is problematic
because it orders 3DES higher than AES128. This is wrong because
3DES offers less security than AES128, and it is also much
slower. +3DES> reorders it after all other
HIGH> and MEDIUM> ciphers.
!aNULL
Disables anonymous cipher suites that do no authentication. Such
cipher suites are vulnerable to man-in-the-middle attacks and
therefore should not be used.
Available cipher suite details will vary across OpenSSL versions. Use
the command
openssl ciphers -v 'HIGH:MEDIUM:+3DES:!aNULL' to
see actual details for the currently installed OpenSSL>
version. Note that this list is filtered at run time based on the
server key type.
ssl_prefer_server_ciphers (bool)
ssl_prefer_server_ciphers> configuration parameter
Specifies whether to use the server's SSL cipher preferences, rather
than the client's. The default is true.
Older PostgreSQL versions do not have this setting and always use the
client's preferences. This setting is mainly for backward
compatibility with those versions. Using the server's preferences is
usually better because it is more likely that the server is appropriately
configured.
ssl_ecdh_curve (string)
ssl_ecdh_curve> configuration parameter
Specifies the name of the curve to use in ECDH> key
exchange. It needs to be supported by all clients that connect.
It does not need to be same curve as used by server's Elliptic
Curve key. The default is prime256v1>.
OpenSSL names for most common curves:
prime256v1> (NIST P-256),
secp384r1> (NIST P-384),
secp521r1> (NIST P-521).
The full list of available curves can be shown with the command
openssl ecparam -list_curves. Not all of them
are usable in TLS> though.
password_encryption (boolean)
password_encryption> configuration parameter
When a password is specified in or
without writing either ENCRYPTED> or
UNENCRYPTED>, this parameter determines whether the
password is to be encrypted. The default is on>
(encrypt the password).
krb_server_keyfile (string)
krb_server_keyfile> configuration parameter
Sets the location of the Kerberos server key file. See
for details. This parameter can only be set in the
postgresql.conf> file or on the server command line.
krb_caseins_users (boolean)
krb_caseins_users configuration parameter
Sets whether GSSAPI user names should be treated
case-insensitively.
The default is off> (case sensitive). This parameter can only be
set in the postgresql.conf> file or on the server command line.
db_user_namespace (boolean)
db_user_namespace> configuration parameter
This parameter enables per-database user names. It is off by default.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
If this is on, you should create users as username@dbname>.
When username> is passed by a connecting client,
@> and the database name are appended to the user
name and that database-specific user name is looked up by the
server. Note that when you create users with names containing
@> within the SQL environment, you will need to
quote the user name.
With this parameter enabled, you can still create ordinary global
users. Simply append @> when specifying the user
name in the client, e.g. joe@>. The @>
will be stripped off before the user name is looked up by the
server.
db_user_namespace> causes the client's and
server's user name representation to differ.
Authentication checks are always done with the server's user name
so authentication methods must be configured for the
server's user name, not the client's. Because
md5> uses the user name as salt on both the
client and server, md5> cannot be used with
db_user_namespace>.
This feature is intended as a temporary measure until a
complete solution is found. At that time, this option will
be removed.
Resource ConsumptionMemoryshared_buffers (integer)
shared_buffers> configuration parameter
Sets the amount of memory the database server uses for shared
memory buffers. The default is typically 128 megabytes
(128MB>), but might be less if your kernel settings will
not support it (as determined during initdb>).
This setting must be at least 128 kilobytes. (Non-default
values of BLCKSZ change the minimum.) However,
settings significantly higher than the minimum are usually needed
for good performance. This parameter can only be set at server start.
If you have a dedicated database server with 1GB or more of RAM, a
reasonable starting value for shared_buffers is 25%
of the memory in your system. There are some workloads where even
large settings for shared_buffers are effective, but
because PostgreSQL also relies on the
operating system cache, it is unlikely that an allocation of more than
40% of RAM to shared_buffers will work better than a
smaller amount. Larger settings for shared_buffers
usually require a corresponding increase in
max_wal_size, in order to spread out the
process of writing large quantities of new or changed data over a
longer period of time.
On systems with less than 1GB of RAM, a smaller percentage of RAM is
appropriate, so as to leave adequate space for the operating system.
Also, on Windows, large values for shared_buffers
aren't as effective. You may find better results keeping the setting
relatively low and using the operating system cache more instead. The
useful range for shared_buffers on Windows systems
is generally from 64MB to 512MB.
huge_pages (enum)
huge_pages> configuration parameter
Enables/disables the use of huge memory pages. Valid values are
try (the default), on,
and off.
At present, this feature is supported only on Linux. The setting is
ignored on other systems when set to try.
The use of huge pages results in smaller page tables and less CPU time
spent on memory management, increasing performance. For more details,
see .
With huge_pages set to try,
the server will try to use huge pages, but fall back to using
normal allocation if that fails. With on, failure
to use huge pages will prevent the server from starting up. With
off, huge pages will not be used.
temp_buffers (integer)
temp_buffers> configuration parameter
Sets the maximum number of temporary buffers used by each database
session. These are session-local buffers used only for access to
temporary tables. The default is eight megabytes
(8MB>). The setting can be changed within individual
sessions, but only before the first use of temporary tables
within the session; subsequent attempts to change the value will
have no effect on that session.
A session will allocate temporary buffers as needed up to the limit
given by temp_buffers>. The cost of setting a large
value in sessions that do not actually need many temporary
buffers is only a buffer descriptor, or about 64 bytes, per
increment in temp_buffers>. However if a buffer is
actually used an additional 8192 bytes will be consumed for it
(or in general, BLCKSZ bytes).
max_prepared_transactions (integer)
max_prepared_transactions> configuration parameter
Sets the maximum number of transactions that can be in the
prepared> state simultaneously (see ).
Setting this parameter to zero (which is the default)
disables the prepared-transaction feature.
This parameter can only be set at server start.
If you are not planning to use prepared transactions, this parameter
should be set to zero to prevent accidental creation of prepared
transactions. If you are using prepared transactions, you will
probably want max_prepared_transactions to be at
least as large as , so that every
session can have a prepared transaction pending.
When running a standby server, you must set this parameter to the
same or higher value than on the master server. Otherwise, queries
will not be allowed in the standby server.
work_mem (integer)
work_mem> configuration parameter
Specifies the amount of memory to be used by internal sort operations
and hash tables before writing to temporary disk files. The value
defaults to four megabytes (4MB>).
Note that for a complex query, several sort or hash operations might be
running in parallel; each operation will be allowed to use as much memory
as this value specifies before it starts to write data into temporary
files. Also, several running sessions could be doing such operations
concurrently. Therefore, the total memory used could be many
times the value of work_mem; it is necessary to
keep this fact in mind when choosing the value. Sort operations are
used for ORDER BY>, DISTINCT>, and
merge joins.
Hash tables are used in hash joins, hash-based aggregation, and
hash-based processing of IN> subqueries.
maintenance_work_mem (integer)
maintenance_work_mem> configuration parameter
Specifies the maximum amount of memory to be used by maintenance
operations, such as VACUUM, CREATE
INDEX>, and ALTER TABLE ADD FOREIGN KEY>. It defaults
to 64 megabytes (64MB>). Since only one of these
operations can be executed at a time by a database session, and
an installation normally doesn't have many of them running
concurrently, it's safe to set this value significantly larger
than work_mem. Larger settings might improve
performance for vacuuming and for restoring database dumps.
Note that when autovacuum runs, up to
times this memory
may be allocated, so be careful not to set the default value
too high. It may be useful to control for this by separately
setting .
replacement_sort_tuples (integer)
replacement_sort_tuples> configuration parameter
When the number of tuples to be sorted is smaller than this number,
a sort will produce its first output run using replacement selection
rather than quicksort. This may be useful in memory-constrained
environments where tuples that are input into larger sort operations
have a strong physical-to-logical correlation. Note that this does
not include input tuples with an inverse
correlation. It is possible for the replacement selection algorithm
to generate one long run that requires no merging, where use of the
default strategy would result in many runs that must be merged
to produce a final sorted output. This may allow sort
operations to complete sooner.
The default is 150,000 tuples. Note that higher values are typically
not much more effective, and may be counter-productive, since the
priority queue is sensitive to the size of available CPU cache, whereas
the default strategy sorts runs using a cache
oblivious algorithm. This property allows the default sort
strategy to automatically and transparently make effective use
of available CPU cache.
Setting maintenance_work_mem to its default
value usually prevents utility command external sorts (e.g.,
sorts used by CREATE INDEX> to build B-Tree
indexes) from ever using replacement selection sort, unless the
input tuples are quite wide.
autovacuum_work_mem (integer)
autovacuum_work_mem> configuration parameter
Specifies the maximum amount of memory to be used by each
autovacuum worker process. It defaults to -1, indicating that
the value of should
be used instead. The setting has no effect on the behavior of
VACUUM when run in other contexts.
max_stack_depth (integer)
max_stack_depth> configuration parameter
Specifies the maximum safe depth of the server's execution stack.
The ideal setting for this parameter is the actual stack size limit
enforced by the kernel (as set by ulimit -s> or local
equivalent), less a safety margin of a megabyte or so. The safety
margin is needed because the stack depth is not checked in every
routine in the server, but only in key potentially-recursive routines
such as expression evaluation. The default setting is two
megabytes (2MB>), which is conservatively small and
unlikely to risk crashes. However, it might be too small to allow
execution of complex functions. Only superusers can change this
setting.
Setting max_stack_depth> higher than
the actual kernel limit will mean that a runaway recursive function
can crash an individual backend process. On platforms where
PostgreSQL can determine the kernel limit,
the server will not allow this variable to be set to an unsafe
value. However, not all platforms provide the information,
so caution is recommended in selecting a value.
dynamic_shared_memory_type (enum)
dynamic_shared_memory_type> configuration parameter
Specifies the dynamic shared memory implementation that the server
should use. Possible values are posix> (for POSIX shared
memory allocated using shm_open>), sysv
(for System V shared memory allocated via shmget>),
windows> (for Windows shared memory), mmap>
(to simulate shared memory using memory-mapped files stored in the
data directory), and none> (to disable this feature).
Not all values are supported on all platforms; the first supported
option is the default for that platform. The use of the
mmap> option, which is not the default on any platform,
is generally discouraged because the operating system may write
modified pages back to disk repeatedly, increasing system I/O load;
however, it may be useful for debugging, when the
pg_dynshmem> directory is stored on a RAM disk, or when
other shared memory facilities are not available.
Disktemp_file_limit (integer)
temp_file_limit> configuration parameter
Specifies the maximum amount of disk space that a process can use
for temporary files, such as sort and hash temporary files, or the
storage file for a held cursor. A transaction attempting to exceed
this limit will be canceled.
The value is specified in kilobytes, and -1> (the
default) means no limit.
Only superusers can change this setting.
This setting constrains the total space used at any instant by all
temporary files used by a given PostgreSQL> process.
It should be noted that disk space used for explicit temporary
tables, as opposed to temporary files used behind-the-scenes in query
execution, does not count against this limit.
Kernel Resource Usagemax_files_per_process (integer)
max_files_per_process> configuration parameter
Sets the maximum number of simultaneously open files allowed to each
server subprocess. The default is one thousand files. If the kernel is enforcing
a safe per-process limit, you don't need to worry about this setting.
But on some platforms (notably, most BSD systems), the kernel will
allow individual processes to open many more files than the system
can actually support if many processes all try to open
that many files. If you find yourself seeing Too many open
files> failures, try reducing this setting.
This parameter can only be set at server start.
Cost-based Vacuum Delay
During the execution of
and
commands, the system maintains an
internal counter that keeps track of the estimated cost of the
various I/O operations that are performed. When the accumulated
cost reaches a limit (specified by
vacuum_cost_limit), the process performing
the operation will sleep for a short period of time, as specified by
vacuum_cost_delay. Then it will reset the
counter and continue execution.
The intent of this feature is to allow administrators to reduce
the I/O impact of these commands on concurrent database
activity. There are many situations where it is not
important that maintenance commands like
VACUUM and ANALYZE finish
quickly; however, it is usually very important that these
commands do not significantly interfere with the ability of the
system to perform other database operations. Cost-based vacuum
delay provides a way for administrators to achieve this.
This feature is disabled by default for manually issued
VACUUM commands. To enable it, set the
vacuum_cost_delay variable to a nonzero
value.
vacuum_cost_delay (integer)
vacuum_cost_delay> configuration parameter
The length of time, in milliseconds, that the process will sleep
when the cost limit has been exceeded.
The default value is zero, which disables the cost-based vacuum
delay feature. Positive values enable cost-based vacuuming.
Note that on many systems, the effective resolution
of sleep delays is 10 milliseconds; setting
vacuum_cost_delay to a value that is
not a multiple of 10 might have the same results as setting it
to the next higher multiple of 10.
When using cost-based vacuuming, appropriate values for
vacuum_cost_delay> are usually quite small, perhaps
10 or 20 milliseconds. Adjusting vacuum's resource consumption
is best done by changing the other vacuum cost parameters.
vacuum_cost_page_hit (integer)
vacuum_cost_page_hit> configuration parameter
The estimated cost for vacuuming a buffer found in the shared buffer
cache. It represents the cost to lock the buffer pool, lookup
the shared hash table and scan the content of the page. The
default value is one.
vacuum_cost_page_miss (integer)
vacuum_cost_page_miss> configuration parameter
The estimated cost for vacuuming a buffer that has to be read from
disk. This represents the effort to lock the buffer pool,
lookup the shared hash table, read the desired block in from
the disk and scan its content. The default value is 10.
vacuum_cost_page_dirty (integer)
vacuum_cost_page_dirty> configuration parameter
The estimated cost charged when vacuum modifies a block that was
previously clean. It represents the extra I/O required to
flush the dirty block out to disk again. The default value is
20.
vacuum_cost_limit (integer)
vacuum_cost_limit> configuration parameter
The accumulated cost that will cause the vacuuming process to sleep.
The default value is 200.
There are certain operations that hold critical locks and should
therefore complete as quickly as possible. Cost-based vacuum
delays do not occur during such operations. Therefore it is
possible that the cost accumulates far higher than the specified
limit. To avoid uselessly long delays in such cases, the actual
delay is calculated as vacuum_cost_delay *
accumulated_balance /
vacuum_cost_limit with a maximum of
vacuum_cost_delay * 4.
Background Writer
There is a separate server
process called the background writer>, whose function
is to issue writes of dirty> (new or modified) shared
buffers. It writes shared buffers so server processes handling
user queries seldom or never need to wait for a write to occur.
However, the background writer does cause a net overall
increase in I/O load, because while a repeatedly-dirtied page might
otherwise be written only once per checkpoint interval, the
background writer might write it several times as it is dirtied
in the same interval. The parameters discussed in this subsection
can be used to tune the behavior for local needs.
bgwriter_delay (integer)
bgwriter_delay> configuration parameter
Specifies the delay between activity rounds for the
background writer. In each round the writer issues writes
for some number of dirty buffers (controllable by the
following parameters). It then sleeps for bgwriter_delay>
milliseconds, and repeats. When there are no dirty buffers in the
buffer pool, though, it goes into a longer sleep regardless of
bgwriter_delay>. The default value is 200
milliseconds (200ms>). Note that on many systems, the
effective resolution of sleep delays is 10 milliseconds; setting
bgwriter_delay> to a value that is not a multiple of 10
might have the same results as setting it to the next higher multiple
of 10. This parameter can only be set in the
postgresql.conf> file or on the server command line.
bgwriter_lru_maxpages (integer)
bgwriter_lru_maxpages> configuration parameter
In each round, no more than this many buffers will be written
by the background writer. Setting this to zero disables
background writing. (Note that checkpoints, which are managed by
a separate, dedicated auxiliary process, are unaffected.)
The default value is 100 buffers.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
bgwriter_lru_multiplier (floating point)
bgwriter_lru_multiplier> configuration parameter
The number of dirty buffers written in each round is based on the
number of new buffers that have been needed by server processes
during recent rounds. The average recent need is multiplied by
bgwriter_lru_multiplier> to arrive at an estimate of the
number of buffers that will be needed during the next round. Dirty
buffers are written until there are that many clean, reusable buffers
available. (However, no more than bgwriter_lru_maxpages>
buffers will be written per round.)
Thus, a setting of 1.0 represents a just in time> policy
of writing exactly the number of buffers predicted to be needed.
Larger values provide some cushion against spikes in demand,
while smaller values intentionally leave writes to be done by
server processes.
The default is 2.0.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
bgwriter_flush_after (integer)
bgwriter_flush_after> configuration parameter
Whenever more than bgwriter_flush_after bytes have
been written by the bgwriter, attempt to force the OS to issue these
writes to the underlying storage. Doing so will limit the amount of
dirty data in the kernel's page cache, reducing the likelihood of
stalls when an fsync is issued at the end of a checkpoint, or when
the OS writes data back in larger batches in the background. Often
that will result in greatly reduced transaction latency, but there
also are some cases, especially with workloads that are bigger than
, but smaller than the OS's page
cache, where performance might degrade. This setting may have no
effect on some platforms. The valid range is between
0, which disables controlled writeback, and
2MB. The default is 512Kb> on Linux,
0> elsewhere. (Non-default values of
BLCKSZ change the default and maximum.)
This parameter can only be set in the postgresql.conf>
file or on the server command line.
Smaller values of bgwriter_lru_maxpages and
bgwriter_lru_multiplier reduce the extra I/O load
caused by the background writer, but make it more likely that server
processes will have to issue writes for themselves, delaying interactive
queries.
Asynchronous Behavioreffective_io_concurrency (integer)
effective_io_concurrency> configuration parameter
Sets the number of concurrent disk I/O operations that
PostgreSQL> expects can be executed
simultaneously. Raising this value will increase the number of I/O
operations that any individual PostgreSQL> session
attempts to initiate in parallel. The allowed range is 1 to 1000,
or zero to disable issuance of asynchronous I/O requests. Currently,
this setting only affects bitmap heap scans.
For magnetic drives, a good starting point for this setting is the
number of separate
drives comprising a RAID 0 stripe or RAID 1 mirror being used for the
database. (For RAID 5 the parity drive should not be counted.)
However, if the database is often busy with multiple queries issued in
concurrent sessions, lower values may be sufficient to keep the disk
array busy. A value higher than needed to keep the disks busy will
only result in extra CPU overhead.
SSDs and other memory-based storage can often process many
concurrent requests, so the best value might be in the hundreds.
Asynchronous I/O depends on an effective posix_fadvise>
function, which some operating systems lack. If the function is not
present then setting this parameter to anything but zero will result
in an error. On some operating systems (e.g., Solaris), the function
is present but does not actually do anything.
The default is 1 on supported systems, otherwise 0. This value can
be overridden for tables in a particular tablespace by setting the
tablespace parameter of the same name (see
).
max_worker_processes (integer)
max_worker_processes> configuration parameter
Sets the maximum number of background processes that the system
can support. This parameter can only be set at server start. The
default is 8.
When running a standby server, you must set this parameter to the
same or higher value than on the master server. Otherwise, queries
will not be allowed in the standby server.
max_parallel_workers_per_gather (integer)
max_parallel_workers_per_gather> configuration parameter
Sets the maximum number of workers that can be started by a single
Gather node. Parallel workers are taken from the
pool of processes established by
. Note that the requested
number of workers may not actually be available at runtime. If this
occurs, the plan will run with fewer workers than expected, which may
be inefficient. The default value is 2. Setting this value to 0
disables parallel query execution.
Note that parallel queries may consume very substantially more
resources than non-parallel queries, because each worker process is
a completely separate process which has roughly the same impact on the
system as an additional user session. This should be taken into
account when choosing a value for this setting, as well as when
configuring other settings that control resource utilization, such
as . Resource limits such as
work_mem> are applied individually to each worker,
which means the total utilization may be much higher across all
processes than it would normally be for any single process.
For example, a parallel query using 4 workers may use up to 5 times
as much CPU time, memory, I/O bandwidth, and so forth as a query which
uses no workers at all.
backend_flush_after (integer)
backend_flush_after> configuration parameter
Whenever more than backend_flush_after bytes have
been written by a single backend, attempt to force the OS to issue
these writes to the underlying storage. Doing so will limit the
amount of dirty data in the kernel's page cache, reducing the
likelihood of stalls when an fsync is issued at the end of a
checkpoint, or when the OS writes data back in larger batches in the
background. Often that will result in greatly reduced transaction
latency, but there also are some cases, especially with workloads
that are bigger than , but smaller
than the OS's page cache, where performance might degrade. This
setting may have no effect on some platforms. The valid range is
between 0, which disables controlled writeback,
and 2MB. The default is 0> (i.e. no
flush control). (Non-default values of BLCKSZ
change the maximum.)
old_snapshot_threshold (integer)
old_snapshot_threshold> configuration parameter
Sets the minimum time that a snapshot can be used without risk of a
snapshot too old> error occurring when using the snapshot.
This parameter can only be set at server start.
Beyond the threshold, old data may be vacuumed away. This can help
prevent bloat in the face of snapshots which remain in use for a
long time. To prevent incorrect results due to cleanup of data which
would otherwise be visible to the snapshot, an error is generated
when the snapshot is older than this threshold and the snapshot is
used to read a page which has been modified since the snapshot was
built.
A value of -1> disables this feature, and is the default.
Useful values for production work probably range from a small number
of hours to a few days. The setting will be coerced to a granularity
of minutes, and small numbers (such as 0> or
1min>) are only allowed because they may sometimes be
useful for testing. While a setting as high as 60d> is
allowed, please note that in many workloads extreme bloat or
transaction ID wraparound may occur in much shorter time frames.
When this feature is enabled, freed space at the end of a relation
cannot be released to the operating system, since that could remove
information needed to detect the snapshot too old>
condition. All space allocated to a relation remains associated with
that relation for reuse only within that relation unless explicitly
freed (for example, with VACUUM FULL>).
This setting does not attempt to guarantee that an error will be
generated under any particular circumstances. In fact, if the
correct results can be generated from (for example) a cursor which
has materialized a result set, no error will be generated even if the
underlying rows in the referenced table have been vacuumed away.
Some tables cannot safely be vacuumed early, and so will not be
affected by this setting. Examples include system catalogs and any
table which has a hash index. For such tables this setting will
neither reduce bloat nor create a possibility of a snapshot
too old> error on scanning.
Write Ahead Log
For additional information on tuning these settings,
see .
Settingswal_level (enum)
wal_level> configuration parameterwal_level> determines how much information is written
to the WAL. The default value is minimal>, which writes
only the information needed to recover from a crash or immediate
shutdown. replica> adds logging required for WAL
archiving as well as information required to run
read-only queries on a standby server. Finally,
logical> adds information necessary to support logical
decoding. Each level includes the information logged at all lower
levels. This parameter can only be set at server start.
In minimal> level, WAL-logging of some bulk
operations can be safely skipped, which can make those
operations much faster (see ).
Operations in which this optimization can be applied include:
CREATE TABLE AS>CREATE INDEX>CLUSTER>COPY> into tables that were created or truncated in the same
transaction
But minimal WAL does not contain enough information to reconstruct the
data from a base backup and the WAL logs, so replica> or
higher must be used to enable WAL archiving
() and streaming replication.
In logical> level, the same information is logged as
with replica>, plus information needed to allow
extracting logical change sets from the WAL. Using a level of
logical> will increase the WAL volume, particularly if many
tables are configured for REPLICA IDENTITY FULL and
many UPDATE> and DELETE> statements are
executed.
In releases prior to 9.6, this parameter also allowed the
values archive and hot_standby.
These are still accepted but mapped to replica.
fsync (boolean)
fsync> configuration parameter
If this parameter is on, the PostgreSQL> server
will try to make sure that updates are physically written to
disk, by issuing fsync()> system calls or various
equivalent methods (see ).
This ensures that the database cluster can recover to a
consistent state after an operating system or hardware crash.
While turning off fsync is often a performance
benefit, this can result in unrecoverable data corruption in
the event of a power failure or system crash. Thus it
is only advisable to turn off fsync if
you can easily recreate your entire database from external
data.
Examples of safe circumstances for turning off
fsync include the initial loading of a new
database cluster from a backup file, using a database cluster
for processing a batch of data after which the database
will be thrown away and recreated,
or for a read-only database clone which
gets recreated frequently and is not used for failover. High
quality hardware alone is not a sufficient justification for
turning off fsync.
For reliable recovery when changing fsync
off to on, it is necessary to force all modified buffers in the
kernel to durable storage. This can be done while the cluster
is shutdown or while fsync is on by running initdb
--sync-only, running sync>, unmounting the
file system, or rebooting the server.
In many situations, turning off
for noncritical transactions can provide much of the potential
performance benefit of turning off fsync, without
the attendant risks of data corruption.
fsync can only be set in the postgresql.conf>
file or on the server command line.
If you turn this parameter off, also consider turning off
.
synchronous_commit (enum)
synchronous_commit> configuration parameter
Specifies whether transaction commit will wait for WAL records
to be written to disk before the command returns a success>
indication to the client. Valid values are on>,
remote_apply>, remote_write>, local>,
and off>. The default, and safe, setting
is on>. When off>, there can be a delay between
when success is reported to the client and when the transaction is
really guaranteed to be safe against a server crash. (The maximum
delay is three times .) Unlike
, setting this parameter to off>
does not create any risk of database inconsistency: an operating
system or database crash might
result in some recent allegedly-committed transactions being lost, but
the database state will be just the same as if those transactions had
been aborted cleanly. So, turning synchronous_commit> off
can be a useful alternative when performance is more important than
exact certainty about the durability of a transaction. For more
discussion see .
If is non-empty, this
parameter also controls whether or not transaction commits will wait
for their WAL records to be replicated to the standby server(s).
When set to on>, commits will wait until replies
from the current synchronous standby(s) indicate they have received
the commit record of the transaction and flushed it to disk. This
ensures the transaction will not be lost unless both the primary and
all synchronous standbys suffer corruption of their database storage.
When set to remote_apply>, commits will wait until replies
from the current synchronous standby(s) indicate they have received the
commit record of the transaction and applied it, so that it has become
visible to queries on the standby(s).
When set to remote_write>, commits will wait until replies
from the current synchronous standby(s) indicate they have
received the commit record of the transaction and written it out to
their operating system. This setting is sufficient to
ensure data preservation even if a standby instance of
PostgreSQL> were to crash, but not if the standby
suffers an operating-system-level crash, since the data has not
necessarily reached stable storage on the standby.
Finally, the setting local> causes commits to wait for
local flush to disk, but not for replication. This is not usually
desirable when synchronous replication is in use, but is provided for
completeness.
If synchronous_standby_names> is empty, the settings
on>, remote_apply>, remote_write>
and local> all provide the same synchronization level:
transaction commits only wait for local flush to disk.
This parameter can be changed at any time; the behavior for any
one transaction is determined by the setting in effect when it
commits. It is therefore possible, and useful, to have some
transactions commit synchronously and others asynchronously.
For example, to make a single multistatement transaction commit
asynchronously when the default is the opposite, issue SET
LOCAL synchronous_commit TO OFF> within the transaction.
wal_sync_method (enum)
wal_sync_method> configuration parameter
Method used for forcing WAL updates out to disk.
If fsync is off then this setting is irrelevant,
since WAL file updates will not be forced out at all.
Possible values are:
open_datasync> (write WAL files with open()> option O_DSYNC>)
fdatasync> (call fdatasync()> at each commit)
fsync> (call fsync()> at each commit)
fsync_writethrough> (call fsync()> at each commit, forcing write-through of any disk write cache)
open_sync> (write WAL files with open()> option O_SYNC>)
The open_>* options also use O_DIRECT> if available.
Not all of these choices are available on all platforms.
The default is the first method in the above list that is supported
by the platform, except that fdatasync> is the default on
Linux. The default is not necessarily ideal; it might be
necessary to change this setting or other aspects of your system
configuration in order to create a crash-safe configuration or
achieve optimal performance.
These aspects are discussed in .
This parameter can only be set in the postgresql.conf>
file or on the server command line.
full_page_writes (boolean)
full_page_writes> configuration parameter
When this parameter is on, the PostgreSQL> server
writes the entire content of each disk page to WAL during the
first modification of that page after a checkpoint.
This is needed because
a page write that is in process during an operating system crash might
be only partially completed, leading to an on-disk page
that contains a mix of old and new data. The row-level change data
normally stored in WAL will not be enough to completely restore
such a page during post-crash recovery. Storing the full page image
guarantees that the page can be correctly restored, but at the price
of increasing the amount of data that must be written to WAL.
(Because WAL replay always starts from a checkpoint, it is sufficient
to do this during the first change of each page after a checkpoint.
Therefore, one way to reduce the cost of full-page writes is to
increase the checkpoint interval parameters.)
Turning this parameter off speeds normal operation, but
might lead to either unrecoverable data corruption, or silent
data corruption, after a system failure. The risks are similar to turning off
fsync, though smaller, and it should be turned off
only based on the same circumstances recommended for that parameter.
Turning off this parameter does not affect use of
WAL archiving for point-in-time recovery (PITR)
(see ).
This parameter can only be set in the postgresql.conf>
file or on the server command line.
The default is on>.
wal_log_hints (boolean)
wal_log_hints> configuration parameter
When this parameter is on>, the PostgreSQL>
server writes the entire content of each disk page to WAL during the
first modification of that page after a checkpoint, even for
non-critical modifications of so-called hint bits.
If data checksums are enabled, hint bit updates are always WAL-logged
and this setting is ignored. You can use this setting to test how much
extra WAL-logging would occur if your database had data checksums
enabled.
This parameter can only be set at server start. The default value is off>.
wal_compression (boolean)
wal_compression> configuration parameter
When this parameter is on>, the PostgreSQL>
server compresses a full page image written to WAL when
is on or during a base backup.
A compressed page image will be decompressed during WAL replay.
The default value is off>.
Only superusers can change this setting.
Turning this parameter on can reduce the WAL volume without
increasing the risk of unrecoverable data corruption,
but at the cost of some extra CPU spent on the compression during
WAL logging and on the decompression during WAL replay.
wal_buffers (integer)
wal_buffers> configuration parameter
The amount of shared memory used for WAL data that has not yet been
written to disk. The default setting of -1 selects a size equal to
1/32nd (about 3%) of , but not less
than 64kB nor more than the size of one WAL
segment, typically 16MB. This value can be set
manually if the automatic choice is too large or too small,
but any positive value less than 32kB will be
treated as 32kB.
This parameter can only be set at server start.
The contents of the WAL buffers are written out to disk at every
transaction commit, so extremely large values are unlikely to
provide a significant benefit. However, setting this value to at
least a few megabytes can improve write performance on a busy
server where many clients are committing at once. The auto-tuning
selected by the default setting of -1 should give reasonable
results in most cases.
wal_writer_delay (integer)
wal_writer_delay> configuration parameter
Specifies how often the WAL writer flushes WAL. After flushing WAL it
sleeps for wal_writer_delay> milliseconds, unless woken up
by an asynchronously committing transaction. In case the last flush
happened less than wal_writer_delay> milliseconds ago and
less than wal_writer_flush_after> bytes of WAL have been
produced since, WAL is only written to the OS, not flushed to disk.
The default value is 200 milliseconds (200ms>). Note that
on many systems, the effective resolution of sleep delays is 10
milliseconds; setting wal_writer_delay> to a value that is
not a multiple of 10 might have the same results as setting it to the
next higher multiple of 10. This parameter can only be set in the
postgresql.conf> file or on the server command line.
wal_writer_flush_after (integer)
wal_writer_flush_after> configuration parameter
Specifies how often the WAL writer flushes WAL. In case the last flush
happened less than wal_writer_delay> milliseconds ago and
less than wal_writer_flush_after> bytes of WAL have been
produced since, WAL is only written to the OS, not flushed to disk.
If wal_writer_flush_after> is set to 0> WAL is
flushed every time the WAL writer has written WAL. The default is
1MB. This parameter can only be set in the
postgresql.conf> file or on the server command line.
commit_delay (integer)
commit_delay> configuration parametercommit_delay adds a time delay, measured in
microseconds, before a WAL flush is initiated. This can improve
group commit throughput by allowing a larger number of transactions
to commit via a single WAL flush, if system load is high enough
that additional transactions become ready to commit within the
given interval. However, it also increases latency by up to
commit_delay microseconds for each WAL
flush. Because the delay is just wasted if no other transactions
become ready to commit, a delay is only performed if at least
commit_siblings other transactions are active
when a flush is about to be initiated. Also, no delays are
performed if fsync is disabled.
The default commit_delay> is zero (no delay).
Only superusers can change this setting.
In PostgreSQL> releases prior to 9.3,
commit_delay behaved differently and was much
less effective: it affected only commits, rather than all WAL flushes,
and waited for the entire configured delay even if the WAL flush
was completed sooner. Beginning in PostgreSQL> 9.3,
the first process that becomes ready to flush waits for the configured
interval, while subsequent processes wait only until the leader
completes the flush operation.
commit_siblings (integer)
commit_siblings> configuration parameter
Minimum number of concurrent open transactions to require
before performing the commit_delay> delay. A larger
value makes it more probable that at least one other
transaction will become ready to commit during the delay
interval. The default is five transactions.
Checkpointscheckpoint_timeout (integer)
checkpoint_timeout> configuration parameter
Maximum time between automatic WAL checkpoints, in seconds.
The valid range is between 30 seconds and one hour.
The default is five minutes (5min>).
Increasing this parameter can increase the amount of time needed
for crash recovery.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
checkpoint_completion_target (floating point)
checkpoint_completion_target> configuration parameter
Specifies the target of checkpoint completion, as a fraction of
total time between checkpoints. The default is 0.5.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
checkpoint_flush_after (integer)
checkpoint_flush_after> configuration parameter
Whenever more than checkpoint_flush_after bytes
have been written while performing a checkpoint, attempt to force the
OS to issue these writes to the underlying storage. Doing so will
limit the amount of dirty data in the kernel's page cache, reducing
the likelihood of stalls when an fsync is issued at the end of the
checkpoint, or when the OS writes data back in larger batches in the
background. Often that will result in greatly reduced transaction
latency, but there also are some cases, especially with workloads
that are bigger than , but smaller
than the OS's page cache, where performance might degrade. This
setting may have no effect on some platforms. The valid range is
between 0, which disables controlled writeback,
and 2MB. The default is 256Kb> on
Linux, 0> elsewhere. (Non-default values of
BLCKSZ change the default and maximum.)
This parameter can only be set in the postgresql.conf>
file or on the server command line.
checkpoint_warning (integer)
checkpoint_warning> configuration parameter
Write a message to the server log if checkpoints caused by
the filling of checkpoint segment files happen closer together
than this many seconds (which suggests that
max_wal_size> ought to be raised). The default is
30 seconds (30s>). Zero disables the warning.
No warnings will be generated if checkpoint_timeout
is less than checkpoint_warning.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
max_wal_size (integer)
max_wal_size> configuration parameter
Maximum size to let the WAL grow to between automatic WAL
checkpoints. This is a soft limit; WAL size can exceed
max_wal_size> under special circumstances, like
under heavy load, a failing archive_command>, or a high
wal_keep_segments> setting. The default is 1 GB.
Increasing this parameter can increase the amount of time needed for
crash recovery.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
min_wal_size (integer)
min_wal_size> configuration parameter
As long as WAL disk usage stays below this setting, old WAL files are
always recycled for future use at a checkpoint, rather than removed.
This can be used to ensure that enough WAL space is reserved to
handle spikes in WAL usage, for example when running large batch
jobs. The default is 80 MB.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
Archivingarchive_mode (enum)
archive_mode> configuration parameter
When archive_mode> is enabled, completed WAL segments
are sent to archive storage by setting
. In addition to off>,
to disable, there are two modes: on>, and
always>. During normal operation, there is no
difference between the two modes, but when set to always>
the WAL archiver is enabled also during archive recovery or standby
mode. In always> mode, all files restored from the archive
or streamed with streaming replication will be archived (again). See
for details.
archive_mode> and archive_command> are
separate variables so that archive_command> can be
changed without leaving archiving mode.
This parameter can only be set at server start.
archive_mode> cannot be enabled when
wal_level> is set to minimal>.
archive_command (string)
archive_command> configuration parameter
The local shell command to execute to archive a completed WAL file
segment. Any %p> in the string is
replaced by the path name of the file to archive, and any
%f> is replaced by only the file name.
(The path name is relative to the working directory of the server,
i.e., the cluster's data directory.)
Use %%> to embed an actual %> character in the
command. It is important for the command to return a zero
exit status only if it succeeds. For more information see
.
This parameter can only be set in the postgresql.conf>
file or on the server command line. It is ignored unless
archive_mode> was enabled at server start.
If archive_command> is an empty string (the default) while
archive_mode> is enabled, WAL archiving is temporarily
disabled, but the server continues to accumulate WAL segment files in
the expectation that a command will soon be provided. Setting
archive_command> to a command that does nothing but
return true, e.g. /bin/true> (REM> on
Windows), effectively disables
archiving, but also breaks the chain of WAL files needed for
archive recovery, so it should only be used in unusual circumstances.
archive_timeout (integer)
archive_timeout> configuration parameter
The is only invoked for
completed WAL segments. Hence, if your server generates little WAL
traffic (or has slack periods where it does so), there could be a
long delay between the completion of a transaction and its safe
recording in archive storage. To limit how old unarchived
data can be, you can set archive_timeout> to force the
server to switch to a new WAL segment file periodically. When this
parameter is greater than zero, the server will switch to a new
segment file whenever this many seconds have elapsed since the last
segment file switch, and there has been any database activity,
including a single checkpoint. (Increasing
checkpoint_timeout> will reduce unnecessary
checkpoints on an idle system.)
Note that archived files that are closed early
due to a forced switch are still the same length as completely full
files. Therefore, it is unwise to use a very short
archive_timeout> — it will bloat your archive
storage. archive_timeout> settings of a minute or so are
usually reasonable. You should consider using streaming replication,
instead of archiving, if you want data to be copied off the master
server more quickly than that.
This parameter can only be set in the
postgresql.conf> file or on the server command line.
Replication
These settings control the behavior of the built-in
streaming replication> feature (see
). Servers will be either a
Master or a Standby server. Masters can send data, while Standby(s)
are always receivers of replicated data. When cascading replication
(see ) is used, Standby server(s)
can also be senders, as well as receivers.
Parameters are mainly for Sending and Standby servers, though some
parameters have meaning only on the Master server. Settings may vary
across the cluster without problems if that is required.
Sending Server(s)
These parameters can be set on any server that is
to send replication data to one or more standby servers.
The master is always a sending server, so these parameters must
always be set on the master.
The role and meaning of these parameters does not change after a
standby becomes the master.
max_wal_senders (integer)
max_wal_senders> configuration parameter
Specifies the maximum number of concurrent connections from
standby servers or streaming base backup clients (i.e., the
maximum number of simultaneously running WAL sender
processes). The default is zero, meaning replication is
disabled. WAL sender processes count towards the total number
of connections, so the parameter cannot be set higher than
. Abrupt streaming client
disconnection might cause an orphaned connection slot until
a timeout is reached, so this parameter should be set slightly
higher than the maximum number of expected clients so disconnected
clients can immediately reconnect. This parameter can only
be set at server start. wal_level> must be set to
replica> or higher to allow connections from standby
servers.
max_replication_slots (integer)
max_replication_slots> configuration parameter
Specifies the maximum number of replication slots
(see ) that the server
can support. The default is zero. This parameter can only be set at
server start.
wal_level must be set
to replica or higher to allow replication slots to
be used. Setting it to a lower value than the number of currently
existing replication slots will prevent the server from starting.
wal_keep_segments (integer)
wal_keep_segments> configuration parameter
Specifies the minimum number of past log file segments kept in the
pg_xlog>
directory, in case a standby server needs to fetch them for streaming
replication. Each segment is normally 16 megabytes. If a standby
server connected to the sending server falls behind by more than
wal_keep_segments> segments, the sending server might remove
a WAL segment still needed by the standby, in which case the
replication connection will be terminated. Downstream connections
will also eventually fail as a result. (However, the standby
server can recover by fetching the segment from archive, if WAL
archiving is in use.)
This sets only the minimum number of segments retained in
pg_xlog>; the system might need to retain more segments
for WAL archival or to recover from a checkpoint. If
wal_keep_segments> is zero (the default), the system
doesn't keep any extra segments for standby purposes, so the number
of old WAL segments available to standby servers is a function of
the location of the previous checkpoint and status of WAL
archiving.
This parameter can only be set in the
postgresql.conf> file or on the server command line.
wal_sender_timeout (integer)
wal_sender_timeout> configuration parameter
Terminate replication connections that are inactive longer
than the specified number of milliseconds. This is useful for
the sending server to detect a standby crash or network outage.
A value of zero disables the timeout mechanism. This parameter
can only be set in
the postgresql.conf> file or on the server command line.
The default value is 60 seconds.
track_commit_timestamp (bool)
track_commit_timestamp> configuration parameter
Record commit time of transactions. This parameter
can only be set in postgresql.conf> file or on the server
command line. The default value is off.
Master Server
These parameters can be set on the master/primary server that is
to send replication data to one or more standby servers.
Note that in addition to these parameters,
must be set appropriately on the master
server, and optionally WAL archiving can be enabled as
well (see ).
The values of these parameters on standby servers are irrelevant,
although you may wish to set them there in preparation for the
possibility of a standby becoming the master.
synchronous_standby_names (string)
synchronous_standby_names> configuration parameter
Specifies a list of standby servers that can support
synchronous replication>, as described in
.
There will be one or more active synchronous standbys;
transactions waiting for commit will be allowed to proceed after
these standby servers confirm receipt of their data.
The synchronous standbys will be those whose names appear
earlier in this list, and
that are both currently connected and streaming data in real-time
(as shown by a state of streaming in the
pg_stat_replication> view).
Other standby servers appearing later in this list represent potential
synchronous standbys. If any of the current synchronous
standbys disconnects for whatever reason,
it will be replaced immediately with the next-highest-priority standby.
Specifying more than one standby name can allow very high availability.
This parameter specifies a list of standby servers using
either of the following syntaxes:
num_sync ( standby_name [, ...] )
standby_name [, ...]
where num_sync is
the number of synchronous standbys that transactions need to
wait for replies from,
and standby_name
is the name of a standby server. For example, a setting of
3 (s1, s2, s3, s4)> makes transaction commits wait
until their WAL records are received by three higher-priority standbys
chosen from standby servers s1>, s2>,
s3> and s4>.
The second syntax was used before PostgreSQL>
version 9.6 and is still supported. It's the same as the first syntax
with num_sync equal to 1.
For example, 1 (s1, s2)> and
s1, s2> have the same meaning: either s1>
or s2> is chosen as a synchronous standby.
The name of a standby server for this purpose is the
application_name> setting of the standby, as set in the
primary_conninfo> of the standby's WAL receiver. There is
no mechanism to enforce uniqueness. In case of duplicates one of the
matching standbys will be considered as higher priority, though
exactly which one is indeterminate.
The special entry *> matches any
application_name>, including the default application name
of walreceiver>.
Each standby_name
should have the form of a valid SQL identifier, unless it
is *>. You can use double-quoting if necessary. But note
that standby_names are
compared to standby application names case-insensitively, whether
double-quoted or not.
If no synchronous standby names are specified here, then synchronous
replication is not enabled and transaction commits will not wait for
replication. This is the default configuration. Even when
synchronous replication is enabled, individual transactions can be
configured not to wait for replication by setting the
parameter to
local> or off>.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
vacuum_defer_cleanup_age (integer)
vacuum_defer_cleanup_age> configuration parameter
Specifies the number of transactions by which VACUUM> and
HOT> updates will defer cleanup of dead row versions. The
default is zero transactions, meaning that dead row versions can be
removed as soon as possible, that is, as soon as they are no longer
visible to any open transaction. You may wish to set this to a
non-zero value on a primary server that is supporting hot standby
servers, as described in . This allows
more time for queries on the standby to complete without incurring
conflicts due to early cleanup of rows. However, since the value
is measured in terms of number of write transactions occurring on the
primary server, it is difficult to predict just how much additional
grace time will be made available to standby queries.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
You should also consider setting hot_standby_feedback>
on standby server(s) as an alternative to using this parameter.
This does not prevent cleanup of dead rows which have reached the age
specified by old_snapshot_threshold>.
Standby Servers
These settings control the behavior of a standby server that is
to receive replication data. Their values on the master server
are irrelevant.
hot_standby (boolean)
hot_standby> configuration parameter
Specifies whether or not you can connect and run queries during
recovery, as described in .
The default value is off.
This parameter can only be set at server start. It only has effect
during archive recovery or in standby mode.
max_standby_archive_delay (integer)
max_standby_archive_delay> configuration parameter
When Hot Standby is active, this parameter determines how long the
standby server should wait before canceling standby queries that
conflict with about-to-be-applied WAL entries, as described in
.
max_standby_archive_delay> applies when WAL data is
being read from WAL archive (and is therefore not current).
The default is 30 seconds. Units are milliseconds if not specified.
A value of -1 allows the standby to wait forever for conflicting
queries to complete.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
Note that max_standby_archive_delay> is not the same as the
maximum length of time a query can run before cancellation; rather it
is the maximum total time allowed to apply any one WAL segment's data.
Thus, if one query has resulted in significant delay earlier in the
WAL segment, subsequent conflicting queries will have much less grace
time.
max_standby_streaming_delay (integer)
max_standby_streaming_delay> configuration parameter
When Hot Standby is active, this parameter determines how long the
standby server should wait before canceling standby queries that
conflict with about-to-be-applied WAL entries, as described in
.
max_standby_streaming_delay> applies when WAL data is
being received via streaming replication.
The default is 30 seconds. Units are milliseconds if not specified.
A value of -1 allows the standby to wait forever for conflicting
queries to complete.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
Note that max_standby_streaming_delay> is not the same as
the maximum length of time a query can run before cancellation; rather
it is the maximum total time allowed to apply WAL data once it has
been received from the primary server. Thus, if one query has
resulted in significant delay, subsequent conflicting queries will
have much less grace time until the standby server has caught up
again.
wal_receiver_status_interval (integer)
wal_receiver_status_interval> configuration parameter
Specifies the minimum frequency for the WAL receiver
process on the standby to send information about replication progress
to the primary or upstream standby, where it can be seen using the
pg_stat_replication> view. The standby will report
the last transaction log position it has written, the last position it
has flushed to disk, and the last position it has applied.
This parameter's
value is the maximum interval, in seconds, between reports. Updates are
sent each time the write or flush positions change, or at least as
often as specified by this parameter. Thus, the apply position may
lag slightly behind the true position. Setting this parameter to zero
disables status updates completely. This parameter can only be set in
the postgresql.conf> file or on the server command line.
The default value is 10 seconds.
hot_standby_feedback (boolean)
hot_standby_feedback> configuration parameter
Specifies whether or not a hot standby will send feedback to the primary
or upstream standby
about queries currently executing on the standby. This parameter can
be used to eliminate query cancels caused by cleanup records, but
can cause database bloat on the primary for some workloads.
Feedback messages will not be sent more frequently than once per
wal_receiver_status_interval>. The default value is
off. This parameter can only be set in the
postgresql.conf> file or on the server command line.
If cascaded replication is in use the feedback is passed upstream
until it eventually reaches the primary. Standbys make no other use
of feedback they receive other than to pass upstream.
This setting does not override the behavior of
old_snapshot_threshold> on the primary; a snapshot on the
standby which exceeds the primary's age threshold can become invalid,
resulting in cancellation of transactions on the standby. This is
because old_snapshot_threshold> is intended to provide an
absolute limit on the time which dead rows can contribute to bloat,
which would otherwise be violated because of the configuration of a
standby.
wal_receiver_timeout (integer)
wal_receiver_timeout> configuration parameter
Terminate replication connections that are inactive longer
than the specified number of milliseconds. This is useful for
the receiving standby server to detect a primary node crash or network
outage.
A value of zero disables the timeout mechanism. This parameter
can only be set in
the postgresql.conf> file or on the server command line.
The default value is 60 seconds.
wal_retrieve_retry_interval (integer)
wal_retrieve_retry_interval> configuration parameter
Specify how long the standby server should wait when WAL data is not
available from any sources (streaming replication,
local pg_xlog> or WAL archive) before retrying to
retrieve WAL data. This parameter can only be set in the
postgresql.conf> file or on the server command line.
The default value is 5 seconds. Units are milliseconds if not specified.
This parameter is useful in configurations where a node in recovery
needs to control the amount of time to wait for new WAL data to be
available. For example, in archive recovery, it is possible to
make the recovery more responsive in the detection of a new WAL
log file by reducing the value of this parameter. On a system with
low WAL activity, increasing it reduces the amount of requests necessary
to access WAL archives, something useful for example in cloud
environments where the amount of times an infrastructure is accessed
is taken into account.
Query PlanningPlanner Method Configuration
These configuration parameters provide a crude method of
influencing the query plans chosen by the query optimizer. If
the default plan chosen by the optimizer for a particular query
is not optimal, a temporary> solution is to use one
of these configuration parameters to force the optimizer to
choose a different plan.
Better ways to improve the quality of the
plans chosen by the optimizer include adjusting the planer cost
constants (see ),
running manually, increasing
the value of the configuration parameter,
and increasing the amount of statistics collected for
specific columns using ALTER TABLE SET
STATISTICS.
enable_bitmapscan (boolean)
bitmap scanenable_bitmapscan> configuration parameter
Enables or disables the query planner's use of bitmap-scan plan
types. The default is on>.
enable_hashagg (boolean)
enable_hashagg> configuration parameter
Enables or disables the query planner's use of hashed
aggregation plan types. The default is on>.
enable_hashjoin (boolean)
enable_hashjoin> configuration parameter
Enables or disables the query planner's use of hash-join plan
types. The default is on>.
enable_indexscan (boolean)
index scanenable_indexscan> configuration parameter
Enables or disables the query planner's use of index-scan plan
types. The default is on>.
enable_indexonlyscan (boolean)
enable_indexonlyscan> configuration parameter
Enables or disables the query planner's use of index-only-scan plan
types (see ).
The default is on>.
enable_material (boolean)
enable_material> configuration parameter
Enables or disables the query planner's use of materialization.
It is impossible to suppress materialization entirely,
but turning this variable off prevents the planner from inserting
materialize nodes except in cases where it is required for correctness.
The default is on>.
enable_mergejoin (boolean)
enable_mergejoin> configuration parameter
Enables or disables the query planner's use of merge-join plan
types. The default is on>.
enable_nestloop (boolean)
enable_nestloop> configuration parameter
Enables or disables the query planner's use of nested-loop join
plans. It is impossible to suppress nested-loop joins entirely,
but turning this variable off discourages the planner from using
one if there are other methods available. The default is
on>.
enable_seqscan (boolean)
sequential scanenable_seqscan> configuration parameter
Enables or disables the query planner's use of sequential scan
plan types. It is impossible to suppress sequential scans
entirely, but turning this variable off discourages the planner
from using one if there are other methods available. The
default is on>.
enable_sort (boolean)
enable_sort> configuration parameter
Enables or disables the query planner's use of explicit sort
steps. It is impossible to suppress explicit sorts entirely,
but turning this variable off discourages the planner from
using one if there are other methods available. The default
is on>.
enable_tidscan (boolean)
enable_tidscan> configuration parameter
Enables or disables the query planner's use of TID>
scan plan types. The default is on>.
Planner Cost Constants
The cost> variables described in this section are measured
on an arbitrary scale. Only their relative values matter, hence
scaling them all up or down by the same factor will result in no change
in the planner's choices. By default, these cost variables are based on
the cost of sequential page fetches; that is,
seq_page_cost> is conventionally set to 1.0>
and the other cost variables are set with reference to that. But
you can use a different scale if you prefer, such as actual execution
times in milliseconds on a particular machine.
Unfortunately, there is no well-defined method for determining ideal
values for the cost variables. They are best treated as averages over
the entire mix of queries that a particular installation will receive. This
means that changing them on the basis of just a few experiments is very
risky.
seq_page_cost (floating point)
seq_page_cost> configuration parameter
Sets the planner's estimate of the cost of a disk page fetch
that is part of a series of sequential fetches. The default is 1.0.
This value can be overridden for tables and indexes in a particular
tablespace by setting the tablespace parameter of the same name
(see ).
random_page_cost (floating point)
random_page_cost> configuration parameter
Sets the planner's estimate of the cost of a
non-sequentially-fetched disk page. The default is 4.0.
This value can be overridden for tables and indexes in a particular
tablespace by setting the tablespace parameter of the same name
(see ).
Reducing this value relative to seq_page_cost>
will cause the system to prefer index scans; raising it will
make index scans look relatively more expensive. You can raise
or lower both values together to change the importance of disk I/O
costs relative to CPU costs, which are described by the following
parameters.
Random access to mechanical disk storage is normally much more expensive
than four times sequential access. However, a lower default is used
(4.0) because the majority of random accesses to disk, such as indexed
reads, are assumed to be in cache. The default value can be thought of
as modeling random access as 40 times slower than sequential, while
expecting 90% of random reads to be cached.
If you believe a 90% cache rate is an incorrect assumption
for your workload, you can increase random_page_cost to better
reflect the true cost of random storage reads. Correspondingly,
if your data is likely to be completely in cache, such as when
the database is smaller than the total server memory, decreasing
random_page_cost can be appropriate. Storage that has a low random
read cost relative to sequential, e.g. solid-state drives, might
also be better modeled with a lower value for random_page_cost.
Although the system will let you set random_page_cost> to
less than seq_page_cost>, it is not physically sensible
to do so. However, setting them equal makes sense if the database
is entirely cached in RAM, since in that case there is no penalty
for touching pages out of sequence. Also, in a heavily-cached
database you should lower both values relative to the CPU parameters,
since the cost of fetching a page already in RAM is much smaller
than it would normally be.
cpu_tuple_cost (floating point)
cpu_tuple_cost> configuration parameter
Sets the planner's estimate of the cost of processing
each row during a query.
The default is 0.01.
cpu_index_tuple_cost (floating point)
cpu_index_tuple_cost> configuration parameter
Sets the planner's estimate of the cost of processing
each index entry during an index scan.
The default is 0.005.
cpu_operator_cost (floating point)
cpu_operator_cost> configuration parameter
Sets the planner's estimate of the cost of processing each
operator or function executed during a query.
The default is 0.0025.
parallel_setup_cost (floating point)
parallel_setup_cost> configuration parameter
Sets the planner's estimate of the cost of launching parallel worker
processes.
The default is 1000.
parallel_tuple_cost (floating point)
parallel_tuple_cost> configuration parameter
Sets the planner's estimate of the cost of transferring one tuple
from a parallel worker process to another process.
The default is 0.1.
min_parallel_relation_size (integer)
min_parallel_relation_size> configuration parameter
Sets the minimum size of relations to be considered for parallel scan.
The default is 8 megabytes (8MB>).
effective_cache_size (integer)
effective_cache_size> configuration parameter
Sets the planner's assumption about the effective size of the
disk cache that is available to a single query. This is
factored into estimates of the cost of using an index; a
higher value makes it more likely index scans will be used, a
lower value makes it more likely sequential scans will be
used. When setting this parameter you should consider both
PostgreSQL's shared buffers and the
portion of the kernel's disk cache that will be used for
PostgreSQL data files. Also, take
into account the expected number of concurrent queries on different
tables, since they will have to share the available
space. This parameter has no effect on the size of shared
memory allocated by PostgreSQL, nor
does it reserve kernel disk cache; it is used only for estimation
purposes. The system also does not assume data remains in
the disk cache between queries. The default is 4 gigabytes
(4GB>).
Genetic Query Optimizer
The genetic query optimizer (GEQO) is an algorithm that does query
planning using heuristic searching. This reduces planning time for
complex queries (those joining many relations), at the cost of producing
plans that are sometimes inferior to those found by the normal
exhaustive-search algorithm.
For more information see .
geqo (boolean)
genetic query optimizationGEQOgenetic query optimizationgeqo> configuration parameter
Enables or disables genetic query optimization.
This is on by default. It is usually best not to turn it off in
production; the geqo_threshold variable provides
more granular control of GEQO.
geqo_threshold (integer)
geqo_threshold> configuration parameter
Use genetic query optimization to plan queries with at least
this many FROM> items involved. (Note that a
FULL OUTER JOIN> construct counts as only one FROM>
item.) The default is 12. For simpler queries it is usually best
to use the regular, exhaustive-search planner, but for queries with
many tables the exhaustive search takes too long, often
longer than the penalty of executing a suboptimal plan. Thus,
a threshold on the size of the query is a convenient way to manage
use of GEQO.
geqo_effort (integer)
geqo_effort> configuration parameter
Controls the trade-off between planning time and query plan
quality in GEQO. This variable must be an integer in the
range from 1 to 10. The default value is five. Larger values
increase the time spent doing query planning, but also
increase the likelihood that an efficient query plan will be
chosen.
geqo_effort doesn't actually do anything
directly; it is only used to compute the default values for
the other variables that influence GEQO behavior (described
below). If you prefer, you can set the other parameters by
hand instead.
geqo_pool_size (integer)
geqo_pool_size> configuration parameter
Controls the pool size used by GEQO, that is the
number of individuals in the genetic population. It must be
at least two, and useful values are typically 100 to 1000. If
it is set to zero (the default setting) then a suitable
value is chosen based on geqo_effort and
the number of tables in the query.
geqo_generations (integer)
geqo_generations> configuration parameter
Controls the number of generations used by GEQO, that is
the number of iterations of the algorithm. It must
be at least one, and useful values are in the same range as
the pool size. If it is set to zero (the default setting)
then a suitable value is chosen based on
geqo_pool_size.
geqo_selection_bias (floating point)
geqo_selection_bias> configuration parameter
Controls the selection bias used by GEQO. The selection bias
is the selective pressure within the population. Values can be
from 1.50 to 2.00; the latter is the default.
geqo_seed (floating point)
geqo_seed> configuration parameter
Controls the initial value of the random number generator used
by GEQO to select random paths through the join order search space.
The value can range from zero (the default) to one. Varying the
value changes the set of join paths explored, and may result in a
better or worse best path being found.
Other Planner Optionsdefault_statistics_target (integer)
default_statistics_target> configuration parameter
Sets the default statistics target for table columns without
a column-specific target set via ALTER TABLE
SET STATISTICS>. Larger values increase the time needed to
do ANALYZE>, but might improve the quality of the
planner's estimates. The default is 100. For more information
on the use of statistics by the PostgreSQL>
query planner, refer to .
constraint_exclusion (enum)
constraint exclusionconstraint_exclusion> configuration parameter
Controls the query planner's use of table constraints to
optimize queries.
The allowed values of constraint_exclusion> are
on> (examine constraints for all tables),
off> (never examine constraints), and
partition> (examine constraints only for inheritance child
tables and UNION ALL> subqueries).
partition> is the default setting.
It is often used with inheritance and partitioned tables to
improve performance.
When this parameter allows it for a particular table, the planner
compares query conditions with the table's CHECK>
constraints, and omits scanning tables for which the conditions
contradict the constraints. For example:
CREATE TABLE parent(key integer, ...);
CREATE TABLE child1000(check (key between 1000 and 1999)) INHERITS(parent);
CREATE TABLE child2000(check (key between 2000 and 2999)) INHERITS(parent);
...
SELECT * FROM parent WHERE key = 2400;
With constraint exclusion enabled, this SELECT>
will not scan child1000> at all, improving performance.
Currently, constraint exclusion is enabled by default
only for cases that are often used to implement table partitioning.
Turning it on for all tables imposes extra planning overhead that is
quite noticeable on simple queries, and most often will yield no
benefit for simple queries. If you have no partitioned tables
you might prefer to turn it off entirely.
Refer to for
more information on using constraint exclusion and partitioning.
cursor_tuple_fraction (floating point)
cursor_tuple_fraction> configuration parameter
Sets the planner's estimate of the fraction of a cursor's rows that
will be retrieved. The default is 0.1. Smaller values of this
setting bias the planner towards using fast start> plans
for cursors, which will retrieve the first few rows quickly while
perhaps taking a long time to fetch all rows. Larger values
put more emphasis on the total estimated time. At the maximum
setting of 1.0, cursors are planned exactly like regular queries,
considering only the total estimated time and not how soon the
first rows might be delivered.
from_collapse_limit (integer)
from_collapse_limit> configuration parameter
The planner will merge sub-queries into upper queries if the
resulting FROM list would have no more than
this many items. Smaller values reduce planning time but might
yield inferior query plans. The default is eight.
For more information see .
Setting this value to or more
may trigger use of the GEQO planner, resulting in non-optimal
plans. See .
join_collapse_limit (integer)
join_collapse_limit> configuration parameter
The planner will rewrite explicit JOIN>
constructs (except FULL JOIN>s) into lists of
FROM> items whenever a list of no more than this many items
would result. Smaller values reduce planning time but might
yield inferior query plans.
By default, this variable is set the same as
from_collapse_limit, which is appropriate
for most uses. Setting it to 1 prevents any reordering of
explicit JOIN>s. Thus, the explicit join order
specified in the query will be the actual order in which the
relations are joined. Because the query planner does not always choose
the optimal join order, advanced users can elect to
temporarily set this variable to 1, and then specify the join
order they desire explicitly.
For more information see .
Setting this value to or more
may trigger use of the GEQO planner, resulting in non-optimal
plans. See .
force_parallel_mode (enum)
force_parallel_mode> configuration parameter
Allows the use of parallel queries for testing purposes even in cases
where no performance benefit is expected.
The allowed values of force_parallel_mode> are
off> (use parallel mode only when it is expected to improve
performance), on> (force parallel query for all queries
for which it is thought to be safe), and regress> (like
on>, but with additional behavior changes as explained
below).
More specifically, setting this value to on> will add
a Gather> node to the top of any query plan for which this
appears to be safe, so that the query runs inside of a parallel worker.
Even when a parallel worker is not available or cannot be used,
operations such as starting a subtransaction that would be prohibited
in a parallel query context will be prohibited unless the planner
believes that this will cause the query to fail. If failures or
unexpected results occur when this option is set, some functions used
by the query may need to be marked PARALLEL UNSAFE
(or, possibly, PARALLEL RESTRICTED).
Setting this value to regress> has all of the same effects
as setting it to on> plus some additional effects that are
intended to facilitate automated regression testing. Normally,
messages from a parallel worker include a context line indicating that,
but a setting of regress> suppresses this line so that the
output is the same as in non-parallel execution. Also,
the Gather> nodes added to plans by this setting are hidden
in EXPLAIN> output so that the output matches what
would be obtained if this setting were turned off>.
Error Reporting and Loggingserver logWhere To Logwhere to loglog_destination (string)
log_destination> configuration parameterPostgreSQL supports several methods
for logging server messages, including
stderr, csvlog and
syslog. On Windows,
eventlog is also supported. Set this
parameter to a list of desired log destinations separated by
commas. The default is to log to stderr
only.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
If csvlog> is included in log_destination>,
log entries are output in comma separated
value> (CSV>) format, which is convenient for
loading logs into programs.
See for details.
must be enabled to generate
CSV-format log output.
On most Unix systems, you will need to alter the configuration of
your system's syslog daemon in order
to make use of the syslog option for
log_destination>. PostgreSQL
can log to syslog facilities
LOCAL0> through LOCAL7> (see ), but the default
syslog configuration on most platforms
will discard all such messages. You will need to add something like:
local0.* /var/log/postgresql
to the syslog daemon's configuration file
to make it work.
On Windows, when you use the eventlog
option for log_destination>, you should
register an event source and its library with the operating
system so that the Windows Event Viewer can display event
log messages cleanly.
See for details.
logging_collector (boolean)
logging_collector> configuration parameter
This parameter enables the logging collector>, which
is a background process that captures log messages
sent to stderr> and redirects them into log files.
This approach is often more useful than
logging to syslog>, since some types of messages
might not appear in syslog> output. (One common
example is dynamic-linker failure messages; another is error messages
produced by scripts such as archive_command>.)
This parameter can only be set at server start.
It is possible to log to stderr> without using the
logging collector; the log messages will just go to wherever the
server's stderr> is directed. However, that method is
only suitable for low log volumes, since it provides no convenient
way to rotate log files. Also, on some platforms not using the
logging collector can result in lost or garbled log output, because
multiple processes writing concurrently to the same log file can
overwrite each other's output.
The logging collector is designed to never lose messages. This means
that in case of extremely high load, server processes could be
blocked while trying to send additional log messages when the
collector has fallen behind. In contrast, syslog>
prefers to drop messages if it cannot write them, which means it
may fail to log some messages in such cases but it will not block
the rest of the system.
log_directory (string)
log_directory> configuration parameter
When logging_collector> is enabled,
this parameter determines the directory in which log files will be created.
It can be specified as an absolute path, or relative to the
cluster data directory.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
The default is pg_log.
log_filename (string)
log_filename> configuration parameter
When logging_collector is enabled,
this parameter sets the file names of the created log files. The value
is treated as a strftime pattern,
so %-escapes can be used to specify time-varying
file names. (Note that if there are
any time-zone-dependent %-escapes, the computation
is done in the zone specified
by .)
The supported %-escapes are similar to those
listed in the Open Group's strftime
specification.
Note that the system's strftime is not used
directly, so platform-specific (nonstandard) extensions do not work.
The default is postgresql-%Y-%m-%d_%H%M%S.log.
If you specify a file name without escapes, you should plan to
use a log rotation utility to avoid eventually filling the
entire disk. In releases prior to 8.4, if
no % escapes were
present, PostgreSQL would append
the epoch of the new log file's creation time, but this is no
longer the case.
If CSV-format output is enabled in log_destination>,
.csv> will be appended to the timestamped
log file name to create the file name for CSV-format output.
(If log_filename> ends in .log>, the suffix is
replaced instead.)
This parameter can only be set in the postgresql.conf>
file or on the server command line.
log_file_mode (integer)
log_file_mode> configuration parameter
On Unix systems this parameter sets the permissions for log files
when logging_collector is enabled. (On Microsoft
Windows this parameter is ignored.)
The parameter value is expected to be a numeric mode
specified in the format accepted by the
chmod and umask
system calls. (To use the customary octal format the number
must start with a 0 (zero).)
The default permissions are 0600>, meaning only the
server owner can read or write the log files. The other commonly
useful setting is 0640>, allowing members of the owner's
group to read the files. Note however that to make use of such a
setting, you'll need to alter to
store the files somewhere outside the cluster data directory. In
any case, it's unwise to make the log files world-readable, since
they might contain sensitive data.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
log_rotation_age (integer)
log_rotation_age> configuration parameter
When logging_collector is enabled,
this parameter determines the maximum lifetime of an individual log file.
After this many minutes have elapsed, a new log file will
be created. Set to zero to disable time-based creation of
new log files.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
log_rotation_size (integer)
log_rotation_size> configuration parameter
When logging_collector is enabled,
this parameter determines the maximum size of an individual log file.
After this many kilobytes have been emitted into a log file,
a new log file will be created. Set to zero to disable size-based
creation of new log files.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
log_truncate_on_rotation (boolean)
log_truncate_on_rotation> configuration parameter
When logging_collector is enabled,
this parameter will cause PostgreSQL to truncate (overwrite),
rather than append to, any existing log file of the same name.
However, truncation will occur only when a new file is being opened
due to time-based rotation, not during server startup or size-based
rotation. When off, pre-existing files will be appended to in
all cases. For example, using this setting in combination with
a log_filename like postgresql-%H.log
would result in generating twenty-four hourly log files and then
cyclically overwriting them.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
Example: To keep 7 days of logs, one log file per day named
server_log.Mon, server_log.Tue,
etc, and automatically overwrite last week's log with this week's log,
set log_filename to server_log.%a,
log_truncate_on_rotation to on, and
log_rotation_age to 1440.
Example: To keep 24 hours of logs, one log file per hour, but
also rotate sooner if the log file size exceeds 1GB, set
log_filename to server_log.%H%M,
log_truncate_on_rotation to on,
log_rotation_age to 60, and
log_rotation_size to 1000000.
Including %M> in log_filename allows
any size-driven rotations that might occur to select a file name
different from the hour's initial file name.
syslog_facility (enum)
syslog_facility> configuration parameter
When logging to syslog> is enabled, this parameter
determines the syslogfacility to be used. You can choose
from LOCAL0>, LOCAL1>,
LOCAL2>, LOCAL3>, LOCAL4>,
LOCAL5>, LOCAL6>, LOCAL7>;
the default is LOCAL0>. See also the
documentation of your system's
syslog daemon.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
syslog_ident (string)
syslog_ident> configuration parameter
When logging to syslog> is enabled, this parameter
determines the program name used to identify
PostgreSQL messages in
syslog logs. The default is
postgres.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
syslog_sequence_numbers (boolean)
syslog_sequence_numbers> configuration parameter
When logging to syslog and this is on (the
default), then each message will be prefixed by an increasing
sequence number (such as [2]). This circumvents
the --- last message repeated N times --- suppression
that many syslog implementations perform by default. In more modern
syslog implementations, repeated message suppression can be configured
(for example, $RepeatedMsgReduction
in rsyslog), so this might not be
necessary. Also, you could turn this off if you actually want to
suppress repeated messages.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
syslog_split_messages (boolean)
syslog_split_messages> configuration parameter
When logging to syslog> is enabled, this parameter
determines how messages are delivered to syslog. When on (the
default), messages are split by lines, and long lines are split so
that they will fit into 1024 bytes, which is a typical size limit for
traditional syslog implementations. When off, PostgreSQL server log
messages are delivered to the syslog service as is, and it is up to
the syslog service to cope with the potentially bulky messages.
If syslog is ultimately logging to a text file, then the effect will
be the same either way, and it is best to leave the setting on, since
most syslog implementations either cannot handle large messages or
would need to be specially configured to handle them. But if syslog
is ultimately writing into some other medium, it might be necessary or
more useful to keep messages logically together.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
event_source (string)
event_source> configuration parameter
When logging to event log> is enabled, this parameter
determines the program name used to identify
PostgreSQL messages in
the log. The default is PostgreSQL.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
When To Logclient_min_messages (enum)
client_min_messages> configuration parameter
Controls which message levels are sent to the client.
Valid values are DEBUG5>,
DEBUG4>, DEBUG3>, DEBUG2>,
DEBUG1>, LOG>, NOTICE>,
WARNING>, ERROR>, FATAL>,
and PANIC>. Each level
includes all the levels that follow it. The later the level,
the fewer messages are sent. The default is
NOTICE>. Note that LOG> has a different
rank here than in log_min_messages>.
log_min_messages (enum)
log_min_messages> configuration parameter
Controls which message levels are written to the server log.
Valid values are DEBUG5>, DEBUG4>,
DEBUG3>, DEBUG2>, DEBUG1>,
INFO>, NOTICE>, WARNING>,
ERROR>, LOG>, FATAL>, and
PANIC>. Each level includes all the levels that
follow it. The later the level, the fewer messages are sent
to the log. The default is WARNING>. Note that
LOG> has a different rank here than in
client_min_messages>.
Only superusers can change this setting.
log_min_error_statement (enum)
log_min_error_statement> configuration parameter
Controls which SQL statements that cause an error
condition are recorded in the server log. The current
SQL statement is included in the log entry for any message of
the specified severity or higher.
Valid values are DEBUG5,
DEBUG4, DEBUG3,
DEBUG2, DEBUG1,
INFO, NOTICE,
WARNING, ERROR,
LOG,
FATAL, and PANIC.
The default is ERROR, which means statements
causing errors, log messages, fatal errors, or panics will be logged.
To effectively turn off logging of failing statements,
set this parameter to PANIC.
Only superusers can change this setting.
log_min_duration_statement (integer)
log_min_duration_statement> configuration parameter
Causes the duration of each completed statement to be logged
if the statement ran for at least the specified number of
milliseconds. Setting this to zero prints all statement durations.
Minus-one (the default) disables logging statement durations.
For example, if you set it to 250ms
then all SQL statements that run 250ms or longer will be
logged. Enabling this parameter can be helpful in tracking down
unoptimized queries in your applications.
Only superusers can change this setting.
For clients using extended query protocol, durations of the Parse,
Bind, and Execute steps are logged independently.
When using this option together with
,
the text of statements that are logged because of
log_statement> will not be repeated in the
duration log message.
If you are not using syslog>, it is recommended
that you log the PID or session ID using
so that you can link the statement message to the later
duration message using the process ID or session ID.
explains the message
severity levels used by PostgreSQL>. If logging output
is sent to syslog or Windows'
eventlog, the severity levels are translated
as shown in the table.
Message Severity LevelsSeverityUsagesyslog>eventlog>DEBUG1..DEBUG5>Provides successively-more-detailed information for use by
developers.DEBUG>INFORMATION>INFO>Provides information implicitly requested by the user,
e.g., output from VACUUM VERBOSE>.INFO>INFORMATION>NOTICE>Provides information that might be helpful to users, e.g.,
notice of truncation of long identifiers.NOTICE>INFORMATION>WARNING>Provides warnings of likely problems, e.g., COMMIT>
outside a transaction block.NOTICE>WARNING>ERROR>Reports an error that caused the current command to
abort.WARNING>ERROR>LOG>Reports information of interest to administrators, e.g.,
checkpoint activity.INFO>INFORMATION>FATAL>Reports an error that caused the current session to
abort.ERR>ERROR>PANIC>Reports an error that caused all database sessions to abort.CRIT>ERROR>
What To Logapplication_name (string)
application_name> configuration parameter
The application_name can be any string of less than
NAMEDATALEN> characters (64 characters in a standard build).
It is typically set by an application upon connection to the server.
The name will be displayed in the pg_stat_activity> view
and included in CSV log entries. It can also be included in regular
log entries via the parameter.
Only printable ASCII characters may be used in the
application_name value. Other characters will be
replaced with question marks (?).
debug_print_parse (boolean)
debug_print_parse> configuration parameterdebug_print_rewritten (boolean)
debug_print_rewritten> configuration parameterdebug_print_plan (boolean)
debug_print_plan> configuration parameter
These parameters enable various debugging output to be emitted.
When set, they print the resulting parse tree, the query rewriter
output, or the execution plan for each executed query.
These messages are emitted at LOG> message level, so by
default they will appear in the server log but will not be sent to the
client. You can change that by adjusting
and/or
.
These parameters are off by default.
debug_pretty_print (boolean)
debug_pretty_print> configuration parameter
When set, debug_pretty_print indents the messages
produced by debug_print_parse,
debug_print_rewritten, or
debug_print_plan. This results in more readable
but much longer output than the compact> format used when
it is off. It is on by default.
log_checkpoints (boolean)
log_checkpoints> configuration parameter
Causes checkpoints and restartpoints to be logged in the server log.
Some statistics are included in the log messages, including the number
of buffers written and the time spent writing them.
This parameter can only be set in the postgresql.conf>
file or on the server command line. The default is off.
log_connections (boolean)
log_connections> configuration parameter
Causes each attempted connection to the server to be logged,
as well as successful completion of client authentication.
Only superusers can change this parameter at session start,
and it cannot be changed at all within a session.
The default is off>.
Some client programs, like psql>, attempt
to connect twice while determining if a password is required, so
duplicate connection received> messages do not
necessarily indicate a problem.
log_disconnections (boolean)
log_disconnections> configuration parameter
Causes session terminations to be logged. The log output
provides information similar to log_connections,
plus the duration of the session.
Only superusers can change this parameter at session start,
and it cannot be changed at all within a session.
The default is off>.
log_duration (boolean)
log_duration> configuration parameter
Causes the duration of every completed statement to be logged.
The default is off>.
Only superusers can change this setting.
For clients using extended query protocol, durations of the Parse,
Bind, and Execute steps are logged independently.
The difference between setting this option and setting
to zero is that
exceeding log_min_duration_statement> forces the text of
the query to be logged, but this option doesn't. Thus, if
log_duration> is on> and
log_min_duration_statement> has a positive value, all
durations are logged but the query text is included only for
statements exceeding the threshold. This behavior can be useful for
gathering statistics in high-load installations.
log_error_verbosity (enum)
log_error_verbosity> configuration parameter
Controls the amount of detail written in the server log for each
message that is logged. Valid values are TERSE>,
DEFAULT>, and VERBOSE>, each adding more
fields to displayed messages. TERSE> excludes
the logging of DETAIL>, HINT>,
QUERY>, and CONTEXT> error information.
VERBOSE> output includes the SQLSTATE> error
code (see also ) and the source code file name, function name,
and line number that generated the error.
Only superusers can change this setting.
log_hostname (boolean)
log_hostname> configuration parameter
By default, connection log messages only show the IP address of the
connecting host. Turning this parameter on causes logging of the
host name as well. Note that depending on your host name resolution
setup this might impose a non-negligible performance penalty.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
log_line_prefix (string)
log_line_prefix> configuration parameter
This is a printf>-style string that is output at the
beginning of each log line.
%> characters begin escape sequences>
that are replaced with status information as outlined below.
Unrecognized escapes are ignored. Other
characters are copied straight to the log line. Some escapes are
only recognized by session processes, and will be treated as empty by
background processes such as the main server process. Status
information may be aligned either left or right by specifying a
numeric literal after the % and before the option. A negative
value will cause the status information to be padded on the
right with spaces to give it a minimum width, whereas a positive
value will pad on the left. Padding can be useful to aid human
readability in log files.
This parameter can only be set in the postgresql.conf>
file or on the server command line. The default is an empty string.
EscapeEffectSession only%aApplication nameyes%uUser nameyes%dDatabase nameyes%rRemote host name or IP address, and remote portyes%hRemote host name or IP addressyes%pProcess IDno%tTime stamp without millisecondsno%mTime stamp with millisecondsno%nTime stamp with milliseconds (as a Unix epoch)no%iCommand tag: type of session's current commandyes%eSQLSTATE error codeno%cSession ID: see belowno%lNumber of the log line for each session or process, starting at 1no%sProcess start time stampno%vVirtual transaction ID (backendID/localXID)no%xTransaction ID (0 if none is assigned)no%qProduces no output, but tells non-session
processes to stop at this point in the string; ignored by
session processesno%%Literal %>no
The %c> escape prints a quasi-unique session identifier,
consisting of two 4-byte hexadecimal numbers (without leading zeros)
separated by a dot. The numbers are the process start time and the
process ID, so %c> can also be used as a space saving way
of printing those items. For example, to generate the session
identifier from pg_stat_activity>, use this query:
SELECT to_hex(trunc(EXTRACT(EPOCH FROM backend_start))::integer) || '.' ||
to_hex(pid)
FROM pg_stat_activity;
If you set a nonempty value for log_line_prefix>,
you should usually make its last character be a space, to provide
visual separation from the rest of the log line. A punctuation
character can be used too.
Syslog> produces its own
time stamp and process ID information, so you probably do not want to
include those escapes if you are logging to syslog>.
log_lock_waits (boolean)
log_lock_waits> configuration parameter
Controls whether a log message is produced when a session waits
longer than to acquire a
lock. This is useful in determining if lock waits are causing
poor performance. The default is off>.
log_statement (enum)
log_statement> configuration parameter
Controls which SQL statements are logged. Valid values are
none> (off), ddl>, mod>, and
all> (all statements). ddl> logs all data definition
statements, such as CREATE>, ALTER>, and
DROP> statements. mod> logs all
ddl> statements, plus data-modifying statements
such as INSERT>,
UPDATE>, DELETE>, TRUNCATE>,
and COPY FROM>.
PREPARE>, EXECUTE>, and
EXPLAIN ANALYZE> statements are also logged if their
contained command is of an appropriate type. For clients using
extended query protocol, logging occurs when an Execute message
is received, and values of the Bind parameters are included
(with any embedded single-quote marks doubled).
The default is none>. Only superusers can change this
setting.
Statements that contain simple syntax errors are not logged
even by the log_statement> = all> setting,
because the log message is emitted only after basic parsing has
been done to determine the statement type. In the case of extended
query protocol, this setting likewise does not log statements that
fail before the Execute phase (i.e., during parse analysis or
planning). Set log_min_error_statement> to
ERROR> (or lower) to log such statements.
log_replication_commands (boolean)
log_replication_commands> configuration parameter
Causes each replication command to be logged in the server log.
See for more information about
replication command. The default value is off>.
Only superusers can change this setting.
log_temp_files (integer)
log_temp_files> configuration parameter
Controls logging of temporary file names and sizes.
Temporary files can be
created for sorts, hashes, and temporary query results.
A log entry is made for each temporary file when it is deleted.
A value of zero logs all temporary file information, while positive
values log only files whose size is greater than or equal to
the specified number of kilobytes. The
default setting is -1, which disables such logging.
Only superusers can change this setting.
log_timezone (string)
log_timezone> configuration parameter
Sets the time zone used for timestamps written in the server log.
Unlike , this value is cluster-wide,
so that all sessions will report timestamps consistently.
The built-in default is GMT>, but that is typically
overridden in postgresql.conf>; initdb>
will install a setting there corresponding to its system environment.
See for more information.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
Using CSV-Format Log Output
Including csvlog> in the log_destination> list
provides a convenient way to import log files into a database table.
This option emits log lines in comma-separated-values
(CSV>) format,
with these columns:
time stamp with milliseconds,
user name,
database name,
process ID,
client host:port number,
session ID,
per-session line number,
command tag,
session start time,
virtual transaction ID,
regular transaction ID,
error severity,
SQLSTATE code,
error message,
error message detail,
hint,
internal query that led to the error (if any),
character count of the error position therein,
error context,
user query that led to the error (if any and enabled by
log_min_error_statement>),
character count of the error position therein,
location of the error in the PostgreSQL source code
(if log_error_verbosity> is set to verbose>),
and application name.
Here is a sample table definition for storing CSV-format log output:
CREATE TABLE postgres_log
(
log_time timestamp(3) with time zone,
user_name text,
database_name text,
process_id integer,
connection_from text,
session_id text,
session_line_num bigint,
command_tag text,
session_start_time timestamp with time zone,
virtual_transaction_id text,
transaction_id bigint,
error_severity text,
sql_state_code text,
message text,
detail text,
hint text,
internal_query text,
internal_query_pos integer,
context text,
query text,
query_pos integer,
location text,
application_name text,
PRIMARY KEY (session_id, session_line_num)
);
To import a log file into this table, use the COPY FROM>
command:
COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
There are a few things you need to do to simplify importing CSV log
files:
Set log_filename and
log_rotation_age> to provide a consistent,
predictable naming scheme for your log files. This lets you
predict what the file name will be and know when an individual log
file is complete and therefore ready to be imported.
Set log_rotation_size to 0 to disable
size-based log rotation, as it makes the log file name difficult
to predict.
Set log_truncate_on_rotation to on> so
that old log data isn't mixed with the new in the same file.
The table definition above includes a primary key specification.
This is useful to protect against accidentally importing the same
information twice. The COPY> command commits all of the
data it imports at one time, so any error will cause the entire
import to fail. If you import a partial log file and later import
the file again when it is complete, the primary key violation will
cause the import to fail. Wait until the log is complete and
closed before importing. This procedure will also protect against
accidentally importing a partial line that hasn't been completely
written, which would also cause COPY> to fail.
Process Title
These settings control how the process title as seen
by ps is modified. See
for details.
cluster_name (string)
cluster_name> configuration parameter
Sets the cluster name that appears in the process title for all
processes in this cluster. The name can be any string of less than
NAMEDATALEN> characters (64 characters in a standard
build). Only printable ASCII characters may be used in the
cluster_name value. Other characters will be
replaced with question marks (?). No name is shown
if this parameter is set to the empty string ''> (which is
the default). This parameter can only be set at server start.
The process title is typically viewed using programs like
ps> or, on Windows, Process Explorer>.
update_process_title (boolean)
update_process_title> configuration parameter
Enables updating of the process title every time a new SQL command
is received by the server. The process title is typically viewed
by the ps> command,
or in Windows by using the Process Explorer>.
Only superusers can change this setting.
Run-time StatisticsQuery and Index Statistics Collector
These parameters control server-wide statistics collection features.
When statistics collection is enabled, the data that is produced can be
accessed via the pg_stat and
pg_statio family of system views.
Refer to for more information.
track_activities (boolean)
track_activities> configuration parameter
Enables the collection of information on the currently
executing command of each session, along with the time when
that command began execution. This parameter is on by
default. Note that even when enabled, this information is not
visible to all users, only to superusers and the user owning
the session being reported on, so it should not represent a
security risk.
Only superusers can change this setting.
track_activity_query_size (integer)
track_activity_query_size> configuration parameter
Specifies the number of bytes reserved to track the currently
executing command for each active session, for the
pg_stat_activity>.query> field.
The default value is 1024. This parameter can only be set at server
start.
track_counts (boolean)
track_counts> configuration parameter
Enables collection of statistics on database activity.
This parameter is on by default, because the autovacuum
daemon needs the collected information.
Only superusers can change this setting.
track_io_timing (boolean)
track_io_timing> configuration parameter
Enables timing of database I/O calls. This parameter is off by
default, because it will repeatedly query the operating system for
the current time, which may cause significant overhead on some
platforms. You can use the tool to
measure the overhead of timing on your system.
I/O timing information is
displayed in , in the output of
when the BUFFERS> option is
used, and by . Only superusers can
change this setting.
track_functions (enum)
track_functions> configuration parameter
Enables tracking of function call counts and time used. Specify
pl to track only procedural-language functions,
all to also track SQL and C language functions.
The default is none, which disables function
statistics tracking. Only superusers can change this setting.
SQL-language functions that are simple enough to be inlined>
into the calling query will not be tracked, regardless of this
setting.
stats_temp_directory (string)
stats_temp_directory> configuration parameter
Sets the directory to store temporary statistics data in. This can be
a path relative to the data directory or an absolute path. The default
is pg_stat_tmp. Pointing this at a RAM-based
file system will decrease physical I/O requirements and can lead to
improved performance.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
Statistics Monitoringlog_statement_stats (boolean)
log_statement_stats> configuration parameterlog_parser_stats (boolean)
log_parser_stats> configuration parameterlog_planner_stats (boolean)
log_planner_stats> configuration parameterlog_executor_stats (boolean)
log_executor_stats> configuration parameter
For each query, output performance statistics of the respective
module to the server log. This is a crude profiling
instrument, similar to the Unix getrusage()> operating
system facility. log_statement_stats reports total
statement statistics, while the others report per-module statistics.
log_statement_stats cannot be enabled together with
any of the per-module options. All of these options are disabled by
default. Only superusers can change these settings.
Automatic Vacuumingautovacuumconfiguration parameters
These settings control the behavior of the autovacuum>
feature. Refer to for more information.
Note that many of these settings can be overridden on a per-table
basis; see .
autovacuum (boolean)
autovacuum> configuration parameter
Controls whether the server should run the
autovacuum launcher daemon. This is on by default; however,
must also be enabled for
autovacuum to work.
This parameter can only be set in the postgresql.conf>
file or on the server command line; however, autovacuuming can be
disabled for individual tables by changing table storage parameters.
Note that even when this parameter is disabled, the system
will launch autovacuum processes if necessary to
prevent transaction ID wraparound. See for more information.
log_autovacuum_min_duration (integer)
log_autovacuum_min_duration> configuration parameter
Causes each action executed by autovacuum to be logged if it ran for at
least the specified number of milliseconds. Setting this to zero logs
all autovacuum actions. Minus-one (the default) disables logging
autovacuum actions. For example, if you set this to
250ms then all automatic vacuums and analyzes that run
250ms or longer will be logged. In addition, when this parameter is
set to any value other than -1, a message will be
logged if an autovacuum action is skipped due to the existence of a
conflicting lock. Enabling this parameter can be helpful
in tracking autovacuum activity. This parameter can only be set in
the postgresql.conf> file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
autovacuum_max_workers (integer)
autovacuum_max_workers> configuration parameter
Specifies the maximum number of autovacuum processes (other than the
autovacuum launcher) that may be running at any one time. The default
is three. This parameter can only be set at server start.
autovacuum_naptime (integer)
autovacuum_naptime> configuration parameter
Specifies the minimum delay between autovacuum runs on any given
database. In each round the daemon examines the
database and issues VACUUM> and ANALYZE> commands
as needed for tables in that database. The delay is measured
in seconds, and the default is one minute (1min>).
This parameter can only be set in the postgresql.conf>
file or on the server command line.
autovacuum_vacuum_threshold (integer)
autovacuum_vacuum_threshold> configuration parameter
Specifies the minimum number of updated or deleted tuples needed
to trigger a VACUUM> in any one table.
The default is 50 tuples.
This parameter can only be set in the postgresql.conf>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
autovacuum_analyze_threshold (integer)
autovacuum_analyze_threshold> configuration parameter
Specifies the minimum number of inserted, updated or deleted tuples
needed to trigger an ANALYZE> in any one table.
The default is 50 tuples.
This parameter can only be set in the postgresql.conf>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
autovacuum_vacuum_scale_factor (floating point)
autovacuum_vacuum_scale_factor> configuration parameter
Specifies a fraction of the table size to add to
autovacuum_vacuum_threshold
when deciding whether to trigger a VACUUM>.
The default is 0.2 (20% of table size).
This parameter can only be set in the postgresql.conf>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
autovacuum_analyze_scale_factor (floating point)
autovacuum_analyze_scale_factor> configuration parameter
Specifies a fraction of the table size to add to
autovacuum_analyze_threshold
when deciding whether to trigger an ANALYZE>.
The default is 0.1 (10% of table size).
This parameter can only be set in the postgresql.conf>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
autovacuum_freeze_max_age (integer)
autovacuum_freeze_max_age> configuration parameter
Specifies the maximum age (in transactions) that a table's
pg_class>.relfrozenxid> field can
attain before a VACUUM> operation is forced
to prevent transaction ID wraparound within the table.
Note that the system will launch autovacuum processes to
prevent wraparound even when autovacuum is otherwise disabled.
Vacuum also allows removal of old files from the
pg_clog> subdirectory, which is why the default
is a relatively low 200 million transactions.
This parameter can only be set at server start, but the setting
can be reduced for individual tables by
changing table storage parameters.
For more information see .
autovacuum_multixact_freeze_max_age (integer)
autovacuum_multixact_freeze_max_age configuration parameter
Specifies the maximum age (in multixacts) that a table's
pg_class>.relminmxid> field can
attain before a VACUUM> operation is forced to
prevent multixact ID wraparound within the table.
Note that the system will launch autovacuum processes to
prevent wraparound even when autovacuum is otherwise disabled.
Vacuuming multixacts also allows removal of old files from the
pg_multixact/members> and pg_multixact/offsets>
subdirectories, which is why the default is a relatively low
400 million multixacts.
This parameter can only be set at server start, but the setting can
be reduced for individual tables by changing table storage parameters.
For more information see .
autovacuum_vacuum_cost_delay (integer)
autovacuum_vacuum_cost_delay> configuration parameter
Specifies the cost delay value that will be used in automatic
VACUUM> operations. If -1 is specified, the regular
value will be used.
The default value is 20 milliseconds.
This parameter can only be set in the postgresql.conf>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
autovacuum_vacuum_cost_limit (integer)
autovacuum_vacuum_cost_limit> configuration parameter
Specifies the cost limit value that will be used in automatic
VACUUM> operations. If -1 is specified (which is the
default), the regular
value will be used. Note that
the value is distributed proportionally among the running autovacuum
workers, if there is more than one, so that the sum of the limits for
each worker does not exceed the value of this variable.
This parameter can only be set in the postgresql.conf>
file or on the server command line;
but the setting can be overridden for individual tables by
changing table storage parameters.
Client Connection DefaultsStatement Behaviorsearch_path (string)
search_path> configuration parameterpath>for schemas>>
This variable specifies the order in which schemas are searched
when an object (table, data type, function, etc.) is referenced by a
simple name with no schema specified. When there are objects of
identical names in different schemas, the one found first
in the search path is used. An object that is not in any of the
schemas in the search path can only be referenced by specifying
its containing schema with a qualified (dotted) name.
The value for search_path must be a comma-separated
list of schema names. Any name that is not an existing schema, or is
a schema for which the user does not have USAGE>
permission, is silently ignored.
If one of the list items is the special name
$user, then the schema having the name returned by
SESSION_USER> is substituted, if there is such a schema
and the user has USAGE> permission for it.
(If not, $user is ignored.)
The system catalog schema, pg_catalog>, is always
searched, whether it is mentioned in the path or not. If it is
mentioned in the path then it will be searched in the specified
order. If pg_catalog> is not in the path then it will
be searched before> searching any of the path items.
Likewise, the current session's temporary-table schema,
pg_temp_nnn>>, is always searched if it
exists. It can be explicitly listed in the path by using the
alias pg_temp>pg_temp>>. If it is not listed in the path then
it is searched first (even before pg_catalog>). However,
the temporary schema is only searched for relation (table, view,
sequence, etc) and data type names. It is never searched for
function or operator names.
When objects are created without specifying a particular target
schema, they will be placed in the first valid schema named in
search_path. An error is reported if the search
path is empty.
The default value for this parameter is
"$user", public.
This setting supports shared use of a database (where no users
have private schemas, and all share use of public>),
private per-user schemas, and combinations of these. Other
effects can be obtained by altering the default search path
setting, either globally or per-user.
The current effective value of the search path can be examined
via the SQL function
current_schemas>
(see ).
This is not quite the same as
examining the value of search_path, since
current_schemas> shows how the items
appearing in search_path were resolved.
For more information on schema handling, see .
row_security (boolean)
row_security> configuration parameter
This variable controls whether to raise an error in lieu of applying a
row security policy. When set to on>, policies apply
normally. When set to off>, queries fail which would
otherwise apply at least one policy. The default is on>.
Change to off> where limited row visibility could cause
incorrect results; for example, pg_dump> makes that
change by default. This variable has no effect on roles which bypass
every row security policy, to wit, superusers and roles with
the BYPASSRLS> attribute.
For more information on row security policies,
see .
default_tablespace (string)
default_tablespace> configuration parametertablespace>default>>
This variable specifies the default tablespace in which to create
objects (tables and indexes) when a CREATE> command does
not explicitly specify a tablespace.
The value is either the name of a tablespace, or an empty string
to specify using the default tablespace of the current database.
If the value does not match the name of any existing tablespace,
PostgreSQL> will automatically use the default
tablespace of the current database. If a nondefault tablespace
is specified, the user must have CREATE> privilege
for it, or creation attempts will fail.
This variable is not used for temporary tables; for them,
is consulted instead.
This variable is also not used when creating databases.
By default, a new database inherits its tablespace setting from
the template database it is copied from.
For more information on tablespaces,
see .
temp_tablespaces (string)
temp_tablespaces> configuration parametertablespace>temporary>>
This variable specifies tablespaces in which to create temporary
objects (temp tables and indexes on temp tables) when a
CREATE> command does not explicitly specify a tablespace.
Temporary files for purposes such as sorting large data sets
are also created in these tablespaces.
The value is a list of names of tablespaces. When there is more than
one name in the list, PostgreSQL> chooses a random
member of the list each time a temporary object is to be created;
except that within a transaction, successively created temporary
objects are placed in successive tablespaces from the list.
If the selected element of the list is an empty string,
PostgreSQL> will automatically use the default
tablespace of the current database instead.
When temp_tablespaces> is set interactively, specifying a
nonexistent tablespace is an error, as is specifying a tablespace for
which the user does not have CREATE> privilege. However,
when using a previously set value, nonexistent tablespaces are
ignored, as are tablespaces for which the user lacks
CREATE> privilege. In particular, this rule applies when
using a value set in postgresql.conf>.
The default value is an empty string, which results in all temporary
objects being created in the default tablespace of the current
database.
See also .
check_function_bodies (boolean)
check_function_bodies> configuration parameter
This parameter is normally on. When set to off>, it
disables validation of the function body string during . Disabling validation avoids side
effects of the validation process and avoids false positives due
to problems such as forward references. Set this parameter
to off> before loading functions on behalf of other
users; pg_dump> does so automatically.
default_transaction_isolation (enum)
transaction isolation levelsetting defaultdefault_transaction_isolation> configuration parameter
Each SQL transaction has an isolation level, which can be
either read uncommitted, read
committed, repeatable read, or
serializable. This parameter controls the
default isolation level of each new transaction. The default
is read committed.
Consult and for more information.
default_transaction_read_only (boolean)
read-only transactionsetting defaultdefault_transaction_read_only> configuration parameter
A read-only SQL transaction cannot alter non-temporary tables.
This parameter controls the default read-only status of each new
transaction. The default is off> (read/write).
Consult for more information.
default_transaction_deferrable (boolean)
deferrable transactionsetting defaultdefault_transaction_deferrable> configuration parameter
When running at the serializable> isolation level,
a deferrable read-only SQL transaction may be delayed before
it is allowed to proceed. However, once it begins executing
it does not incur any of the overhead required to ensure
serializability; so serialization code will have no reason to
force it to abort because of concurrent updates, making this
option suitable for long-running read-only transactions.
This parameter controls the default deferrable status of each
new transaction. It currently has no effect on read-write
transactions or those operating at isolation levels lower
than serializable>. The default is off>.
Consult for more information.
session_replication_role (enum)
session_replication_role> configuration parameter
Controls firing of replication-related triggers and rules for the
current session. Setting this variable requires
superuser privilege and results in discarding any previously cached
query plans. Possible values are origin> (the default),
replica> and local>.
See for
more information.
statement_timeout (integer)
statement_timeout> configuration parameter
Abort any statement that takes more than the specified number of
milliseconds, starting from the time the command arrives at the server
from the client. If log_min_error_statement> is set to
ERROR> or lower, the statement that timed out will also be
logged. A value of zero (the default) turns this off.
Setting statement_timeout> in
postgresql.conf> is not recommended because it would
affect all sessions.
lock_timeout (integer)
lock_timeout> configuration parameter
Abort any statement that waits longer than the specified number of
milliseconds while attempting to acquire a lock on a table, index,
row, or other database object. The time limit applies separately to
each lock acquisition attempt. The limit applies both to explicit
locking requests (such as LOCK TABLE>, or SELECT
FOR UPDATE> without NOWAIT>) and to implicitly-acquired
locks. If log_min_error_statement> is set to
ERROR> or lower, the statement that timed out will be
logged. A value of zero (the default) turns this off.
Unlike statement_timeout>, this timeout can only occur
while waiting for locks. Note that if statement_timeout>
is nonzero, it is rather pointless to set lock_timeout> to
the same or larger value, since the statement timeout would always
trigger first.
Setting lock_timeout> in
postgresql.conf> is not recommended because it would
affect all sessions.
idle_in_transaction_session_timeout (integer)
idle_in_transaction_session_timeout> configuration parameter
Terminate any session with an open transaction that has been idle for
longer than the specified duration in milliseconds. This allows any
locks held by that session to be released and the connection slot to be reused;
it also allows tuples visible only to this transaction to be vacuumed. See
for more details about this.
The default value of 0 disables this feature.
vacuum_freeze_table_age (integer)
vacuum_freeze_table_age> configuration parameterVACUUM> performs an aggressive scan if the table's
pg_class>.relfrozenxid> field has reached
the age specified by this setting. An aggressive scan differs from
a regular VACUUM> in that it visits every page that might
contain unfrozen XIDs or MXIDs, not just those that might contain dead
tuples. The default is 150 million transactions. Although users can
set this value anywhere from zero to two billions, VACUUM>
will silently limit the effective value to 95% of
, so that a
periodical manual VACUUM> has a chance to run before an
anti-wraparound autovacuum is launched for the table. For more
information see
.
vacuum_freeze_min_age (integer)
vacuum_freeze_min_age> configuration parameter
Specifies the cutoff age (in transactions) that VACUUM>
should use to decide whether to freeze row versions
while scanning a table.
The default is 50 million transactions. Although
users can set this value anywhere from zero to one billion,
VACUUM> will silently limit the effective value to half
the value of , so
that there is not an unreasonably short time between forced
autovacuums. For more information see .
vacuum_multixact_freeze_table_age (integer)
vacuum_multixact_freeze_table_age> configuration parameterVACUUM> performs an aggressive scan if the table's
pg_class>.relminmxid> field has reached
the age specified by this setting. An aggressive scan differs from
a regular VACUUM> in that it visits every page that might
contain unfrozen XIDs or MXIDs, not just those that might contain dead
tuples. The default is 150 million multixacts.
Although users can set this value anywhere from zero to two billions,
VACUUM> will silently limit the effective value to 95% of
, so that a
periodical manual VACUUM> has a chance to run before an
anti-wraparound is launched for the table.
For more information see .
vacuum_multixact_freeze_min_age (integer)
vacuum_multixact_freeze_min_age> configuration parameter
Specifies the cutoff age (in multixacts) that VACUUM>
should use to decide whether to replace multixact IDs with a newer
transaction ID or multixact ID while scanning a table. The default
is 5 million multixacts.
Although users can set this value anywhere from zero to one billion,
VACUUM> will silently limit the effective value to half
the value of ,
so that there is not an unreasonably short time between forced
autovacuums.
For more information see .
bytea_output (enum)
bytea_output> configuration parameter
Sets the output format for values of type bytea.
Valid values are hex (the default)
and escape (the traditional PostgreSQL
format). See for more
information. The bytea type always
accepts both formats on input, regardless of this setting.
xmlbinary (enum)
xmlbinary> configuration parameter
Sets how binary values are to be encoded in XML. This applies
for example when bytea values are converted to
XML by the functions xmlelement or
xmlforest. Possible values are
base64 and hex, which
are both defined in the XML Schema standard. The default is
base64. For further information about
XML-related functions, see .
The actual choice here is mostly a matter of taste,
constrained only by possible restrictions in client
applications. Both methods support all possible values,
although the hex encoding will be somewhat larger than the
base64 encoding.
xmloption (enum)
xmloption> configuration parameterSET XML OPTION>XML option
Sets whether DOCUMENT or
CONTENT is implicit when converting between
XML and character string values. See for a description of this. Valid
values are DOCUMENT and
CONTENT. The default is
CONTENT.
According to the SQL standard, the command to set this option is
SET XML OPTION { DOCUMENT | CONTENT };
This syntax is also available in PostgreSQL.
gin_pending_list_limit (integer)
gin_pending_list_limit> configuration parameter
Sets the maximum size of the GIN pending list which is used
when fastupdate> is enabled. If the list grows
larger than this maximum size, it is cleaned up by moving
the entries in it to the main GIN data structure in bulk.
The default is four megabytes (4MB>). This setting
can be overridden for individual GIN indexes by changing
index storage parameters.
See and
for more information.
Locale and FormattingDateStyle (string)
DateStyle> configuration parameter
Sets the display format for date and time values, as well as the
rules for interpreting ambiguous date input values. For
historical reasons, this variable contains two independent
components: the output format specification (ISO>,
Postgres>, SQL>, or German>)
and the input/output specification for year/month/day ordering
(DMY>, MDY>, or YMD>). These
can be set separately or together. The keywords Euro>
and European> are synonyms for DMY>; the
keywords US>, NonEuro>, and
NonEuropean> are synonyms for MDY>. See
for more information. The
built-in default is ISO, MDY>, but
initdb will initialize the
configuration file with a setting that corresponds to the
behavior of the chosen lc_time locale.
IntervalStyle (enum)
IntervalStyle> configuration parameter
Sets the display format for interval values.
The value sql_standard> will produce
output matching SQL standard interval literals.
The value postgres> (which is the default) will produce
output matching PostgreSQL> releases prior to 8.4
when the
parameter was set to ISO>.
The value postgres_verbose> will produce output
matching PostgreSQL> releases prior to 8.4
when the DateStyle>
parameter was set to non-ISO> output.
The value iso_8601> will produce output matching the time
interval format with designators> defined in section
4.4.3.2 of ISO 8601.
The IntervalStyle> parameter also affects the
interpretation of ambiguous interval input. See
for more information.
TimeZone (string)
TimeZone> configuration parametertime zone>>
Sets the time zone for displaying and interpreting time stamps.
The built-in default is GMT>, but that is typically
overridden in postgresql.conf>; initdb>
will install a setting there corresponding to its system environment.
See for more information.
timezone_abbreviations (string)
timezone_abbreviations> configuration parametertime zone names>>
Sets the collection of time zone abbreviations that will be accepted
by the server for datetime input. The default is 'Default'>,
which is a collection that works in most of the world; there are
also 'Australia' and 'India',
and other collections can be defined for a particular installation.
See for more information.
extra_float_digits (integer)
significant digitsfloating-pointdisplayextra_float_digits> configuration parameter
This parameter adjusts the number of digits displayed for
floating-point values, including float4>, float8>,
and geometric data types. The parameter value is added to the
standard number of digits (FLT_DIG> or DBL_DIG>
as appropriate). The value can be set as high as 3, to include
partially-significant digits; this is especially useful for dumping
float data that needs to be restored exactly. Or it can be set
negative to suppress unwanted digits.
See also .
client_encoding (string)
client_encoding> configuration parametercharacter set>>
Sets the client-side encoding (character set).
The default is to use the database encoding.
The character sets supported by the PostgreSQL
server are described in .
lc_messages (string)
lc_messages> configuration parameter
Sets the language in which messages are displayed. Acceptable
values are system-dependent; see for
more information. If this variable is set to the empty string
(which is the default) then the value is inherited from the
execution environment of the server in a system-dependent way.
On some systems, this locale category does not exist. Setting
this variable will still work, but there will be no effect.
Also, there is a chance that no translated messages for the
desired language exist. In that case you will continue to see
the English messages.
Only superusers can change this setting, because it affects the
messages sent to the server log as well as to the client, and
an improper value might obscure the readability of the server
logs.
lc_monetary (string)
lc_monetary> configuration parameter
Sets the locale to use for formatting monetary amounts, for
example with the to_char family of
functions. Acceptable values are system-dependent; see for more information. If this variable is
set to the empty string (which is the default) then the value
is inherited from the execution environment of the server in a
system-dependent way.
lc_numeric (string)
lc_numeric> configuration parameter
Sets the locale to use for formatting numbers, for example
with the to_char family of
functions. Acceptable values are system-dependent; see for more information. If this variable is
set to the empty string (which is the default) then the value
is inherited from the execution environment of the server in a
system-dependent way.
lc_time (string)
lc_time> configuration parameter
Sets the locale to use for formatting dates and times, for example
with the to_char family of
functions. Acceptable values are system-dependent; see for more information. If this variable is
set to the empty string (which is the default) then the value
is inherited from the execution environment of the server in a
system-dependent way.
default_text_search_config (string)
default_text_search_config> configuration parameter
Selects the text search configuration that is used by those variants
of the text search functions that do not have an explicit argument
specifying the configuration.
See for further information.
The built-in default is pg_catalog.simple>, but
initdb will initialize the
configuration file with a setting that corresponds to the
chosen lc_ctype locale, if a configuration
matching that locale can be identified.
Shared Library Preloading
Several settings are available for preloading shared libraries into the
server, in order to load additional functionality or achieve performance
benefits. For example, a setting of
'$libdir/mylib' would cause
mylib.so> (or on some platforms,
mylib.sl>) to be preloaded from the installation's standard
library directory. The differences between the settings are when they
take effect and what privileges are required to change them.
PostgreSQL procedural language libraries can
be preloaded in this way, typically by using the
syntax '$libdir/plXXX' where
XXX is pgsql>, perl>,
tcl>, or python>.
For each parameter, if more than one library is to be loaded, separate
their names with commas. All library names are converted to lower case
unless double-quoted.
Only shared libraries specifically intended to be used with PostgreSQL
can be loaded this way. Every PostgreSQL-supported library has
a magic block> that is checked to guarantee compatibility. For
this reason, non-PostgreSQL libraries cannot be loaded in this way. You
might be able to use operating-system facilities such
as LD_PRELOAD for that.
In general, refer to the documentation of a specific module for the
recommended way to load that module.
local_preload_libraries (string)
local_preload_libraries> configuration parameter$libdir/plugins>
This variable specifies one or more shared libraries that are to be
preloaded at connection start.
The parameter value only takes effect at the start of the connection.
Subsequent changes have no effect. If a specified library is not
found, the connection attempt will fail.
This option can be set by any user. Because of that, the libraries
that can be loaded are restricted to those appearing in the
plugins> subdirectory of the installation's
standard library directory. (It is the database administrator's
responsibility to ensure that only safe> libraries
are installed there.) Entries in local_preload_libraries>
can specify this directory explicitly, for example
$libdir/plugins/mylib, or just specify
the library name — mylib would have
the same effect as $libdir/plugins/mylib.
The intent of this feature is to allow unprivileged users to load
debugging or performance-measurement libraries into specific sessions
without requiring an explicit LOAD> command. To that end,
it would be typical to set this parameter using
the PGOPTIONS environment variable on the client or by
using
ALTER ROLE SET>.
However, unless a module is specifically designed to be used in this way by
non-superusers, this is usually not the right setting to use. Look
at instead.
session_preload_libraries (string)
session_preload_libraries> configuration parameter
This variable specifies one or more shared libraries that are to be
preloaded at connection start. Only superusers can change this setting.
The parameter value only takes effect at the start of the connection.
Subsequent changes have no effect. If a specified library is not
found, the connection attempt will fail.
The intent of this feature is to allow debugging or
performance-measurement libraries to be loaded into specific sessions
without an explicit
LOAD> command being given. For
example, could be enabled for all
sessions under a given user name by setting this parameter
with ALTER ROLE SET>. Also, this parameter can be changed
without restarting the server (but changes only take effect when a new
session is started), so it is easier to add new modules this way, even
if they should apply to all sessions.
Unlike , there is no large
performance advantage to loading a library at session start rather than
when it is first used. There is some advantage, however, when
connection pooling is used.
shared_preload_libraries (string)
shared_preload_libraries> configuration parameter
This variable specifies one or more shared libraries to be preloaded at
server start. This parameter can only be set at server
start. If a specified library is not found, the server will fail to
start.
Some libraries need to perform certain operations that can only take
place at postmaster start, such as allocating shared memory, reserving
light-weight locks, or starting background workers. Those libraries
must be loaded at server start through this parameter. See the
documentation of each library for details.
Other libraries can also be preloaded. By preloading a shared library,
the library startup time is avoided when the library is first used.
However, the time to start each new server process might increase
slightly, even if that process never uses the library. So this
parameter is recommended only for libraries that will be used in most
sessions. Also, changing this parameter requires a server restart, so
this is not the right setting to use for short-term debugging tasks,
say. Use for that
instead.
On Windows hosts, preloading a library at server start will not reduce
the time required to start each new server process; each server process
will re-load all preload libraries. However, shared_preload_libraries
is still useful on Windows hosts for libraries that need to
perform operations at postmaster start time.
Other Defaultsdynamic_library_path (string)
dynamic_library_path> configuration parameterdynamic loading>>
If a dynamically loadable module needs to be opened and the
file name specified in the CREATE FUNCTION or
LOAD command
does not have a directory component (i.e., the
name does not contain a slash), the system will search this
path for the required file.
The value for dynamic_library_path must be a
list of absolute directory paths separated by colons (or semi-colons
on Windows). If a list element starts
with the special string $libdir, the
compiled-in PostgreSQL package
library directory is substituted for $libdir; this
is where the modules provided by the standard
PostgreSQL distribution are installed.
(Use pg_config --pkglibdir to find out the name of
this directory.) For example:
dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
or, in a Windows environment:
dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
The default value for this parameter is
'$libdir'. If the value is set to an empty
string, the automatic path search is turned off.
This parameter can be changed at run time by superusers, but a
setting done that way will only persist until the end of the
client connection, so this method should be reserved for
development purposes. The recommended way to set this parameter
is in the postgresql.conf configuration
file.
gin_fuzzy_search_limit (integer)
gin_fuzzy_search_limit> configuration parameter
Soft upper limit of the size of the set returned by GIN index scans. For more
information see .
Lock Managementdeadlock_timeout (integer)
deadlocktimeout duringtimeoutdeadlockdeadlock_timeout> configuration parameter
This is the amount of time, in milliseconds, to wait on a lock
before checking to see if there is a deadlock condition. The
check for deadlock is relatively expensive, so the server doesn't run
it every time it waits for a lock. We optimistically assume
that deadlocks are not common in production applications and
just wait on the lock for a while before checking for a
deadlock. Increasing this value reduces the amount of time
wasted in needless deadlock checks, but slows down reporting of
real deadlock errors. The default is one second (1s>),
which is probably about the smallest value you would want in
practice. On a heavily loaded server you might want to raise it.
Ideally the setting should exceed your typical transaction time,
so as to improve the odds that a lock will be released before
the waiter decides to check for deadlock. Only superusers can change
this setting.
When is set,
this parameter also determines the length of time to wait before
a log message is issued about the lock wait. If you are trying
to investigate locking delays you might want to set a shorter than
normal deadlock_timeout.
max_locks_per_transaction (integer)
max_locks_per_transaction> configuration parameter
The shared lock table tracks locks on
max_locks_per_transaction * ( + ) objects (e.g., tables);
hence, no more than this many distinct objects can be locked at
any one time. This parameter controls the average number of object
locks allocated for each transaction; individual transactions
can lock more objects as long as the locks of all transactions
fit in the lock table. This is not> the number of
rows that can be locked; that value is unlimited. The default,
64, has historically proven sufficient, but you might need to
raise this value if you have queries that touch many different
tables in a single transaction, e.g. query of a parent table with
many children. This parameter can only be set at server start.
When running a standby server, you must set this parameter to the
same or higher value than on the master server. Otherwise, queries
will not be allowed in the standby server.
max_pred_locks_per_transaction (integer)
max_pred_locks_per_transaction> configuration parameter
The shared predicate lock table tracks locks on
max_pred_locks_per_transaction * ( + ) objects (e.g., tables);
hence, no more than this many distinct objects can be locked at
any one time. This parameter controls the average number of object
locks allocated for each transaction; individual transactions
can lock more objects as long as the locks of all transactions
fit in the lock table. This is not> the number of
rows that can be locked; that value is unlimited. The default,
64, has generally been sufficient in testing, but you might need to
raise this value if you have clients that touch many different
tables in a single serializable transaction. This parameter can
only be set at server start.
Version and Platform CompatibilityPrevious PostgreSQL Versionsarray_nulls (boolean)
array_nulls> configuration parameter
This controls whether the array input parser recognizes
unquoted NULL> as specifying a null array element.
By default, this is on>, allowing array values containing
null values to be entered. However, PostgreSQL> versions
before 8.2 did not support null values in arrays, and therefore would
treat NULL> as specifying a normal array element with
the string value NULL>. For backward compatibility with
applications that require the old behavior, this variable can be
turned off>.
Note that it is possible to create array values containing null values
even when this variable is off>.
backslash_quote (enum)
strings>backslash quotes>>
backslash_quote> configuration parameter
This controls whether a quote mark can be represented by
\'> in a string literal. The preferred, SQL-standard way
to represent a quote mark is by doubling it (''>) but
PostgreSQL> has historically also accepted
\'>. However, use of \'> creates security risks
because in some client character set encodings, there are multibyte
characters in which the last byte is numerically equivalent to ASCII
\>. If client-side code does escaping incorrectly then a
SQL-injection attack is possible. This risk can be prevented by
making the server reject queries in which a quote mark appears to be
escaped by a backslash.
The allowed values of backslash_quote> are
on> (allow \'> always),
off> (reject always), and
safe_encoding> (allow only if client encoding does not
allow ASCII \> within a multibyte character).
safe_encoding> is the default setting.
Note that in a standard-conforming string literal, \> just
means \> anyway. This parameter only affects the handling of
non-standard-conforming literals, including
escape string syntax (E'...'>).
default_with_oids (boolean)
default_with_oids> configuration parameter
This controls whether CREATE TABLE and
CREATE TABLE AS include an OID column in
newly-created tables, if neither WITH OIDS
nor WITHOUT OIDS is specified. It also
determines whether OIDs will be included in tables created by
SELECT INTO. The parameter is off>
by default; in PostgreSQL> 8.0 and earlier, it
was on> by default.
The use of OIDs in user tables is considered deprecated, so
most installations should leave this variable disabled.
Applications that require OIDs for a particular table should
specify WITH OIDS when creating the
table. This variable can be enabled for compatibility with old
applications that do not follow this behavior.
escape_string_warning (boolean)
strings>escape warning>>
escape_string_warning> configuration parameter
When on, a warning is issued if a backslash (\>)
appears in an ordinary string literal ('...'>
syntax) and standard_conforming_strings is off.
The default is on>.
Applications that wish to use backslash as escape should be
modified to use escape string syntax (E'...'>),
because the default behavior of ordinary strings is now to treat
backslash as an ordinary character, per SQL standard. This variable
can be enabled to help locate code that needs to be changed.
lo_compat_privileges (boolean)
lo_compat_privileges> configuration parameter
In PostgreSQL> releases prior to 9.0, large objects
did not have access privileges and were, therefore, always readable
and writable by all users. Setting this variable to on>
disables the new privilege checks, for compatibility with prior
releases. The default is off>.
Only superusers can change this setting.
Setting this variable does not disable all security checks related to
large objects — only those for which the default behavior has
changed in PostgreSQL> 9.0.
For example, lo_import() and
lo_export() need superuser privileges regardless
of this setting.
operator_precedence_warning (boolean)
operator_precedence_warning> configuration parameter
When on, the parser will emit a warning for any construct that might
have changed meanings since PostgreSQL> 9.4 as a result
of changes in operator precedence. This is useful for auditing
applications to see if precedence changes have broken anything; but it
is not meant to be kept turned on in production, since it will warn
about some perfectly valid, standard-compliant SQL code.
The default is off>.
See for more information.
quote_all_identifiers (boolean)
quote_all_identifiers> configuration parameter
When the database generates SQL, force all identifiers to be quoted,
even if they are not (currently) keywords. This will affect the
output of EXPLAIN> as well as the results of functions
like pg_get_viewdef>. See also the
option of
and .
sql_inheritance (boolean)
sql_inheritance> configuration parameterinheritance>>
This setting controls whether undecorated table references are
considered to include inheritance child tables. The default is
on>, which means child tables are included (thus,
a *> suffix is assumed by default). If turned
off>, child tables are not included (thus, an
ONLY prefix is assumed). The SQL standard
requires child tables to be included, so the off> setting
is not spec-compliant, but it is provided for compatibility with
PostgreSQL> releases prior to 7.1.
See for more information.
Turning sql_inheritance> off is deprecated, because that
behavior has been found to be error-prone as well as contrary to SQL
standard. Discussions of inheritance behavior elsewhere in this
manual generally assume that it is on>.
standard_conforming_strings (boolean)
strings>standard conforming>>
standard_conforming_strings> configuration parameter
This controls whether ordinary string literals
('...'>) treat backslashes literally, as specified in
the SQL standard.
Beginning in PostgreSQL 9.1, the default is
on> (prior releases defaulted to off>).
Applications can check this
parameter to determine how string literals will be processed.
The presence of this parameter can also be taken as an indication
that the escape string syntax (E'...'>) is supported.
Escape string syntax ()
should be used if an application desires
backslashes to be treated as escape characters.
synchronize_seqscans (boolean)
synchronize_seqscans> configuration parameter
This allows sequential scans of large tables to synchronize with each
other, so that concurrent scans read the same block at about the
same time and hence share the I/O workload. When this is enabled,
a scan might start in the middle of the table and then wrap
around> the end to cover all rows, so as to synchronize with the
activity of scans already in progress. This can result in
unpredictable changes in the row ordering returned by queries that
have no ORDER BY> clause. Setting this parameter to
off> ensures the pre-8.3 behavior in which a sequential
scan always starts from the beginning of the table. The default
is on>.
Platform and Client Compatibilitytransform_null_equals (boolean)
IS NULL>>
transform_null_equals> configuration parameter
When on, expressions of the form expr> =
NULL (or NULL =
expr>) are treated as
expr> IS NULL, that is, they
return true if expr> evaluates to the null value,
and false otherwise. The correct SQL-spec-compliant behavior of
expr> = NULL is to always
return null (unknown). Therefore this parameter defaults to
off>.
However, filtered forms in Microsoft
Access generate queries that appear to use
expr> = NULL to test for
null values, so if you use that interface to access the database you
might want to turn this option on. Since expressions of the
form expr> = NULL always
return the null value (using the SQL standard interpretation), they are not
very useful and do not appear often in normal applications so
this option does little harm in practice. But new users are
frequently confused about the semantics of expressions
involving null values, so this option is off by default.
Note that this option only affects the exact form = NULL>,
not other comparison operators or other expressions
that are computationally equivalent to some expression
involving the equals operator (such as IN).
Thus, this option is not a general fix for bad programming.
Refer to for related information.
Error Handlingexit_on_error (boolean)
exit_on_error> configuration parameter
If true, any error will terminate the current session. By default,
this is set to false, so that only FATAL errors will terminate the
session.
restart_after_crash (boolean)
restart_after_crash> configuration parameter
When set to true, which is the default, PostgreSQL>
will automatically reinitialize after a backend crash. Leaving this
value set to true is normally the best way to maximize the availability
of the database. However, in some circumstances, such as when
PostgreSQL> is being invoked by clusterware, it may be
useful to disable the restart so that the clusterware can gain
control and take any actions it deems appropriate.
Preset Options
The following parameters> are read-only, and are determined
when PostgreSQL is compiled or when it is
installed. As such, they have been excluded from the sample
postgresql.conf> file. These options report
various aspects of PostgreSQL behavior
that might be of interest to certain applications, particularly
administrative front-ends.
block_size (integer)
block_size> configuration parameter
Reports the size of a disk block. It is determined by the value
of BLCKSZ> when building the server. The default
value is 8192 bytes. The meaning of some configuration
variables (such as ) is
influenced by block_size. See for information.
data_checksums (boolean)
data_checksums> configuration parameter
Reports whether data checksums are enabled for this cluster.
See for more information.
debug_assertions (boolean)
debug_assertions> configuration parameter
Reports whether PostgreSQL has been built
with assertions enabled. That is the case if the
macro USE_ASSERT_CHECKING is defined
when PostgreSQL is built (accomplished
e.g. by the configure option
). By
default PostgreSQL is built without
assertions.
integer_datetimes (boolean)
integer_datetimes> configuration parameter
Reports whether PostgreSQL> was built with
support for 64-bit-integer dates and times. This can be
disabled by configuring with --disable-integer-datetimes>
when building PostgreSQL>. The default value is
on.
lc_collate (string)
lc_collate> configuration parameter
Reports the locale in which sorting of textual data is done.
See for more information.
This value is determined when a database is created.
lc_ctype (string)
lc_ctype> configuration parameter
Reports the locale that determines character classifications.
See for more information.
This value is determined when a database is created.
Ordinarily this will be the same as lc_collate,
but for special applications it might be set differently.
max_function_args (integer)
max_function_args> configuration parameter
Reports the maximum number of function arguments. It is determined by
the value of FUNC_MAX_ARGS> when building the server. The
default value is 100 arguments.
max_identifier_length (integer)
max_identifier_length> configuration parameter
Reports the maximum identifier length. It is determined as one
less than the value of NAMEDATALEN> when building
the server. The default value of NAMEDATALEN> is
64; therefore the default
max_identifier_length is 63 bytes, which
can be less than 63 characters when using multibyte encodings.
max_index_keys (integer)
max_index_keys> configuration parameter
Reports the maximum number of index keys. It is determined by
the value of INDEX_MAX_KEYS> when building the server. The
default value is 32 keys.
segment_size (integer)
segment_size> configuration parameter
Reports the number of blocks (pages) that can be stored within a file
segment. It is determined by the value of RELSEG_SIZE>
when building the server. The maximum size of a segment file in bytes
is equal to segment_size> multiplied by
block_size>; by default this is 1GB.
server_encoding (string)
server_encoding> configuration parametercharacter set>>
Reports the database encoding (character set).
It is determined when the database is created. Ordinarily,
clients need only be concerned with the value of .
server_version (string)
server_version> configuration parameter
Reports the version number of the server. It is determined by the
value of PG_VERSION> when building the server.
server_version_num (integer)
server_version_num> configuration parameter
Reports the version number of the server as an integer. It is determined
by the value of PG_VERSION_NUM> when building the server.
wal_block_size (integer)
wal_block_size> configuration parameter
Reports the size of a WAL disk block. It is determined by the value
of XLOG_BLCKSZ> when building the server. The default value
is 8192 bytes.
wal_segment_size (integer)
wal_segment_size> configuration parameter
Reports the number of blocks (pages) in a WAL segment file.
The total size of a WAL segment file in bytes is equal to
wal_segment_size> multiplied by wal_block_size>;
by default this is 16MB. See for
more information.
Customized Options
This feature was designed to allow parameters not normally known to
PostgreSQL to be added by add-on modules
(such as procedural languages). This allows extension modules to be
configured in the standard ways.
Custom options have two-part names: an extension name, then a dot, then
the parameter name proper, much like qualified names in SQL. An example
is plpgsql.variable_conflict>.
Because custom options may need to be set in processes that have not
loaded the relevant extension module, PostgreSQL>
will accept a setting for any two-part parameter name. Such variables
are treated as placeholders and have no function until the module that
defines them is loaded. When an extension module is loaded, it will add
its variable definitions, convert any placeholder values according to
those definitions, and issue warnings for any unrecognized placeholders
that begin with its extension name.
Developer Options
The following parameters are intended for work on the
PostgreSQL source code, and in some cases
to assist with recovery of severely damaged databases. There
should be no reason to use them on a production database.
As such, they have been excluded from the sample
postgresql.conf> file. Note that many of these
parameters require special source compilation flags to work at all.
allow_system_table_mods (boolean)
allow_system_table_mods configuration parameter
Allows modification of the structure of system tables.
This is used by initdb.
This parameter can only be set at server start.
ignore_system_indexes (boolean)
ignore_system_indexes configuration parameter
Ignore system indexes when reading system tables (but still
update the indexes when modifying the tables). This is useful
when recovering from damaged system indexes.
This parameter cannot be changed after session start.
post_auth_delay (integer)
post_auth_delay> configuration parameter
If nonzero, a delay of this many seconds occurs when a new
server process is started, after it conducts the
authentication procedure. This is intended to give developers an
opportunity to attach to the server process with a debugger.
This parameter cannot be changed after session start.
pre_auth_delay (integer)
pre_auth_delay> configuration parameter
If nonzero, a delay of this many seconds occurs just after a
new server process is forked, before it conducts the
authentication procedure. This is intended to give developers an
opportunity to attach to the server process with a debugger to
trace down misbehavior in authentication.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
trace_notify (boolean)
trace_notify> configuration parameter
Generates a great amount of debugging output for the
LISTEN and NOTIFY
commands. or
must be
DEBUG1 or lower to send this output to the
client or server logs, respectively.
trace_recovery_messages (enum)
trace_recovery_messages> configuration parameter
Enables logging of recovery-related debugging output that otherwise
would not be logged. This parameter allows the user to override the
normal setting of , but only for
specific messages. This is intended for use in debugging Hot Standby.
Valid values are DEBUG5>, DEBUG4>,
DEBUG3>, DEBUG2>, DEBUG1>, and
LOG>. The default, LOG>, does not affect
logging decisions at all. The other values cause recovery-related
debug messages of that priority or higher to be logged as though they
had LOG> priority; for common settings of
log_min_messages> this results in unconditionally sending
them to the server log.
This parameter can only be set in the postgresql.conf>
file or on the server command line.
trace_sort (boolean)
trace_sort> configuration parameter
If on, emit information about resource usage during sort operations.
This parameter is only available if the TRACE_SORT macro
was defined when PostgreSQL was compiled.
(However, TRACE_SORT is currently defined by default.)
trace_locks (boolean)
trace_locks> configuration parameter
If on, emit information about lock usage. Information dumped
includes the type of lock operation, the type of lock and the unique
identifier of the object being locked or unlocked. Also included
are bit masks for the lock types already granted on this object as
well as for the lock types awaited on this object. For each lock
type a count of the number of granted locks and waiting locks is
also dumped as well as the totals. An example of the log file output
is shown here:
LOG: LockAcquire: new: lock(0xb7acd844) id(24688,24696,0,0,0,1)
grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
wait(0) type(AccessShareLock)
LOG: GrantLock: lock(0xb7acd844) id(24688,24696,0,0,0,1)
grantMask(2) req(1,0,0,0,0,0,0)=1 grant(1,0,0,0,0,0,0)=1
wait(0) type(AccessShareLock)
LOG: UnGrantLock: updated: lock(0xb7acd844) id(24688,24696,0,0,0,1)
grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
wait(0) type(AccessShareLock)
LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
wait(0) type(INVALID)
Details of the structure being dumped may be found in
src/include/storage/lock.h.
This parameter is only available if the LOCK_DEBUG
macro was defined when PostgreSQL was
compiled.
trace_lwlocks (boolean)
trace_lwlocks> configuration parameter
If on, emit information about lightweight lock usage. Lightweight
locks are intended primarily to provide mutual exclusion of access
to shared-memory data structures.
This parameter is only available if the LOCK_DEBUG
macro was defined when PostgreSQL was
compiled.
trace_userlocks (boolean)
trace_userlocks> configuration parameter
If on, emit information about user lock usage. Output is the same
as for trace_locks, only for advisory locks.
This parameter is only available if the LOCK_DEBUG
macro was defined when PostgreSQL was
compiled.
trace_lock_oidmin (integer)
trace_lock_oidmin> configuration parameter
If set, do not trace locks for tables below this OID. (use to avoid
output on system tables)
This parameter is only available if the LOCK_DEBUG
macro was defined when PostgreSQL was
compiled.
trace_lock_table (integer)
trace_lock_table> configuration parameter
Unconditionally trace locks on this table (OID).
This parameter is only available if the LOCK_DEBUG
macro was defined when PostgreSQL was
compiled.
debug_deadlocks (boolean)
debug_deadlocks> configuration parameter
If set, dumps information about all current locks when a
deadlock timeout occurs.
This parameter is only available if the LOCK_DEBUG
macro was defined when PostgreSQL was
compiled.
log_btree_build_stats (boolean)
log_btree_build_stats> configuration parameter
If set, logs system resource usage statistics (memory and CPU) on
various B-tree operations.
This parameter is only available if the BTREE_BUILD_STATS
macro was defined when PostgreSQL was
compiled.
wal_debug (boolean)
wal_debug> configuration parameter
If on, emit WAL-related debugging output. This parameter is
only available if the WAL_DEBUG macro was
defined when PostgreSQL was
compiled.
ignore_checksum_failure (boolean)
ignore_checksum_failure> configuration parameter
Only has effect if are enabled.
Detection of a checksum failure during a read normally causes
PostgreSQL> to report an error, aborting the current
transaction. Setting ignore_checksum_failure> to on causes
the system to ignore the failure (but still report a warning), and
continue processing. This behavior may cause crashes, propagate
or hide corruption, or other serious problems>. However, it may allow
you to get past the error and retrieve undamaged tuples that might still be
present in the table if the block header is still sane. If the header is
corrupt an error will be reported even if this option is enabled. The
default setting is off>, and it can only be changed by a superuser.
zero_damaged_pages (boolean)
zero_damaged_pages> configuration parameter
Detection of a damaged page header normally causes
PostgreSQL> to report an error, aborting the current
transaction. Setting zero_damaged_pages> to on causes
the system to instead report a warning, zero out the damaged
page in memory, and continue processing. This behavior will destroy data>,
namely all the rows on the damaged page. However, it does allow you to get
past the error and retrieve rows from any undamaged pages that might
be present in the table. It is useful for recovering data if
corruption has occurred due to a hardware or software error. You should
generally not set this on until you have given up hope of recovering
data from the damaged pages of a table. Zeroed-out pages are not
forced to disk so it is recommended to recreate the table or
the index before turning this parameter off again. The
default setting is off>, and it can only be changed
by a superuser.
Short Options
For convenience there are also single letter command-line option
switches available for some parameters. They are described in
. Some of these
options exist for historical reasons, and their presence as a
single-letter option does not necessarily indicate an endorsement
to use the option heavily.