- linkend="SQL-SET"> at the beginning of the session.
-
-
- However, the format of PGOPTIONS is similar to that
- used when launching the postgres command.
- Specifically, the -c> flag must be specified.
+ 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 -c> flag must be specified.
+ For example,
-env PGOPTIONS="-c geqo=off -c statement_timeout='5 min' " psql
+env PGOPTIONS="-c geqo=off -c statement_timeout=5min " psql
Other clients and libraries might provide their own mechanisms,
via the shell or otherwise, that allow the user to alter session
- settings without requiring the user to issue SQL commands.
+ settings without direct use of SQL commands.
-
Configuration File Includes
+
Managing Configuration File Contents
+
+
PostgreSQL> 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.
+
in configuration file
-
- In addition to 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:
+
+ 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.
+ 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.
in configuration file
- There is also an include_if_exists> directive, which acts
- the same as the include> directive, except for the behavior
- 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.
+ 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.
in configuration file
- The postgresql.conf> file can also contain
- include_dir directives, which specify an entire directory
- of configuration files to include. It is used similarly:
+ 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 follow the same rules as single file include
- directives: they are relative to the directory containing the referencing
- configuration file. Within that directory, only non-directory files whos e
- names end with the suffix .conf will be included. File
- names that start with the . character are also excluded,
- to prevent mistakes as they are hidden on some platforms. Multiple files
- within an include directory are processed in file name order. The file names
- are ordered by C locale rules, i.e. numbers before letters, and uppercase
- letters before lowercase ones .
+ 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 th e
+ 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 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.
+ 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>:
+ 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:
+ Then you could name the files in the conf.d> directory
+ like this:
00shared.conf
01memory.conf
02server.conf
- This shows a clear order in which these files will be loaded. This is
- important because only the last setting encountered when the server is
- reading its configuration will be used. Something set in
- conf.d/02server.conf> in this example would override a value
- set in conf.d/01memory.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 configuration directory approach while naming
- these files more descriptively:
+ 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).
+ 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.)