Documentation
 
 
 

30.4. Run-time Configuration

There are a lot of configuration parameters that affect the behavior of the database system. In this subsection, we describe how to set configuration parameters; the following subsections discuss each parameter in detail.

All parameter names are case-insensitive. Every parameter takes a value of one of the four types: boolean, integer, floating point, and string. Boolean values are ON, OFF, TRUE, FALSE, YES, NO, 1, 0 (case-insensitive) or any non-ambiguous prefix of these.

One way to set these parameters is to edit the file postgresql.conf in the data directory. (A default file is installed there.) An example of what this file might look like is:

# This is a comment
log_connections = yes
log_destination = 'syslog'
search_path = '$user, public'

One parameter is specified per line. The equal sign between name and value is optional. Whitespace is insignificant and blank lines are ignored. Hash marks (#) introduce comments anywhere. Parameter values that are not simple identifiers or numbers should be single-quoted.

The configuration file is reread whenever the edb-postmaster process receives a SIGHUP signal (which is most easily sent by means of pg_ctl reload). The edb-postmaster also propagates this signal to all currently running server processes so that existing sessions also get the new value. 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.

A second way to set these configuration parameters is to give them as a command line option to the edb-postmaster, such as:

edb-postmaster -c log_connections=yes -c log_destination='syslog'

Command-line options override any conflicting settings in postgresql.conf.

Occasionally it is also useful to give a command line option to one particular session only. The environment variable PGOPTIONS can be used for this purpose on the client side:

env PGOPTIONS='-c geqo=off' edb-psql

Note that this won't work for parameters that are fixed when the server is started, nor for parameters that require superuser permissions to change (not even if you are logging in as superuser).

Furthermore, it is possible to assign a set of option settings to a user or a database. Whenever a session is started, the default settings for the user and database involved are loaded. The commands ALTER DATABASE and ALTER USER, respectively, are used to configure these settings. Per-database settings override anything received from the edb-postmaster command-line or the configuration file, and in turn are overridden by per-user settings; both are overridden by per-session options.

Some parameters can be changed in individual SQL sessions with the SET command, for example:

SET ENABLE_SEQSCAN TO OFF;

If SET is allowed, it overrides all other sources of values for the parameter. Some parameters cannot be changed via SET: for example, if they control behavior that cannot reasonably be changed without restarting EnterpriseDB. Also, some parameters can be modified via SET by superusers, but not by ordinary users.

30.4.1. File Locations

data_directory (string)

Specifies the directory to use for data storage. This option can only be set at server start.

config_file (string)

Specifies the main server configuration file (customarily called postgresql.conf). This option can only be set on the edb-postmaster command line.

hba_file (string)

Specifies the configuration file for host-based authentication. This option can only be set at server start.

ident_file (string)

Specifies the configuration file for ident authentication. This option can only be set at server start.

external_pid_file (string)

Specifies that the edb-postmaster should create an additional process-id (PID) file for use by server administration programs. This option can only be set at server start.

In a default installation, none of the above options is set explicitly in the postgresql.conf file. Instead, the data directory is specified by the -D command-line option or the PGDATA environment variable, and the configuration files are all placed within the data directory.

It is also possible to separate the configuration files from the data directory, which can ease administration. (In particular it is often easier to ensure that the configuration files are properly backed-up when they are kept separate.) To do this, the -D command-line option or PGDATA environment variable must point to the directory containing the configuration files, and the data_directory option is set in postgresql.conf (or on the command line) to show where the data directory is actually located. Notice that data_directory overrides -D 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 options config_file, hba_file and/or ident_file. config_file can only be specified on the edb-postmaster command line, but the others can be set within the main configuration file. If all three options plus data_directory are explicitly set, then it is not necessary to specify -D or PGDATA .

When setting any of these options, a relative path will be interpreted with respect to the directory in which the edb-postmaster is started.

30.4.2. Connections and Authentication

30.4.2.1. Connection Settings

listen_addresses (string)

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. 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 "loopback" connections to be made. This parameter can only be set at server start.

port (integer)

The TCP port the server listens on; 5444 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)

Determines the maximum number of concurrent connections to the database server. The default is typically 100, but may be less if your kernel settings will not support it (as determined during initdb). This parameter can only be set at server start.

Increasing this parameter may cause EnterpriseDB to request more System V shared memory or semaphores than your operating system's default configuration allows. See Section 30.5.1 for information on how to adjust those parameters, if necessary.

superuser_reserved_connections (integer)

Determines the number of "connection slots" that are reserved for connections by EnterpriseDB superusers. At most max_connections 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.

The default value is 2. The value must be less than the value of max_connections. This parameter can only be set at server start.

unix_socket_directory (string)

Specifies the directory of the Unix-domain socket on which the server is to listen for connections from client applications. The default is normally /tmp, but can be changed at build time. This parameter can only be set at server start.

unix_socket_group (string)

Sets the owning group of the Unix-domain socket. (The owning user of the socket is always the user that starts the server.) In combination with the option 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 for the current user. This option can only be set at server start.

unix_socket_permissions (integer)

Sets the access permissions of the Unix-domain socket. Unix domain sockets use the usual Unix file system permission set. The option value is expected to be a numeric mode specification in the form 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 actually for a Unix domain socket, only write permission matters and there is no point in setting or revoking read or execute permissions.)

This access control mechanism is independent of the one described in Chapter 33.

This option can only be set at server start.

bonjour_name (string)

Specifies the bonjour broadcast name. By default, the computer name is used, specified as an empty string ''. This option is only meaningful on platforms that support bonjour. This option can only be set at server start.

tcp_keepalives_idle (integer)

On systems that support the TCP_KEEPIDLE socket option, specifies the number of seconds between sending keepalives on an otherwise idle connection. A value of 0 uses the system default. If TCP_KEEPIDLE is not supported, this parameter must be 0. This option is ignored for connections made via a Unix-domain socket.

tcp_keepalives_interval (integer)

On systems that support the TCP_KEEPINTVL socket option, specifies how long, in seconds, to wait for a response to a keepalive before retransmitting. A value of 0 uses the system default. If TCP_KEEPINTVL is not supported, this parameter must be 0. This option is ignored for connections made via a Unix-domain socket.

tcp_keepalives_count (integer)

On systems that support the TCP_KEEPCNT socket option, specifies how many keepalives may be lost before the connection is considered dead. A value of 0 uses the system default. If TCP_KEEPCNT is not supported, this parameter must be 0. This option is ignored for connections made via a Unix-domain socket.

30.4.2.2. Security and Authentication

authentication_timeout (integer)

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 breaks the connection. This prevents hung clients from occupying a connection indefinitely. This option can only be set at server start or in the postgresql.conf file. The default is 60.

