The document provides tuning recommendations for various PostgreSQL configuration parameters related to write-ahead logging, autovacuum, asynchronous behavior, memory, and logging. It includes the parameter name, description and recommended settings to optimize performance for different workloads and hardware.
The document provides tuning recommendations for various PostgreSQL configuration parameters related to write-ahead logging, autovacuum, asynchronous behavior, memory, and logging. It includes the parameter name, description and recommended settings to optimize performance for different workloads and hardware.
1GB CheatSheet WAL size that triggers a checkpoint How aggressive kernel perfs men page swaps Assign more men to devices then actual limit github.com/vaibhav90/PostgreSQL-Parameter-Tuning-CheatSheet When writing > 1GB/per, set to 20GB 1 - do not swap inactive RAM pages 2 - disable process memory overcommit
Min. size to shrink the WAL Max # of dirty pages before writing dirty buffers autovacuum_vacuum_threshold 50 logging_collector Atleast 1GB in high write workload env off Set it to 15% of RAM availability Min. # of tuple updates/deletes prior to vacuum Capture stderr output to log files Table with > 1M rows, set to 1% # rows checkpoint_timeout 5min Switch on for csvlog and stderr dirty_backgroud_ratio 20 Max time btw auto WAL checkpoints Min. % of RAM to occupy dirty pages before flush autovacuum_vacuum_scale_factor 0.2 20% of RAM availability Set it to duration of ETL run log_min_duration_statement -1 # of tuple updates or deletes prior to vacuum checkpoint_completion_target Min exec time to start logging statements Memory Set it to 0, keep the configuration simple 0.5 Set to 0 to log everything Time spent flushing dirty buffers work_mem autovacuum_vacuum_cost_delay 2ms 4MB 0.9 to evenly distribute flushing log_destination stderr Max. memory to be used for query workspace Vacuum cost delay in milliseconds Sets the destination for server log output (max_connections)*[0.5% * RAM Size] Set inversely proportional to I/O frequency Asynchronous Behavior csvlog (to pipe it to pgbadger)
effective_io_concurrency 1 log_directory log Tells query planner of RAM availability Vacuum cost amt. available before napping # simultaneous requests handled by the disk Sets the destination directory for log files 25% of RAM availability (not allocated physically) Set 1000 to increase throughput by 5x Keep separate from db & transaction log # disks in RAID array autovacuum_analyze_threshold 50 shared_buffer 8MB max_worker_processes 8 log_filename %Y-%m-%d_%H%M%S.log Min # of tuple trans. prior to analyze Exclusively dedicated to postgres for caching Max # of concurrent worker processes Sets the file name pattern for log files Proportional to # of autovac workers 50% of RAM availability max_parallel_workers + other workers For auto log rotation, set weekdays/months autovacuum_work_mem -1 maintenance_work_mem 64MB max_parallel_workers 8 log_rotation_size 10MB Max memory used by each worker process Memory for maintenance operations Max. # parallel workers that can be active Auto log rotation occurs after N kilobytes Proportional to # of autovac workers 4% of RAM availability Alter based on # parallel queries 100MB - avoid creation of further log segments
wal_buffers 8kB %m Max # of autovacuum worker processes max # of parallel processes/executor node printf-style string to begin each log line # disk page buffers in shared memory Between 0-3 # of cores/concurrent sessions "%h:%d:%u:%c %t" On a busy, high-core machine set to 128MB