PostgreSQL
PostgreSQL Production Performance Engine

PostgreSQL (postgresql.conf) Hardware Tuner & Builder

Calculate and generate optimized postgresql.conf settings based on hardware specs (shared_buffers, work_mem, effective_cache_size, max_connections).

Zero-Telemetry Client Execution
Presets:
Input
Total System RAM (Memory)
GB RAM
Physical / Virtual CPU Cores
Cores
Maximum Direct Connections
clients
~41MB work_mem/conn
# ----------------------------------------------------------------------
# PostgreSQL 17 Hardware-Tuned Configuration
# Target Profile: WEB | RAM: 32GB | CPU: 8 Cores | Storage: NVME
# Generated: 2026-01-01T00:00:00.000Z via ToolsAA Client-Side Tuner
# ----------------------------------------------------------------------

# CONNECTIONS & NETWORKING
max_connections = 200
# Note: Transaction pooler (PgBouncer) is assumed in front of PostgreSQL.

# MEMORY ALLOCATION
shared_buffers = 8GB
effective_cache_size = 24GB
maintenance_work_mem = 1.6GB
work_mem = 41MB
wal_buffers = 16MB
huge_pages = try

# CHECKPOINT & WAL ENGINE
checkpoint_completion_target = 0.9
checkpoint_timeout = 15min
min_wal_size = 2GB
max_wal_size = 16GB
wal_compression = zstd
synchronous_commit = on

# QUERY PLANNER & DISK I/O TUNING
random_page_cost = 1.05
effective_io_concurrency = 300
default_statistics_target = 100
jit = off

# PARALLEL QUERY WORKERS
max_worker_processes = 8
max_parallel_workers_per_gather = 4
max_parallel_workers = 8
max_parallel_maintenance_workers = 4

# TELEMETRY & DIAGNOSTICS
track_io_timing = on
track_functions = pl
log_min_duration_statement = 1000   # Log queries exceeding 1000ms
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
Shared Buffers Allocation
8GB

PostgreSQL core memory cache (~25% of total physical RAM).

Effective Cache Size
24GB

Total estimated OS disk cache available for index scans (~75% RAM).

Parallel Query Pool
8 Workers

4 parallel workers per gather node across 8 Cores

Zero-Knowledge Local Execution

All data processing, parsing, and compilation execute strictly inside your local browser memory. Zero external server uploads.

Sub-Millisecond AST Engine

All data payloads remain strictly local with zero external server communication.

Production Ready Export

Clean, optimized output formats ready for immediate deployment.

Technical Reference & Architecture Guide

PostgreSQL (postgresql.conf) Hardware Tuner & Builder — Reference Guide

Calculate and generate optimized postgresql.conf settings based on hardware specs (shared_buffers, work_mem, effective_cache_size, max_connections).

Key Parameters & Controls

shared_buffersstring (memory_size)

PostgreSQL dedicated memory buffer pool for caching table and index pages.

Default: 25% of total system RAM (e.g., 4GB for 16GB system)
work_memstring (memory_size)

Memory allocated for internal sort operations and hash tables per query node before spilling to temporary disk files.

Default: ((Total RAM - shared_buffers) / (max_connections * 3)) ~ 16MB - 64MB
effective_cache_sizestring (memory_size)

Planner estimate of memory available for disk caching by both PostgreSQL and the OS kernel.

Default: 50% - 75% of total system RAM (e.g., 12GB for 16GB system)
maintenance_work_memstring (memory_size)

Maximum memory used by maintenance operations like VACUUM, CREATE INDEX, and ALTER TABLE ADD FOREIGN KEY.

Default: 5% - 10% of total system RAM (up to 2GB)
max_connectionsinteger

Maximum number of concurrent client connections allowed by the PostgreSQL server engine.

Default: 100 (Default) / 20-50 behind PgBouncer

Pro Tips & Best Practices

Deploy PgBouncer for Connection Pooling

Avoid setting max_connections to large numbers (>200) directly in postgresql.conf. Use a connection pooler like PgBouncer in transaction mode so you can allocate significantly higher work_mem without risking Out-Of-Memory (OOM) crashes.

Tune for Modern NVMe and SSD Storage

On modern SSD/NVMe drives, reduce random_page_cost from the default 4.0 down to 1.1, and set effective_io_concurrency to 200. This informs the query planner that random seeks are nearly as fast as sequential reads, favouring efficient index scans.

Checkpoint Smoothing and Write Smoothing

Set checkpoint_completion_target = 0.9 and increase max_wal_size to 16GB-32GB on write-heavy databases to spread I/O evenly over the checkpoint interval and eliminate transaction throughput spikes.

Enable Linux Huge Pages for Large Memory

When shared_buffers is set to 8GB or higher, enable Linux Huge Pages (vm.nr_hugepages) and set huge_pages = try in postgresql.conf to reduce TLB cache misses and kernel memory overhead.

Common Gotchas & Troubleshooting

Linux Out-Of-Memory (OOM) Killer abruptly terminates postgres master/worker processes

Lower work_mem or reduce max_connections. Remember that work_mem is allocated per sort/hash operation within each query, so a complex query with multiple joins and sorting can consume multiple work_mem allocations concurrently.

FATAL: could not create shared memory segment: Cannot allocate memory

Ensure the Linux kernel parameters sysctl vm.max_map_count and system available RAM are sufficient. Verify that shared_buffers does not exceed available system memory or container limits.

Database logs indicate checkpoints are occurring too frequently

Increase max_wal_size (e.g., from 1GB to 16GB) and checkpoint_timeout (e.g., from 5min to 15min) to prevent premature checkpoint creation caused by saturating WAL segments.

Frequently Asked Questions

Why is shared_buffers typically capped at 25% to 40% of total RAM on Linux?▼

PostgreSQL relies on a dual-caching architecture where both shared_buffers and the Linux kernel page cache work in tandem. Setting shared_buffers higher than 40% often causes cache duplication, degrades OS filesystem caching, and increases checkpoint write amplification.

Does effective_cache_size actually allocate or consume physical RAM?▼

No. effective_cache_size is strictly an informational advisory setting for the query planner. It helps the optimizer estimate whether index pages are already cached in OS memory, influencing the choice between index scans and sequential table scans without allocating a single byte.

How does work_mem differ from maintenance_work_mem?▼

work_mem is allocated dynamically per query sort/hash execution step during normal user transactions. In contrast, maintenance_work_mem is only allocated during maintenance and DDL tasks like VACUUM, CREATE INDEX, and REINDEX, allowing you to set it much higher because fewer such operations run simultaneously.

How should configuration differ between OLTP and OLAP (Data Warehouse) workloads?▼

OLTP systems with high concurrency require lower work_mem, lower max_parallel_workers, and moderate shared_buffers to ensure low latency. OLAP systems with fewer concurrent queries should configure significantly higher work_mem (e.g., 256MB-1GB), higher max_parallel_workers_per_gather, and larger temp_buffers for heavy aggregations.

Related Tools & Utilities

All Tools →