ssl (boolean)

Enables SSL connections. The default is off. This parameter can only be set at server start.

password_encryption (boolean)

When a password is specified in CREATE USER or ALTER USER without writing either ENCRYPTED or UNENCRYPTED, this option determines whether the password is to be encrypted. The default is on (encrypt the password).

krb_server_keyfile (string)

Sets the location of the Kerberos server key file. See Section 33.2.3 for details. This parameter can only be set at server start time.

krb_srvname (string)

Sets the Kerberos service name. See Section 33.2.3 for details. This parameter can only be set at server start.

krb_server_hostname (string)

Sets the host name part of the service principal. This, combined with krb_srvname, is used to generate the complete service principal, that is krb_srvname/krb_server_hostname@REALM.

If not set, the default is the server host name. See Section 33.2.3 for details. This parameter can only be set at server start.

krb_caseins_users (boolean)

Sets whether Kerberos user names should be treated case-insensitively. The default is off (case sensitive). This parameter can only be set at server start.

db_user_namespace (boolean)

This allows per-database user names. It is off by default.

If this is on, you should create users as username@dbname. When username is passed by a connecting client, @ and the database name is 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 option enabled, you can still create ordinary global users. Simply append @ when specifying the user name in the client. The @ will be stripped off before the user name is looked up by the server.

Note: This feature is intended as a temporary measure until a complete solution is found. At that time, this option will be removed.

30.4.3. Dynamic Tuning

EnterpriseDB provides a single configuration parameter than can be set in accordance with the intended use of the host system in order to provide the maximum performance out of EnterpriseDB on that particular machine. The description of this configuration parameter follows.

edb_dynatune (integer)

Sets the resources used by EnterpriseDB in accordance with the intended purpose and capacity of the host machine on which the EnterpriseDB database server is installed. An integer value is specified in the range of 1 thru 100 that describes on a relative basis, the amount of resources to be dedicated to the EnterpriseDB database server. The smaller the value, the smaller the amount of the host system's resources will be dedicated to EnterpriseDB allowing more applications to share the same machine. The larger the value, the larger the amount of the host machine's resources will be dedicated to EnterpriseDB providing for best database performance.

30.4.4. Resource Consumption

30.4.4.1. Memory

shared_buffers (integer)

Sets the number of shared memory buffers used by the database server. The default is typically 1000, but may be less if your kernel settings will not support it (as determined during initdb). Each buffer is 8192 bytes, unless a different value of BLCKSZ was chosen when building the server. This setting must be at least 16, as well as at least twice the value of max_connections; however, settings significantly higher than the minimum are usually needed for good performance. Values of a few thousand are recommended for production installations. This option can only be set at server start.

Increasing this parameter may cause EnterpriseDB to request more System V shared memory than your operating system's default configuration allows. See Section 30.5.1 for information on how to adjust those parameters, if necessary.

temp_buffers (integer)

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 1000. The setting can be changed within individual sessions, but only up until the first use of temporary tables within a 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 a lot of 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)

Sets the maximum number of transactions that can be in the "prepared" state simultaneously (see PREPARE TRANSACTION). Setting this parameter to zero disables the prepared-transaction feature. The default is 5. This option can only be set at server start.

If you are not using prepared transactions, this parameter may as well be set to zero. If you are using them, you will probably want max_prepared_transactions to be at least as large as max_connections, to avoid unwanted failures at the prepare step.

Increasing this parameter may cause EnterpriseDB to request more System V shared memory than your operating system's default configuration allows. See Section 30.5.1 for information on how to adjust those parameters, if necessary.

work_mem (integer)

Specifies the amount of memory to be used by internal sort operations and hash tables before switching to temporary disk files. The value is specified in kilobytes, and defaults to 1024 kilobytes (1 MB). Note that for a complex query, several sort or hash operations might be running in parallel; each one will be allowed to use as much memory as this value specifies before it starts to put data into temporary files. Also, several running sessions could be doing such operations concurrently. So 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)

Specifies the maximum amount of memory to be used in maintenance operations, such as VACUUM, CREATE INDEX, and ALTER TABLE ADD FOREIGN KEY. The value is specified in kilobytes, and defaults to 16384 kilobytes (16 MB). Since only one of these operations can be executed at a time by a database session, and an installation normally doesn't have very many of them happening concurrently, it's safe to set this value significantly larger than work_mem. Larger settings may improve performance for vacuuming and for restoring database dumps.

max_stack_depth (integer)

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. Setting the parameter higher than the actual kernel limit will mean that a runaway recursive function can crash an individual backend process. The default setting is 2048 KB (two megabytes), which is conservatively small and unlikely to risk crashes. However, it may be too small to allow execution of complex functions.

30.4.4.2. Free Space Map

These parameters control the size of the shared free space map, which tracks the location of unused space in the database. An undersized free space map may cause the database to consume increasing amounts of disk space over time, because the free space that is not in the map cannot be re-used;instead EnterpriseDB will request more disk space from the operating system when it needs to store new data. The last few lines displayed by a database-wise VACUUM VERBOSE command can help in determining if the current settings are adequate. A NOTICE message is also printed during such an operation if the current settings are too low.

Increasing these parameters may cause EnterpriseDB to request more System V shared memory than your operating system's default configuration allows.

max_fsm_pages (integer)

Sets the maximum number of disk pages for which free space will be tracked in the shared free-space map. Six bytes of shared memory are consumed for each page slot. This setting must be more than 16 * max_fsm_relations. The default is 20000. This option can only be set at server start.

max_fsm_relations (integer)

Sets the maximum number of relations (tables and indexes) for which free space will be tracked in the shared free-space map. Roughly fifty bytes of shared memory are consumed for each slot. The default is 1000. This option can only be set at server start.

30.4.4.3. Kernel Resource Usage

max_files_per_process (integer)

Sets the maximum number of simultaneously open files allowed to each server subprocess. The default is 1000. 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 really support when a large number of processes all try to open that many files. If you find yourself seeing "Too many open files" failures, try reducing this setting. This option can only be set at server start.

preload_libraries (string)

This variable specifies one or more shared libraries that are to be preloaded at server start. A parameterless initialization function can optionally be called for each library. To specify that, add a colon and the name of the initialization function after the library name. For example '$libdir/mylib:mylib_init' would cause mylib to be preloaded and mylib_init to be executed. If more than one library is to be loaded, separate their names with commas.

If mylib or mylib_init are not found, the server will fail to start.

EnterpriseDB procedural language libraries may be preloaded in this way, typically by using the syntax '$libdir/plXXX:plXXX_init' where XXX is pgsql, perl, tcl, or python.

By preloading a shared library (and initializing it if applicable), the library startup time is avoided when the library is first used. However, the time to start each new server process may increase, even if that process never uses the library.

