Files
Autoparts-DB/docs/POSTGRESQL_TUNING.md
consultoria-as c766571b7d docs(infra): add PostgreSQL tuning and systemd service documentation
- POSTGRESQL_TUNING.md: documents applied config (8GB shared_buffers,
  64MB work_mem, 8GB max_wal_size, SSD params)
- SYSTEMD_SERVICES.md: lists all production systemd services
- systemd/: versioned copies of all .service and .timer files
- .gitignore: ignore package-lock.json and backups/
2026-04-29 06:30:22 +00:00

1.4 KiB

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

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.<timestamp>

pg_hba Adjustment for Monitoring

Added Docker network access for postgres-exporter:

host    nexus_autoparts    postgres    172.17.0.0/16    trust