PostgreSQL configuration options and sensible defaults
|
postgresql.conf
|
pg_hba.conf
|
log_destination = 'csvlog'
log_directory = 'pg_log'
logging_collector = on
log_filename = 'postgres-%Y-%m-%d_%H%M%S'
log_rotation_age = 1d
log_rotation_size = 1GB
log_min_duration_statement = 250ms
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
|
Most settings just require a server reload to take effect.
|
|
Some require a full server restart (such as
shared_buffers). |
local all postgres peer
local replication repl trust
local fugu fugu trust
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
hostssl fugu fugu 178.79.191.8/32 md5
hostssl replication repl 178.79.191.8/32 md5
|
By default, database traffic is not encrypted.
|
|
Turn on ssl if you are running in a cloud provider.
|
|
For pre-9.4, set ssl_renegotiation_limit = 0.
|
|
Consists of:
|
shared_buffers |
work_mem |
maintenance_work_mem |
|
Below 2gb RAM?
20% Total System Memory
|
|
Below 64gm RAM?
25% Total System Memory
|
|
> 64gm RAM?
shared_buffers = 16gb
|
|
Start low: 32-64MB.
|
|
Look for ‘temporary file’ lines in logs.
|
|
THEN - Set to 2-3x the largest temp file you see.
|
|
The contents and special files in the main PostgreSQL directories should never, ever be modified directly. Ever.
|
|
Exceptions: pg_log (if you put the log files there), and the configuration files.
|
|
pg_xlog and pg_clog are off-limits!
|
checkpoint_segments get out of hand.wal_buffers = 16MB
checkpoint_completion_target = 0.9
checkpoint_timeout = 10m-30m # Depends on restart time
checkpoint_segments = 32 # To start.
wal_buffers = 16MB
checkpoint_completion_target = 0.9
checkpoint_timeout = 10m-30m # Depends on restart time
min_wal_size = 512MB
max_wal_size = 2GB
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.