| PostgreSQL Reference Manual - Volume 3 - Server Administration Guide by The PostgreSQL Global Development Group Paperback (6"x9"), 204 pages ISBN 0954612043 RRP £13.95 ($24.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
4.4.1 Memory
shared_buffers(integer)-
Sets the amount of memory the database server uses for shared
memory buffers. The default is typically 32 megabytes
(
32MB), but may be less if your kernel settings will not support it (as determined during initdb). This setting must be at least 128 kilobytes and at least 16 kilobytes timesmax_connections. (Non-default values ofBLCKSZchange the minimum.) However, settings significantly higher than the minimum are usually needed for good performance. Several tens of megabytes are recommended for production installations. This parameter can only be set at server start. Increasing this parameter may cause PostgreSQL to request moreSystem Vshared memory than your operating system's default configuration allows. See section 3.4.1 Shared Memory and Semaphores 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 eight megabytes
(
8MB). 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 bytemp_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 intemp_buffers. However if a buffer is actually used an additional 8192 bytes will be consumed for it (or in general,BLCKSZbytes). 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 five transactions. This parameter 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 wantmax_prepared_transactionsto be at least as large asmax_connections, to avoid unwanted failures at the prepare step. Increasing this parameter may cause PostgreSQL to request moreSystem Vshared memory than your operating system's default configuration allows. See section 3.4.1 Shared Memory and Semaphores 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
defaults to one megabyte (
1MB). 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 ofwork_mem; it is necessary to keep this fact in mind when choosing the value. Sort operations are used forORDER BY,DISTINCT, and merge joins. Hash tables are used in hash joins, hash-based aggregation, and hash-based processing ofINsubqueries. maintenance_work_mem(integer)-
Specifies the maximum amount of memory to be used in maintenance
operations, such as
VACUUM,CREATE INDEX, andALTER TABLE ADD FOREIGN KEY. It defaults to 16 megabytes (16MB). Since only one of these operations can be executed at a time by a database session, and an installation normally doesn't have many of them running concurrently, it's safe to set this value significantly larger thanwork_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 -sor local equivalent), less a safety margin of a megabyte or so. The safety margin is needed because the stack depth is not checked in every routine in the server, but only in key potentially-recursive routines such as expression evaluation. The default setting is two megabytes (2MB), which is conservatively small and unlikely to risk crashes. However, it may be too small to allow execution of complex functions. Only superusers can change this setting. Settingmax_stack_depthhigher than the actual kernel limit will mean that a runaway recursive function can crash an individual backend process. On platforms where PostgreSQL can determine the kernel limit, it will not let you set this variable to an unsafe value. However, not all platforms provide the information, so caution is recommended in selecting a value.
| ISBN 0954612043 | PostgreSQL Reference Manual - Volume 3 - Server Administration Guide | See the print edition |