def_postgresql_conf
def_postgresql_conf
conf file,
step by step
Ilya Kosmodemiansky
[email protected]
Before we start
dataegret.com
dataegret.com
pg settings
postgres=# \x
Expanded display is on.
postgres=# select * from pg_settings where name ~ ’checkpoint_timeout’;
-[ RECORD 1 ]---+---------------------------------------------------------
dataegret.com
dataegret.com
pg settings: context
dataegret.com
dataegret.com
postgresql.conf
Why the
• Plase do not change thisorder
talk of the settings when you edit
them manually
dataegret.com
dataegret.com
postgresql.conf
Why the
• Plase do not change thisorder
talk of the settings when you edit
them manually
• postgresql.conf supports includes
• Linux is a most common OS for databases
dataegret.com
dataegret.com
postgresql.conf
Why the
• Plase do not change thisorder
talk of the settings when you edit
them manually
• postgresql.conf supports includes
• Always check pg• Linux is a mostifcommon
settings OS for databases
you doubt...
• DBAs often run into IO problems
dataegret.com
dataegret.com
postgresql.conf
Why the
• Plase do not change thisorder
talk of the settings when you edit
them manually
• postgresql.conf supports includes
• Always check pg• Linux is a mostifcommon
settings OS for databases
you doubt...
• And off we go • DBAs often run into IO problems
• Most of the information on topic is written by kerneldevelopers
(for kernel developers) or is checklist-style
dataegret.com
dataegret.com
listen addresses
dataegret.com
dataegret.com
listen addresses
dataegret.com
dataegret.com
listen addresses
dataegret.com
dataegret.com
max connections
Why
• Client connection thisPostgres
cause talk to spawn a ”heavy”
Unix-Process
dataegret.com
dataegret.com
max connections
Why
• Client connection thisPostgres
cause talk to spawn a ”heavy”
Unix-Process
• Thats why things like max connections = 1000 will never work
• Linux is a most common OS for databases
dataegret.com
dataegret.com
max connections
Why
• Client connection thisPostgres
cause talk to spawn a ”heavy”
Unix-Process
• Thats why things like max connections = 1000 will never work
• A much better idea:
• Linuxmax
is a most common OS for=
connections databases
100 or 200 and really
small pool sizes• inDBAs
pgbouncer orIOanother
often run into problems connection pooler
dataegret.com
dataegret.com
superuser reserved connections
dataegret.com
dataegret.com
superuser reserved connections
dataegret.com
dataegret.com
tcp keepalives idle
dataegret.com
dataegret.com
tcp keepalives idle
dataegret.com
dataegret.com
shared buffers
• Rule of Thumb:Why
25% this talk
of RAM
dataegret.com
dataegret.com
shared buffers
dataegret.com
dataegret.com
shared buffers
dataegret.com
dataegret.com
huge pages
dataegret.com
dataegret.com
huge pages
dataegret.com
dataegret.com
huge pages
• vm.nr overcommit
• DBAs often run intoand
hugepages IO problems
vm.nr hugepages
• Most of the information on topic is written by kerneldevelopers
(for kernel developers) or is checklist-style
dataegret.com
dataegret.com
Linux Memory allocation
CPU L1
Virtual addressing
dataegret.com
dataegret.com
work mem
dataegret.com
dataegret.com
work mem
dataegret.com
dataegret.com
work mem
dataegret.com
dataegret.com
work mem
dataegret.com
dataegret.com
maintenance work mem
dataegret.com
dataegret.com
maintenance work mem
dataegret.com
dataegret.com
maintenance work mem
dataegret.com
dataegret.com
maintenance work mem
dataegret.com
dataegret.com
Settings fro manual vacuum
Why
• vacuum cost delay = this
0 talk
• vacuum cost page hit = 0
• vacuum cost page miss = 10
• Linux
• vacuum cost page is a most
dirty = 10 common OS for databases
• DBAs
• vacuum cost limit often run into IO problems
= 100
• Most of the information on topic is written by kerneldevelopers
(for kernel developers) or is checklist-style
dataegret.com
dataegret.com
Write Ahead Log
dataegret.com
dataegret.com
Write Ahead Log
dataegret.com
dataegret.com
Write Ahead Log
• checkpoint completion
• DBAs often run into
target =IO0.9
problems
dataegret.com
dataegret.com
bgwriter
dataegret.com
dataegret.com
bgwriter
dataegret.com
dataegret.com
bgwriter
dataegret.com
dataegret.com
effective io concurrency
dataegret.com
dataegret.com
effective io concurrency
dataegret.com
dataegret.com
effective io concurrency
dataegret.com
dataegret.com
Must have optimizer settings
dataegret.com
dataegret.com
Autovacuum
dataegret.com
dataegret.com
Autovacuum
dataegret.com
dataegret.com
Autovacuum
dataegret.com
dataegret.com
Autovacuum
dataegret.com
dataegret.com
Autovacuum
dataegret.com
dataegret.com
Autovacuum
dataegret.com
dataegret.com
Autovacuum
dataegret.com
dataegret.com
Logging
log_directory = ’’/var/log/postgresql’’
Why this talk
log_filename = ’’postgresql-%Y-%m-%d.log’’
log_rotation_age = 1d
log_rotation_size = 0
log_min_error_statement = error
log_min_duration_statement = 1000
log_checkpoints = on
log_line_prefix = ’’%m %p %u@%d from %h [vxid:%v txid:%x] [%i] ’’
log_lock_waits = on • Linux is a most common OS for databases
log_statement = ’’none’’
log_replication_commands = on
log_temp_files = 0 • DBAs often run into IO problems
log_timezone = ’’Europe/Berlin’’
• Most of the information on topic is written by kerneldevelopers
(for kernel developers) or is checklist-style
dataegret.com
dataegret.com
Don’t forget about one very useful extension
dataegret.com
dataegret.com
Questions?
dataegret.com
dataegret.com