30.4.4.4. Cost-Based Vacuum Delay

During the execution of VACUUM and ANALYZE 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 while (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 in which it is not very 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. To enable it, set the vacuum_cost_delay variable to a nonzero value.

vacuum_cost_delay (integer)

The length of time, in milliseconds, that the process will sleep when the cost limit has been exceeded. The default value is 0, 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 may have the same results as setting it to the next higher multiple of 10.

vacuum_cost_page_hit (integer)

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 1.

vacuum_cost_page_miss (integer)

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)

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)

The accumulated cost that will cause the vacuuming process to sleep. The default value is 200.

Note: 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.

30.4.4.5. Background Writer

EnterpriseDB has a separate server process called the background writer, whose sole function is to issue writes of "dirty" shared buffers. The intent is that server processes handling user queries should seldom or never have to wait for a write to occur, because the background writer will do it. This arrangement also reduces the performance penalty associated with checkpoints. The background writer will continuously trickle out dirty pages to disk, so that only a few pages will need to be forced out when checkpoint time arrives, instead of the storm of dirty-buffer writes that formerly occurred at each checkpoint. However there is a net overall increase in I/O load, because where a repeatedly-dirtied page might before have been written only once per checkpoint interval, the background writer might write it several times in the same interval. In most situations a continuous low load is preferable to periodic spikes, but the parameters discussed in this section can be used to tune the behavior for local needs.

bgwriter_delay (integer)

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). The selected buffers will always be the least recently used ones among the currently dirty buffers. It then sleeps for bgwriter_delay milliseconds, and repeats. The default value is 200. 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 may have the same results as setting it to the next higher multiple of 10. This option can only be set at server start or in the postgresql.conf file.

bgwriter_lru_percent (floating point)

To reduce the probability that server processes will need to issue their own writes, the background writer tries to write buffers that are likely to be recycled soon. In each round, it examines up to bgwriter_lru_percent of the buffers that are nearest to being recycled, and writes any that are dirty. The default value is 1.0 (this is a percentage of the total number of shared buffers). This option can only be set at server start or in the postgresql.conf file.

bgwriter_lru_maxpages (integer)

In each round, no more than this many buffers will be written as a result of scanning soon-to-be-recycled buffers. The default value is 5. This option can only be set at server start or in the postgresql.conf file.

bgwriter_all_percent (floating point)

To reduce the amount of work that will be needed at checkpoint time, the background writer also does a circular scan through the entire buffer pool, writing buffers that are found to be dirty. In each round, it examines up to bgwriter_all_percent of the buffers for this purpose. The default value is 0.333 (this is a percentage of the total number of shared buffers). With the default bgwriter_delay setting, this will allow the entire shared buffer pool to be scanned about once per minute. This option can only be set at server start or in the postgresql.conf file.

bgwriter_all_maxpages (integer)

In each round, no more than this many buffers will be written as a result of the scan of the entire buffer pool. (If this limit is reached, the scan stops, and resumes at the next buffer during the next round.) The default value is 5. This option can only be set at server start or in the postgresql.conf file.

Smaller values of bgwriter_all_percent and bgwriter_all_maxpages reduce the extra I/O load caused by the background writer, but leave more work to be done at checkpoint time. To reduce load spikes at checkpoints, increase these two values. Similarly, smaller values of bgwriter_lru_percent and bgwriter_lru_maxpages 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. To disable background writing entirely, set both maxpages values and/or both percent values to zero.

30.4.5. Write Ahead Log

See also Section 39.2 for details on WAL tuning.

30.4.5.1. Settings

fsync (boolean)

If this option is on, the EnterpriseDB server will use the fsync() system call in several places to make sure that updates are physically written to disk. This insures that a database cluster will recover to a consistent state after an operating system or hardware crash.

However, using fsync() results in a performance penalty: when a transaction is committed, EnterpriseDB must wait for the operating system to flush the write-ahead log to disk. When fsync is disabled, the operating system is allowed to do its best in buffering, ordering, and delaying writes. This can result in significantly improved performance. However, if the system crashes, the results of the last few committed transactions may be lost in part or whole. In the worst case, unrecoverable data corruption may occur. (Crashes of the database server itself are not a risk factor here. Only an operating-system-level crash creates a risk of corruption.)

Due to the risks involved, there is no universally correct setting for fsync. Some administrators always disable fsync, while others only turn it off for bulk loads, where there is a clear restart point if something goes wrong, whereas some administrators always leave fsync enabled. The default is to enable fsync, for maximum reliability. If you trust your operating system, your hardware, and your utility company (or your battery backup), you can consider disabling fsync.

This option can only be set at server start or in the postgresql.conf file.

wal_sync_method (string)

Method used for forcing WAL updates out to disk. Possible values are:

  • open_datasync (write WAL files with open() option O_DSYNC).

  • fdatasync (call fdatasync() at each commit).

  • fsync_writethrough (call fsync() at each commit, forcing write-through of any disk write cache).

  • fsync (call fsync() at each commit).

  • open_sync (write WAL files with open() option O_SYNC).

Not all of these choices are available on all platforms. If fsync is off then this setting is irrelevant. This option can only be set at server start or in the postgresql.conf file.

full_page_writes (boolean)

When this option is on, the EnterpriseDB 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 a price in 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 option off speeds normal operation, but might lead to a corrupt database after an operating system crash or power failure. The risks are similar to turning off fsync, though smaller. It may be safe to turn off this option if you have hardware (such as a battery-backed disk controller) or filesystem software (e.g., Reiser4) that reduces the risk of partial page writes to an acceptably low level.

Turning off this option does not affect use of WAL archiving for point-in-time recovery (PITR) (see Section 36.3).

This option can only be set at server start or in the postgresql.conf file. The default is on.

wal_buffers (integer)

Number of disk-page buffers allocated in shared memory for WAL data. The default is 8. The setting need only be large enough to hold the amount of WAL data generated by one typical transaction. This option can only be set at server start.

commit_delay (integer)

Time delay between writing a commit record to the WAL buffer and flushing the buffer out to disk, in microseconds. A nonzero delay can allow multiple transactions to be committed with only one fsync() system call, if system load is high enough that additional transactions become ready to commit within the given interval. But the delay is just wasted if no other transactions become ready to commit. Therefore, the delay is only performed if at least commit_siblings other transactions are active at the instant that a server process has written its commit record. The default is zero (no delay).

commit_siblings (integer)

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.

30.4.5.2. Checkpoints

checkpoint_segments (integer)

Maximum distance between automatic WAL checkpoints, in log file segments (each segment is normally 16 megabytes). The default is three. This option can only be set at server start or in the postgresql.conf file.

checkpoint_timeout (integer)

