@@ -211,6 +211,80 @@ Validate connectivity before starting vCTP:
|
||||
psql "postgres://vctp_user:change-this-password@db-hostname:5432/vctp?sslmode=disable"
|
||||
```
|
||||
|
||||
### PostgreSQL tuning baseline (20 vCPU / 64 GB host)
|
||||
If your PostgreSQL instance is still running near-default settings, use this as a practical starting profile for vCTP workloads (hourly ingest + daily/monthly aggregation).
|
||||
|
||||
Choose one profile:
|
||||
- Dedicated DB host (PostgreSQL is the primary service on this machine): use the `dedicated` values.
|
||||
- Shared host (vCTP app + PostgreSQL on same machine): use the `shared` values.
|
||||
|
||||
Recommended `postgresql.conf` starting points:
|
||||
|
||||
```conf
|
||||
# Memory
|
||||
shared_buffers = 16GB # dedicated
|
||||
# shared_buffers = 12GB # shared
|
||||
effective_cache_size = 48GB # dedicated
|
||||
# effective_cache_size = 36GB # shared
|
||||
work_mem = 32MB # dedicated
|
||||
# work_mem = 16MB # shared
|
||||
maintenance_work_mem = 2GB # dedicated
|
||||
# maintenance_work_mem = 1GB # shared
|
||||
|
||||
# WAL / checkpoints
|
||||
wal_compression = on
|
||||
checkpoint_timeout = 15min
|
||||
checkpoint_completion_target = 0.9
|
||||
max_wal_size = 16GB
|
||||
min_wal_size = 2GB
|
||||
|
||||
# Parallelism and connections
|
||||
max_connections = 120
|
||||
max_worker_processes = 20
|
||||
max_parallel_workers = 20
|
||||
max_parallel_workers_per_gather = 4
|
||||
max_parallel_maintenance_workers = 4
|
||||
|
||||
# Planner / IO (SSD/NVMe)
|
||||
random_page_cost = 1.1
|
||||
effective_io_concurrency = 200
|
||||
default_statistics_target = 200
|
||||
|
||||
# Autovacuum for high-write canonical tables
|
||||
autovacuum_max_workers = 6
|
||||
autovacuum_naptime = 30s
|
||||
autovacuum_vacuum_scale_factor = 0.02
|
||||
autovacuum_analyze_scale_factor = 0.01
|
||||
autovacuum_vacuum_cost_limit = 2000
|
||||
|
||||
# Useful diagnostics
|
||||
track_io_timing = on
|
||||
log_temp_files = 32MB
|
||||
```
|
||||
|
||||
Apply and validate:
|
||||
- Reload config (`SELECT pg_reload_conf();`) or restart PostgreSQL if required by your platform.
|
||||
- Confirm active values with:
|
||||
|
||||
```sql
|
||||
SHOW shared_buffers;
|
||||
SHOW effective_cache_size;
|
||||
SHOW work_mem;
|
||||
SHOW maintenance_work_mem;
|
||||
SHOW max_wal_size;
|
||||
SHOW autovacuum_vacuum_scale_factor;
|
||||
```
|
||||
|
||||
After tuning, rerun the canonical benchmark and compare against your pre-tuning snapshot:
|
||||
|
||||
```shell
|
||||
vctp -settings /path/to/vctp.yml -benchmark-aggregations -benchmark-runs 3
|
||||
```
|
||||
|
||||
Notes:
|
||||
- `work_mem` is per sort/hash operation, not per session; avoid setting it too high globally.
|
||||
- Keep `settings.scheduled_aggregation_engine: go` as default unless repeated production-scale benchmarks show SQL is consistently faster on your canonical Postgres data.
|
||||
|
||||
PostgreSQL migrations live in `db/migrations_postgres`, while SQLite migrations remain in
|
||||
`db/migrations`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user