postgres

Name

postgres -- Run a PostgreSQL single-user backend

Synopsis

postgres [-A 0 | 1 ] [-B nbuffers] [-c name=value] [-d debug-level] [-D datadir] [-e] [-E] [-f s | i | t | n | m | h ] [-F] [-i] [-N] [-o file-name] [-O] [-P] [-s | -t pa | pl | ex ] [-S sort-mem] [-W seconds] [--name=value] dbname
postgres [-A 0 | 1 ] [-B nbuffers] [-c name=value] [-d debug-level] [-D datadir] [-e] [-f s | i | t | n | m | h ] [-F] [-i] [-o file-name] [-O] [-p database] [-P] [-s | -t pa | pl | ex ] [-S sort-mem] [-v protocol-version] [-W seconds] [--name=value]

Options

When postgres is started by a postmaster, it inherits all options set by the latter. Additionally, postgres-specific options can be passed from the postmaster with the -o switch.

You can avoid having to type these options by setting up a configuration file (see the the Section called Runtime Configuration in Chapter 1 for details). Some (safe) options can also be set from the connecting client in an application-dependent way. For example, if the environment variable PGOPTIONS is set, then libpq-based clients will pass that string to the server, which will interpret it as postgres command-line options.

General Purpose

The options -A, -B, -c, -d, -D, -F, and --name have the same meaning as with the postmaster.

-e

Sets the default date style to "European", which means that the "day before month" (rather than month before day) rule is used to interpret ambiguous date input, and that the day is printed before the month in certain date output formats. See the Red Hat Database SQL Guide and Reference for more information.

-o file-name

Sends all debugging and error output to filename. If the backend is running under the postmaster, this option is ignored, and the stderr inherited from the postmaster is used.

-P

Ignore system indexes to scan/update system tuples. The REINDEX command for system tables/indexes requires this option to be used.

-s

Print time information and other statistics at the end of each query. This is useful for benchmarking or for use in tuning the number of buffers.

-S sort-mem

Specifies the amount of memory to be used by internal sorts and hashes before resorting to temporary disk files. The value is specified in kilobytes, and defaults to 512 kilobytes. Note that for a complex query, several sorts and/or hashes might be run in parallel, and each one will be allowed to use as much as sort-mem kilobytes before it is forced to put data into temporary files.

database

Specifies the name of the database to be accessed. If it is omitted it defaults to the user name.

-E

Echo all queries.

-N

Disables use of newline as a query delimiter.

Semi-internal Options

There are several other options that may be specified, used mainly for debugging purposes. These are listed here only for the use by PostgreSQL system developers. Use of any of these options is highly discouraged. Furthermore, any of these options may disappear or change in a future release without notice.

-f { s | i | m | n | h }

Forbids the use of particular scan and join methods: s and i disable sequential and index scans respectively, while n, m, and h disable nested-loop, merge and hash joins respectively.

Note

Neither sequential scans nor nested-loop joins can be disabled completely; the -fs and -fn options simply discourage the optimizer from using those plan types if it has any other alternative.

-i

Prevents query execution, but shows the plan tree.

-O

Allows the structure of system tables to be modified. This is used by initdb.

-p dbname

Indicates that the server has been started by a postmaster and makes different assumptions about buffer pool management, file descriptors, and so on.

-t pa[rser] | pl[anner] | e[xecutor]

Print timing statistics for each query relating to each of the major system modules. This option cannot be used with the -s option.

-v protocol

Specifies the version number of the frontend/backend protocol to be used for this particular session.

-W seconds

Sleep the process for the specified amount of seconds. This gives developers time to attach a debugger to the backend process.

Description

The postgres executable is the actual PostgreSQL server process that processes queries. It is normally not called directly; instead a postmaster multi-user server is started.

The second form above is how postgres is invoked by the postmaster (only conceptually, since both postmaster and postgres are in fact the same program); it should not be invoked directly this way. The first form invokes the server directly in interactive mode. The primary use for this mode is for bootstrapping by initdb; sometimes it is used for debugging or disaster recovery.

When invoked in interactive mode from the shell, the user can enter queries and the results will be printed to the screen, but in a form that is more useful for developers than end users. But note that running a single-user backend is not truly suitable for debugging the server since no realistic inter-process communication and locking will happen.

When running a stand-alone backend the session user name will automatically be set to the current effective Linux user name. If that user does not exist the server will not start.