Maximum time between automatic WAL checkpoints, in seconds. The default is 300 seconds. This option can only be set at server start or in the postgresql.conf file.

checkpoint_warning (integer)

Write a message to the server logs if checkpoints caused by the filling of checkpoint segment files happen closer together than this many seconds. The default is 30 seconds. Zero turns off the warning.

30.4.5.3. Archiving

archive_command (string)

The shell command to execute to archive a completed segment of the WAL file series. If this is an empty string (the default), WAL archiving is disabled. Any %p in the string is replaced by the absolute path of the file to archive, and any %f is replaced by the file name only. Use %% to embed an actual % character in the command. For more information see Section 36.3.1. This option can only be set at server start or in the postgresql.conf file.

It is important for the command to return a zero exit status only if it succeeds. Examples:

archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
archive_command = 'copy "%p" /mnt/server/archivedir/"%f"'  # Windows

30.4.6. Query Planning

30.4.6.1. Planner Method Configuration

These configuration parameters provide a crude method for 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 may be found by using one of these configuration parameters to force the optimizer to choose a better plan. Other ways to improve the quality of the plans chosen by the optimizer include configuring the Planner Cost Constants, running ANALYZE more frequently, increasing the value of the default_statistics_target configuration parameter, and increasing the amount of statistics collected for a particular column using ALTER TABLE SET STATISTICS.

enable_bitmapscan (boolean)

Enables or disables the query planner's use of bitmap-scan plan types. The default is on.

enable_hashagg (boolean)

Enables or disables the query planner's use of hashed aggregation plan types. The default is on. This is used for debugging the query planner.

enable_hashjoin (boolean)

Enables or disables the query planner's use of hash-join plan types. The default is on. This is used for debugging the query planner.

enable_indexscan (boolean)

Enables or disables the query planner's use of index-scan plan types. The default is on. This is used for debugging the query planner.

enable_mergejoin (boolean)

Enables or disables the query planner's use of merge-join plan types. The default is on. This is used for debugging the query planner.

enable_nestloop (boolean)

Enables or disables the query planner's use of nested-loop join plans. It's not possible 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. This is used for debugging the query planner.

enable_seqscan (boolean)

Enables or disables the query planner's use of sequential scan plan types. It's not possible 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. This is used for debugging the query planner.

enable_sort (boolean)

Enables or disables the query planner's use of explicit sort steps. It's not possible 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. This is used for debugging the query planner.

enable_tidscan (boolean)

Enables or disables the query planner's use of TID scan plan types. The default is on. This is used for debugging the query planner.

30.4.6.2. Planner Cost Constants

Note: Unfortunately, there is no well-defined method for determining ideal values for the family of "cost" variables that appear below. You are encouraged to experiment and share your findings.

effective_cache_size (floating point)

Sets the planner's assumption about the effective size of the disk cache that is available to a single index scan. 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 EnterpriseDB's shared buffers and the portion of the kernel's disk cache that will be used for EnterpriseDB data files. Also, take into account the expected number of concurrent queries using different indexes, since they will have to share the available space. This parameter has no effect on the size of shared memory allocated by EnterpriseDB, nor does it reserve kernel disk cache; it is used only for estimation purposes. The value is measured in disk pages, which are normally 8192 bytes each. The default is 1000.

random_page_cost (floating point)

Sets the planner's estimate of the cost of a nonsequentially fetched disk page. This is measured as a multiple of the cost of a sequential page fetch. A higher value makes it more likely a sequential scan will be used, a lower value makes it more likely an index scan will be used. The default is four.

cpu_tuple_cost (floating point)

Sets the planner's estimate of the cost of processing each row during a query. This is measured as a fraction of the cost of a sequential page fetch. The default is 0.01.

cpu_index_tuple_cost (floating point)

Sets the planner's estimate of the cost of processing each index row during an index scan. This is measured as a fraction of the cost of a sequential page fetch. The default is 0.001.

cpu_operator_cost (floating point)

Sets the planner's estimate of the cost of processing each operator in a WHERE clause. This is measured as a fraction of the cost of a sequential page fetch. The default is 0.0025.

30.4.6.3. Genetic Query Optimizer

geqo (boolean)

Enables or disables genetic query optimization, which is an algorithm that attempts to do query planning without exhaustive searching. This is on by default. The geqo_threshold variable provides a more granular way to disable GEQO for certain classes of queries.

geqo_threshold (integer)

Use genetic query optimization to plan queries with at least this many FROM items involved. (Note that an outer JOIN construct counts as only one FROM item.) The default is 12. For simpler queries it is usually best to use the deterministic, exhaustive planner, but for queries with many tables the deterministic planner takes too long.

geqo_effort (integer)

Controls the tradeoff between planning time and query plan efficiency in GEQO. This variable must be an integer in the range from 1 to 10. The default value is 5. Larger values increase the time spent doing query planning, but also increase the likelyhood 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)

Controls the pool size used by GEQO. The pool size 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 default is chosen based on geqo_effort and the number of tables in the query.

geqo_generations (integer)

Controls the number of generations used by GEQO. Generations specifies 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 default is chosen based on geqo_pool_size.

geqo_selection_bias (floating point)

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.

30.4.6.4. Other Planner Options

default_statistics_target (integer)

Sets the default statistics target for table columns that have not had a column-specific target set via ALTER TABLE SET STATISTICS. Larger values increase the time needed to do ANALYZE, but may improve the quality of the planner's estimates. The default is 10. For more information on the use of statistics by the EnterpriseDB query planner, refer to Section 13.3.

constraint_exclusion (boolean)

Enables or disables the query planner's use of table constraints to optimize queries. The default is off.

When this parameter is on, the planner compares query conditions with table CHECK constraints, and omits scanning tables for which the conditions contradict the constraints. (Presently this is done only for child tables of inheritance scans.) 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. This can improve performance when inheritance is used to build partitioned tables.

Currently, constraint_exclusion is disabled by default because it risks incorrect results if query plans are cached - if a table constraint is changed or dropped, the previously generated plan might now be wrong, and there is no built-in mechanism to force re-planning. (This deficiency will probably be addressed in a future EnterpriseDB release.) Another reason for keeping it off is that the constraint checks are relatively expensive, and in many circumstances will yield no savings. It is recommended to turn this on only if you are actually using partitioned tables designed to take advantage of the feature.

Refer to partitioning for more information on using constraint exclusion and partitioning.

from_collapse_limit (integer)

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 may yield inferior query plans. The default is 8. It is usually wise to keep this less than geqo_threshold.

join_collapse_limit (integer)

The planner will rewrite explicit inner JOIN constructs into lists of FROM items whenever a list of no more than this many items in total would result. The query planner reorders inner joins written in this manner, hence significantly improving performance, and this configuration parameter controls the extent to which this reordering is performed.

