Skip to content

Instantly share code, notes, and snippets.

@mbuckbee
Created September 4, 2012 03:44
Show Gist options
  • Save mbuckbee/3616316 to your computer and use it in GitHub Desktop.
Save mbuckbee/3616316 to your computer and use it in GitHub Desktop.
Postgres tuning
Set File system Read ahead to 4096
blockdev --setra 4096 /dev/sda1
Filesystem tests run at 256, 4096 and 8192 each tested with
bonnie++ -f -n 0 -c 4 -u root | bon_csv2html > ir-results-8192.html
Run /services/postgres-tuning/determine_postgres_memory.sh on machine (copy via SFTP)
Set /etc/sysctl.conf
kernel.shmmax=OUTPUT
kernel.shmall=OUTPUT
vm.swappiness = 0
vm.overcommit_memory=2
Run 'sysctl -p' to apply new settings
Edit /etc/postgresql/9.0/main/postgresql.conf
shared_buffers = 800MB
log_line_prefix = '%t:%r:%u@%d:[%p] '
maintenance_work_mem = 100MB
work_mem = 25MB
wal_buffers = 16MB
checkpoint_segments = 32
checkpoint_timeout = 10min
checkpoint_completion_target = 0.9
Other Test Configurations
Test postgresql.conf - checkpoint_completion_target = 0.5 to see if it is better for I/O
At move to 4GB
Rerun determine_postgres_memory.sh and reset kernel settings after bumping to 4GB.
Set maintenance_work_mem to 200MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment