# PostgreSQL Tuning — Nexus Autoparts **Server:** 48 GB RAM, 8 cores, SSD (QEMU) **Applied:** 2026-04-26 **Requires restart:** Yes (done) ## Configuration Changes File: `/etc/postgresql/17/main/postgresql.conf` | Parameter | Before | After | Rationale | |-----------|--------|-------|-----------| | `shared_buffers` | 128 MB | **8 GB** | ~25% of RAM for PostgreSQL buffer cache | | `work_mem` | 4 MB | **64 MB** | Larger sorts/joins without disk spilling | | `maintenance_work_mem` | 64 MB | **1 GB** | Faster VACUUM, CREATE INDEX, ALTER | | `effective_cache_size` | 4 GB | **36 GB** | Planner knows OS cache is large | | `max_wal_size` | 1 GB | **8 GB** | Fewer checkpoints under heavy write load | | `checkpoint_completion_target` | 0.5 | **0.9** | Spread checkpoint I/O over more time | | `wal_buffers` | - | **16 MB** | WAL buffer sizing | | `random_page_cost` | 4.0 | **1.1** | SSD-appropriate random read cost | | `effective_io_concurrency` | 1 | **200** | SSD can handle many concurrent requests | | `max_connections` | 100 | **200** | Headroom for Celery, Quart, Dashboard, PgBouncer | ## Verification ```bash sudo -u postgres psql -d nexus_autoparts -c "SHOW shared_buffers;" ``` ## Backup A backup of the previous config is stored at: `/etc/postgresql/17/main/postgresql.conf.backup.` ## pg_hba Adjustment for Monitoring Added Docker network access for postgres-exporter: ``` host nexus_autoparts postgres 172.17.0.0/16 trust ```