Note: At present, the order of outer joins specified via the JOIN construct is never adjusted by the query planner; therefore, join_collapse_limit has no effect on this behavior. The planner may be improved to reorder some classes of outer joins in a future release of EnterpriseDB.

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 inner JOINs. Thus, the explicit join order specified in the query will be the actual order in which the relations are joined. The query planner does not always choose the optimal join order; advanced users may elect to temporarily set this variable to 1, and then specify the join order they desire explicitly.

Setting this variable to a value between 1 and from_collapse_limit might be useful to trade off planning time against the quality of the chosen plan (higher values produce better plans).

30.4.7. Error Reporting and Logging

30.4.7.1. Where to log

log_destination (string)

EnterpriseDB supports several methods for logging server messages, including stderr and syslog. On Windows, eventlog is also supported. Set this option to a list of desired log destinations separated by commas. The default is to log to stderr only. This option can only be set at server start or in the postgresql.conf configuration file.

redirect_stderr (boolean)

This option allows messages sent to stderr to be captured and redirected into log files. This option, in combination with logging to stderr, is often more useful than logging to syslog, since some types of messages may not appear in syslog output (a common example is dynamic-linker failure messages). This option can only be set at server start.

log_directory (string)

When redirect_stderr is enabled, this option determines the directory in which log files will be created. It may be specified as an absolute path, or relative to the cluster data directory. This option can only be set at server start or in the postgresql.conf configuration file.

log_filename (string)

When redirect_stderr is enabled, this option 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. If no %-escapes are present, EnterpriseDB will append the epoch of the new log file's open time. For example, if log_filename were server_log, then the chosen file name would be server_log.1093827753 for a log starting at Sun Aug 29 19:02:33 2004 MST. This option can only be set at server start or in the postgresql.conf configuration file.

log_rotation_age (integer)

When redirect_stderr is enabled, this option 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 option can only be set at server start or in the postgresql.conf configuration file.

log_rotation_size (integer)

When redirect_stderr is enabled, this option 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 option can only be set at server start or in the postgresql.conf configuration file.

log_truncate_on_rotation (boolean)

When redirect_stderr is enabled, this option will cause EnterpriseDB 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 false, pre-existing files will be appended to in all cases. For example, using this option 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 option can only be set at server start or in the postgresql.conf configuration file.

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 true, 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 true, log_rotation_age to 60, and log_rotation_size to 1000000. Including %M in log_filename allows any size-driven rotations that may occur to select a filename different from the hour's initial filename.

syslog_facility (string)

When logging to syslog is enabled, this option determines the syslog "facility" to be used. You may 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 option can only be set at server start.

syslog_ident (string)

When logging to syslog is enabled, this option determines the program name used to identify EnterpriseDB messages in syslog logs. The default is enterprisedb. This option can only be set at server start.

30.4.7.2. When To Log

client_min_messages (string)

Controls which message levels are sent to the client. Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, LOG, NOTICE, WARNING, and ERROR. 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 (string)

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 NOTICE. Note that LOG has a different rank here than in client_min_messages. Only superusers can change this setting.

log_error_verbosity (string)

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.

log_min_error_statement (string)

Controls whether or not the SQL statement that causes an error condition will also be recorded in the server log. All SQL statements that cause an error of the specified level or higher are logged. The default is PANIC (effectively turning this feature off for normal use). Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, INFO, NOTICE, WARNING, ERROR, FATAL, and PANIC. For example, if you set this to ERROR then all SQL statements causing errors, fatal errors, or panics will be logged. Enabling this option can be helpful in tracking down the source of any errors that appear in the server log. Only superusers can change this setting.

log_min_duration_statement (integer)

Sets a minimum statement execution time (in milliseconds) that causes a statement to be logged. All SQL statements that run for the time specified or longer will be logged with their duration. Setting this to zero will print all queries and their durations. Minus-one (the default) disables the feature. For example, if you set it to 250 then all SQL statements that run 250ms or longer will be logged. Enabling this option can be useful in tracking down unoptimized queries in your applications. Only superusers can change this setting.

silent_mode (boolean)

