Database Performance Principles
Default PostgreSQL and MySQL installations are intentionally configured to run on minimal hardware (often 256MB–512MB RAM). When deployed on an Edutechz NVMe VPS, leaving default database settings results in underutilized RAM, unnecessary disk throttling, and slow query execution.
1. Key PostgreSQL Tuning Parameters
Edit `/etc/postgresql/16/main/postgresql.conf`:
# Set shared buffers to 25% of total system RAM
shared_buffers = 1GB # For a 4GB RAM VPS
# Estimate available OS disk cache for query planner
effective_cache_size = 3GB
# Maintenance memory for indexing and VACUUM
maintenance_work_mem = 256MB
# Checkpoint write spreading to avoid SSD I/O spikes
checkpoint_completion_target = 0.9
wal_buffers = 16MB
# NVMe drive random read cost reduction
random_page_cost = 1.1
effective_io_concurrency = 200
Restart PostgreSQL to apply:
sudo systemctl restart postgresql
2. MySQL / MariaDB InnoDB Optimizations
In `/etc/mysql/my.cnf`:
[mysqld]
# Allocate 50-70% of available RAM to InnoDB Buffer Pool
innodb_buffer_pool_size = 2G
innodb_log_file_size = 512M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
# Connection Pool Management
max_connections = 150
Restart MySQL:
sudo systemctl restart mysql
These adjustments typically increase queries-per-second (QPS) by 300% to 500% under high concurrency loads.