Runs the server silently. If this option is set, the server will automatically run in background and any controlling terminals are disassociated (same effect as edb-postmaster's -S option). The server's standard output and standard error are redirected to /dev/null, so any messages sent to them will be lost. Unless syslog logging is selected or redirect_stderr is enabled, using this option is discouraged because it makes it impossible to see error messages.

Here is a list of the various message severity levels used in these settings:

DEBUG[1-5]

Provides information for use by developers.

INFO

Provides information implicitly requested by the user, e.g., during VACUUM VERBOSE.

NOTICE

Provides information that may be helpful to users, e.g., truncation of long identifiers and the creation of indexes as part of primary keys.

WARNING

Provides warnings to the user, e.g., COMMIT outside a transaction block.

ERROR

Reports an error that caused the current transaction to abort.

LOG

Reports information of interest to administrators, e.g., checkpoint activity.

FATAL

Reports an error that caused the current session to abort.

PANIC

Reports an error that caused all sessions to abort.

30.4.7.3. What To Log

debug_print_parse (boolean)
debug_print_rewritten (boolean)
debug_print_plan (boolean)
debug_pretty_print (boolean)

These options enable various debugging output to be sent to the client or server log. For each executed query, they print the resulting parse tree, the query rewriter output, or the execution plan. debug_pretty_print indents these displays to produce a more readable but much longer output format. client_min_messages or log_min_messages must be DEBUG1 or lower to send the output to the client or server logs. These options are off by default.

log_connections (boolean)

This outputs a line to the server logs detailing each successful connection. This is off by default, although it is probably very useful. This option can only be set at server start or in the postgresql.conf configuration file.

log_disconnections (boolean)

This outputs a line in the server logs similar to log_connections but at session termination, and includes the duration of the session. This is off by default. This option can only be set at server start or in the postgresql.conf configuration file.

log_duration (boolean)

Causes the duration of every completed statement which satisfies log_statement to be logged. When using this option, if you are not using syslog, it is recommended that you log the PID or session ID using log_line_prefix so that you can link the statement to the duration using the process ID or session ID. The default is off. Only superusers can change this setting.

log_line_prefix (string)

This is a printf-style string that is output at the beginning of each log line. The default is an empty string. Each recognized escape is replaced as outlined below - anything else that looks like an escape is ignored. Other characters are copied straight to the log line. Some escapes are only recognised by session processes, and do not apply to background processes such as the edb-postmaster. Syslog produces its own timestamp and process ID information, so you probably do not want to use those escapes if you are using syslog. This option can only be set at server start or in the postgresql.conf configuration file.

EscapeEffectSession only
%uUser NameYes
%dDatabase NameYes
%rRemote Hostname or IP address, and Remote PortYes
%pProcess IDNo
%tTimestampNo
%iCommand Tag. This is the command which generated the log line.Yes
%cSession ID. A unique identifier for each session. It is 2 4-byte hexadecimal numbers (without leading zeros) separated by a dot. The numbers are the Session Start Time and the Process ID, so this can also be used as a space saving way of printing these items.Yes
%lNumber of the log line for each process, starting at 1No
%sSession Start TimestampYes
%xTransaction IDYes
%qDoes not produce any output, but tells non-session processes to stop at this point in the string. Ignored by session processes.No
%%Literal %No

log_statement (string)

Controls which SQL statements are logged. Valid values are none, ddl, mod, and all. ddl logs all data definition commands like CREATE, ALTER, and DROP commands. mod logs all ddl statements, plus INSERT, UPDATE, DELETE, TRUNCATE, and COPY FROM. PREPARE and EXPLAIN ANALYZE statements are also logged if their contained command is of an appropriate type.

The default is none. Only superusers can change this setting.

Note: The EXECUTE statement is not considered a ddl or mod statement. When it is logged, only the name of the prepared statement is reported, not the actual prepared statement.

When a function is defined in the SPLserver-side language, any queries executed by the function will only be logged the first time that the function is invoked in a particular session. This is because SPL keeps a cache of the query plans produced for the SQL statements in the function.

log_hostname (boolean)

By default, connection logs only show the IP address of the connecting host. If you want it to show the host name you can turn this on, but depending on your host name resolution setup it might impose a non-negligible performance penalty. This option can only be set at server start.

30.4.8. EnterpriseDB Auditing Settings

EnterpriseDB database auditing allows database and system administrators, security administrators, auditors and operators to track and analyze database activities. These activities include database access and usage along with data creation, change or deletion.

The auditing system is based on the configuration parameters defined in the postgresql.conf file. The following is the syntax and the possible values of the database auditing parameters.

edb_audit

Enables or disables database auditing. The values xml or csv will enable database auditing. These values represent the file format in which auditing information will be captured. none will disable database auditing and is also the default value. This option can only be set at server start or in the postgresql.conf.

edb_audit_directory

Specifies the directory where the log files will be created. The path of the directory can be relative or absolute to the data folder. This option can only be set at server start or in the postgresql.conf configuration file.

edb_audit_filename

Specifies the file name of the audit file where the auditing information will be stored. The default file name will be 'audit-%Y-%m-%d_%H%M%S'. The escape sequences, %Y, %m etc., will be replaced by the appropriate current values according to system date and time. This option can only be set at server start or in the postgresql.conf configuration file.

edb_audit_rotation_day

Specifies the day of the week on which to rotate the audit files. Valid values are sun, mon, tue, wed, thu, fri, sat, every and none. To disable rotation, set the value none. To rotate the file every day, set the edb_audit_rotation_day value to every. To rotate the file on a specific day of a week, set the value of any day of the week. none is the default value. This option can only be set at server start or in the postgresql.conf configuration file.

edb_audit_rotation_size

Specifies a file size threshold in megabytes when file rotation will be forced to occur. The default value is 0 MB. If the parameter is commented out or set to 0, rotation of the file on size basis will not occur. This option can only be set at server start or in the postgresql.conf configuration file.

edb_audit_rotation_seconds

Specifies the rotation time in seconds when a new log file should be created. To disable this feature, set this parameter to 0. This option can only be set at server start or in the postgresql.conf configuration file.

edb_audit_connect

Enables auditing of database connection attempts by users. To disable auditing of all connection attempts, set edb_audit_connect set to none. To audit all failed connection attempts, set the value to failed. To audit all connection attempts, set the value to all. This option can only be set at server start or in the postgresql.conf configuration file.

edb_audit_disconnect

Enables auditing of database disconnections by connected users. To enable auditing of disconnections, set the value to all. To disable, set the value to none. This option can only be set at server start or in the postgresql.conf configuration file.

edb_audit_statement

This configuration parameter is used to specify auditing of different categories of SQL statements. To audit statements resulting in error, set the parameter value to error. To audit DDL statements such as CREATE TABLE, ALTER TABLE, etc., set the parameter value to ddl. Modification statements such as INSERT, UPDATE, DELETE etc., can be audited by setting edb_audit_statement to dml. Setting the value to all will audit every statement while none disables this feature. This option can only be set at server start or in the postgresql.conf configuration file.

30.4.8.1. Example

Suppose we need to audit all connections, disconnections, DDL statements and statements resulting in an error. The audit file is to be rotated every Sunday.

  1. Enable auditing by the setting the edb_audit parameter to xml or csv.

  2. Set the file rotation day when the new file will be created by setting the parameter edb_audit_rotation_day to sun.

  3. To audit all connections, set the parameter, edb_audit_connect, to all.

  4. To audit all disconnections, set the parameter, edb_audit_disconnect, to all.

  5. To audit all DDL statements and error statements, set the parameter, edb_audit_statement, to dll, error.

Each audit line is preceded with a fixed prefix that cannot be changed. The prefix consists of user name, database name, remote host and port, process id, session id, transaction id, timestamp, and event type.

The following is the CVS and XML output when auditing is enabled:

CSV output:

,,,17544,,,2006-05-12 18:27:37 PKT ,startup,"AUDIT:  database system is ready"
edb,edb,[local],17551,44648d4d.448f,0,2006-05-12 18:27:41 PKT ,connect,"AUDIT:  connection authorized: user=edb database=edb"
edb,edb,[local],17551,44648d4d.448f,661,2006-05-12 18:27:43 PKT ,ddl,"AUDIT:  statement: create table testing(a integer);"
edb,edb,[local],17551,44648d4d.448f,663,2006-05-12 18:27:46 PKT ,ddl,"AUDIT:  statement: drop table testing;"
edb,edb,[local],17551,44648d4d.448f,0,2006-05-12 18:27:47 PKT ,disconnect,"AUDIT:  disconnection: session time: 0:00:06.43 
user=edb database=edb host=[local]"
,,,17545,,,2006-05-12 18:27:50 PKT ,shutdown,"AUDIT:  database system is shut down"

XML output:

   
<?xml version="1.0" encoding="ISO-8859-1"?>
<EnterpriseDBAuditReports>
    <event process_id="16863" time="2006-05-12 18:14:23 PKT " type="startup">
        <message>AUDIT:  database system is ready</message>
    </event>
    <event user="edb" database="edb" remote_host_and_port="[local]" process_id="16906" session_id="44648a46.420a" 
    transaction="0" time="2006-05-12 18:14:46 PKT " type="connect">
        <message>AUDIT:  connection authorized: user=edb database=edb</message>
    </event>
    <event user="edb" database="edb" remote_host_and_port="[local]" process_id="16906" session_id="44648a46.420a" 
	transaction="655" time="2006-05-12 18:14:55 PKT " type="ddl">
        <command>AUDIT:  statement: create table testing(a integer);</command>
    </event>
    <event user="edb" database="edb" remote_host_and_port="[local]" process_id="16906" session_id="44648a46.420a" 
    transaction="657" time="2006-05-12 18:15:11 PKT " type="ddl">
        <command>AUDIT:  statement: drop table testing;</command>
    </event>
    <event user="edb" database="edb" remote_host_and_port="[local]" process_id="16906" session_id="44648a46.420a" 
    transaction="0" time="2006-05-12 18:15:13 PKT " type="disconnect">
        <message>AUDIT:  disconnection: session time: 0:00:27.13 user=edb database=edb host=[local]</message>
    </event>
    <event process_id="16864" time="2006-05-12 18:15:18 PKT " type="shutdown">
        <message>AUDIT:  database system is shut down</message>
    </event>
</EnterpriseDBAuditReports>
 

30.4.9. Runtime Statistics

30.4.9.1. Statistics Monitoring

log_statement_stats (boolean)
log_parser_stats (boolean)
log_planner_stats (boolean)
log_executor_stats (boolean)

For each query, write performance statistics of the respective module to the server log. This is a crude profiling instrument. 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.

30.4.9.2. Query and Index Statistics Collector

stats_start_collector (boolean)

Controls whether the server should start the statistics-collection subprocess. This is on by default, but may be turned off if you know you have no interest in collecting statistics. This option can only be set at server start.

stats_command_string (boolean)

Enables the collection of statistics on the currently executing command of each session, along with the time at which that command began execution. This option is off 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. This data can be accessed via the pg_stat_activity system view; refer to Chapter 37 for more information.

stats_block_level (boolean)

Enables the collection of block-level statistics on database activity. This option is disabled by default. If this option is enabled, the data that is produced can be accessed via the pg_stat and pg_statio family of system views; refer to Chapter 37 for more information.

stats_row_level (boolean)

Enables the collection of row-level statistics on database activity. This option is disabled by default. If this option is enabled, the data that is produced can be accessed via the pg_stat and pg_statio family of system views; refer to Chapter 37 for more information.

stats_reset_on_server_start (boolean)

If on, collected statistics are zeroed out whenever the server is restarted. If off, statistics are accumulated across server restarts. The default is on. This option can only be set at server start.

30.4.10. Automatic Vacuuming

These settings control the default behavior for the autovacuum daemon.

autovacuum (boolean)

Controls whether the server should start the autovacuum subprocess. This is off by default. stats_start_collector and stats_row_level must also be on for this to start. This option can only be set at server start or in the postgresql.conf file.

autovacuum_naptime (integer)

Specifies the delay between activity rounds for the autovacuum subprocess. In each round the subprocess examines one database and issues VACUUM and ANALYZE commands as needed for tables in that database. The delay is measured in seconds, and the default is 60. This option can only be set at server start or in the postgresql.conf file.

autovacuum_vacuum_threshold (integer)

Specifies the minimum number of updated or deleted tuples needed to trigger a VACUUM in any one table. The default is 1000. This option can only be set at server start or in the postgresql.conf file. This setting can be overridden for individual tables by entries in pg_autovacuum.

autovacuum_analyze_threshold (integer)

Specifies the minimum number of inserted, updated or deleted tuples needed to trigger an ANALYZE in any one table. The default is 500. This option can only be set at server start or in the postgresql.conf file. This setting can be overridden for individual tables by entries in pg_autovacuum.

autovacuum_vacuum_scale_factor (floating point)

Specifies a fraction of the table size to add to autovacuum_vacuum_threshold when deciding whether to trigger a VACUUM. The default is 0.4. This option can only be set at server start or in the postgresql.conf file. This setting can be overridden for individual tables by entries in pg_autovacuum.

autovacuum_analyze_scale_factor (floating point)

Specifies a fraction of the table size to add to autovacuum_analyze_threshold when deciding whether to trigger an ANALYZE. The default is 0.2. This option can only be set at server start or in the postgresql.conf file. This setting can be overridden for individual tables by entries in pg_autovacuum.

autovacuum_vacuum_cost_delay (integer)

Specifies the cost delay value that will be used in automatic VACUUM operations. If -1 is specified (which is the default), the regular vacuum_cost_delay value will be used. This setting can be overridden for individual tables by entries in pg_autovacuum.

autovacuum_vacuum_cost_limit (integer)

Specifies the cost limit value that will be used in automatic VACUUM operations. If -1 is specified (which is the default), the regular vacuum_cost_limit value will be used. This setting can be overridden for individual tables by entries in pg_autovacuum.

30.4.11. Client Connection Defaults

30.4.11.1. Statement Behavior

search_path (string)

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 component. 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 has to be a comma-separated list of schema names. If one of the list items is the special value $user, then the schema having the name returned by SESSION_USER is substituted, if there is such a schema. (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. It should also be noted that the temporary-table schema, pg_temp_nnn, is implicitly searched before any of these.

When objects are created without specifying a particular target schema, they will be placed in the first schema listed in the search path. An error is reported if the search path is empty.

The default value for this parameter is '$user, public' (where the second part will be ignored if there is no schema named public). This 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(). This is not quite the same as examining the value of search_path, since current_schemas() shows how the requests appearing in search_path were resolved.

For more information on schema handling, see Section 4.7.

default_tablespace (string)

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, EnterpriseDB will automatically use the default tablespace of the current database.

For more information on tablespaces, see Section 32.6.

check_function_bodies (boolean)

This parameter is normally true. When set to false, it disables validation of the function body string in CREATE FUNCTION. Disabling validation is occasionally useful to avoid problems such as forward references when restoring function definitions from a dump.

default_transaction_isolation (string)

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 MVCC and SET TRANSACTION for more information.

default_transaction_read_only (boolean)

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 false (read/write).

Consult SET TRANSACTION for more information.

statement_timeout (integer)

Aborts any statement that takes over the specified number of milliseconds. A value of zero (the default) turns off the limitation.

30.4.11.2. Locale and Formatting

DateStyle (string)

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 (Redwood, ISO, SQL, or German) and the input/output specification for year/month/day ordering (DMY, MDY, or YMD) for all the DateStyles except for Redwood which does not have an ordering component, but instead takes a parameter (hide_time, show_time) to either suppress or show the time component of a TIMESTAMP(0) value upon display. The default DateStyle is set to "redwood,show_time".

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 Section 7.4 for more information.

edb_redwood_date (boolean)

Sets whether or not a column with the DATE data type also stores a time component when a table is created or the column is altered.

If set to true, the DATE data type in a CREATE TABLE or ALTER TABLE command is translated to TIMESTAMP(0) when the table is defined or the column is altered.

If set to false, the DATE data type in a CREATE TABLE or ALTER TABLE command remains as the DATE data type.

Note that this configuration parameter has no effect on the DATE data type when used in any other context such as the data type of a variable in an SPL declaration section, or the data type of a formal parameter in an SPL procedure or an SPL function, or the return type of an SPL function. In these cases DATE is always translated to TIMESTAMP(0). See Section 7.4 for more information.

timezone (string)

Sets the time zone for displaying and interpreting time stamps. The default is to use whatever the system environment specifies as the time zone. See Section 7.4 for more information.

australian_timezones (boolean)

If set to true, ACST, CST, EST, and SAT are interpreted as Australian time zones rather than as North/South American time zones and Saturday. The default is false.

extra_float_digits (integer)

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 2, 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.

client_encoding (string)

Sets the client-side encoding (character set). The default is to use the database encoding.

lc_messages (string)

Sets the language in which messages are displayed. Acceptable values are system-dependent; see Section 34.1 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.

lc_monetary (string)

Sets the locale to use for formatting monetary amounts, for example with the to_char family of functions. Acceptable values are system-dependent; see Section 34.1 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)

Sets the locale to use for formatting numbers, for example with the to_char family of functions. Acceptable values are system-dependent; see Section 34.1 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)

Sets the locale to use for formatting date and time values. (Currently, this setting does nothing, but it may in the future.) Acceptable values are system-dependent; see Section 34.1 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.

30.4.11.3. Other Defaults

explain_pretty_print (boolean)

Determines whether EXPLAIN VERBOSE uses the indented or non-indented format for displaying detailed query-tree dumps. The default is on.

dynamic_library_path (string)

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 has to 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 EnterpriseDB package library directory is substituted for $libdir. This is where the modules provided by the standard EnterpriseDB distribution are installed. (Use pg_config --pkglibdir to find out the name of this directory.) For example:

dynamic_library_path = '/usr/local/lib/enterprisedb:/home/my_project/lib:$libdir'

or, in a Windows environment:

dynamic_library_path = 'C:\tools\enterprisedb;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.

30.4.12. Version and Platform Compatibility

escape_string_warning (boolean)

When on, a warning is issued if a backslash (\) appears in an ordinary string literal ('...' syntax). The default is off.

Escape string syntax (E'...') should be used for escapes, because in future versions of EnterpriseDB ordinary strings will have the standard-conforming behavior of treating backslashes literally.

custom_variable_classes (string)

This variable specifies one or several class names to be used for custom variables, in the form of a comma-separated list. A custom variable is a variable not normally known to EnterpriseDB proper but used by some add-on module. Such variables must have names consisting of a class name, a dot, and a variable name. custom_variable_classes specifies all the class names in use in a particular installation. This option can only be set at server start or in the postgresql.conf configuration file.

The difficulty with setting custom variables in postgresql.conf is that the file must be read before add-on modules have been loaded, and so custom variables would ordinarily be rejected as unknown. When custom_variable_classes is set, the server will accept definitions of arbitrary variables within each specified class. These variables will be treated as placeholders and will have no function until the module that defines them is loaded. When a module for a specific class is loaded, it will add the proper variable definitions for its class name, convert any placeholder values according to those definitions, and issue warnings for any placeholders of its class that remain (which presumably would be misspelled configuration variables).

Here is an example of what postgresql.conf might contain when using custom variables:

custom_variable_classes = 'plr,plperl'
plr.path = '/usr/lib/R'
plperl.use_strict = true
plruby.use_strict = true        # generates error: unknown class name

30.4.13. Lock Management

deadlock_timeout (integer)

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 slow, 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 starting the check 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 1000 (i.e., one second), 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.

max_locks_per_transaction (integer)

The shared lock table is sized on the assumption that at most max_locks_per_transaction * max_connections distinct objects will need to be locked at any one time. The default, 64, has historically proven sufficient, but you might need to raise this value if you have clients that touch many different tables in a single transaction. This option can only be set at server start.

30.4.14. Preset Options

The following "parameters" are read-only, and are determined when EnterpriseDB is compiled or when it is installed. As such, they have been excluded from the sample postgresql.conf file. These options determine various aspects of EnterpriseDB behavior that may be of interest to certain applications, particularly administrative front-ends.

block_size (integer)

Shows 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 shared_buffers) is influenced by block_size. See Section 30.4.4 for information.

integer_datetimes (boolean)

Shows whether EnterpriseDB was built with support for 64-bit-integer dates and times. It is set by configuring with --enable-integer-datetimes when building EnterpriseDB. The default value is off.

lc_collate (string)

Shows the locale in which sorting of textual data is done. See Section 34.1 for more information. The value is determined when the database cluster is initialized.

lc_ctype (string)

Shows the locale that determines character classifications. See Section 34.1 for more information. The value is determined when the database cluster is initialized. Ordinarily this will be the same as lc_collate, but for special applications it might be set differently.

max_function_args (integer)

Shows the maximum number of function arguments. It is determined by the value of FUNC_MAX_ARGS when building the server. The default value is 32.

max_identifier_length (integer)

Shows 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.

max_index_keys (integer)

Shows 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.

server_encoding (string)

Shows the database encoding (character set). It is determined when the database is created. Ordinarily, clients need only be concerned with the value of client_encoding.

server_version (string)

Shows the version number of the server. It is determined by the value of PG_VERSION when building the server.

30.4.15. Short Options

For convenience there are also single letter command-line option switches available for some parameters. They are described in Table 30-1.

Table 30-1. Short option key

Short optionEquivalent
-B xshared_buffers = x
-d xlog_min_messages = DEBUGx
-Ffsync = off
-h xlisten_addresses = x
-ilisten_addresses = '*'
-k xunix_socket_directory = x
-N xmax_connections = x
-p xport = x
-fi, -fh, -fm, -fn, -fs, -ft[a] enable_indexscan = off, enable_hashjoin = off, enable_mergejoin = off, enable_nestloop = off, enable_seqscan = off, enable_tidscan = off
-s[a]log_statement_stats = on
-S x[a] work_mem = x
-tpa, -tpl, -te[a]log_parser_stats = on, log_planner_stats = on, log_executor_stats = on
Notes:
a. For historical reasons, these options must be passed to the individual server process via the -o edb-postmaster option, for example,

$ edb-postmaster -o '-S 1024 -s'

or via PGOPTIONS from the client side, as explained above.

 
 ©2004-2007 EnterpriseDB All Rights Reserved