Default database settings are deliberately conservative so they run on any machine. On a VPS with several GB of RAM, a few changes let the database use the memory you are paying for. But configuration is only half the story: most real-world slowness comes from queries and missing indexes, which no setting can fix. This guide covers both, for MySQL/MariaDB and PostgreSQL.
Step 1: Measure Before Changing Anything
- Note current response times for key pages and queries.
- Check memory with
free -hand swap activity withvmstat 5. - Check disk latency with
iostat -x 5. - Record the current configuration so you can roll back.
Change one thing at a time and measure again. Tuning by copying settings from the internet without measuring often makes things worse.
Step 2: Plan the Memory Budget
The database shares RAM with the OS, the application and its workers. On a server that runs everything, leave room for them first; on a dedicated database server, the database can take most of the memory.
| Server | MySQL/MariaDB buffer pool | PostgreSQL shared_buffers |
|---|---|---|
| 8 GB, app + database together | 2–3 GB | 1–2 GB |
| 16 GB, app + database together | 5–7 GB | 3–4 GB |
| 32 GB, dedicated database | about 20–22 GB | about 8 GB |
These are starting points. The aim is no swapping and as much of the frequently used data in memory as possible.
Step 3: MySQL / MariaDB Settings
# /etc/mysql/mysql.conf.d/tuning.cnf (MariaDB: /etc/mysql/mariadb.conf.d/)
[mysqld]
innodb_buffer_pool_size = 6G
innodb_log_file_size = 1G # MySQL 8.0.30+: use innodb_redo_log_capacity instead
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
max_connections = 150
tmp_table_size = 64M
max_heap_table_size = 64M
slow_query_log = 1
long_query_time = 1
Restart and verify the values with SHOW VARIABLES LIKE 'innodb_buffer_pool_size';. The buffer pool hit rate tells you whether it is large enough: compare Innodb_buffer_pool_reads (disk reads) with Innodb_buffer_pool_read_requests in SHOW GLOBAL STATUS; disk reads should be a tiny fraction.
The query cache was removed in MySQL 8.0; on MariaDB it is usually best left disabled for write-heavy workloads.
Step 4: PostgreSQL Settings
# postgresql.conf (or a file in conf.d), example for a 16 GB shared server
shared_buffers = 4GB
effective_cache_size = 10GB # planner hint: memory available for caching incl. OS cache
work_mem = 16MB # per sort/hash operation, per query node
maintenance_work_mem = 512MB
max_connections = 100
random_page_cost = 1.1 # SSD/NVMe storage
effective_io_concurrency = 200 # SSD/NVMe storage
log_min_duration_statement = 1000
Be careful with work_mem: one complex query can use it several times, across many connections, so large values can exhaust memory. Most settings apply after a reload (SELECT pg_reload_conf();); shared_buffers and max_connections need a restart.
Enable the pg_stat_statements extension to see which queries use the most total time; it is the most useful single tool for PostgreSQL tuning.
Step 5: Connections and Pooling
Each connection uses memory, and PostgreSQL in particular uses a process per connection. Hundreds of mostly idle connections waste resources. Keep max_connections moderate and pool connections in the application, or use PgBouncer for PostgreSQL and ProxySQL for MySQL when many processes connect. Match application worker counts to what the database can serve.
Step 6: Find and Fix Slow Queries
This is where most of the gains are.
# MySQL: summarise the slow log
sudo mysqldumpslow -s t /var/log/mysql/mysql-slow.log | head -40
-- PostgreSQL: top queries by total time
SELECT query, calls, total_exec_time, mean_exec_time
FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;
For each slow query, look at the plan:
EXPLAIN ANALYZE SELECT ... ; -- PostgreSQL, and MySQL 8.0.18+
EXPLAIN SELECT ... ; -- MySQL/MariaDB
Full table scans (Seq Scan on large tables in PostgreSQL, type: ALL in MySQL) on queries that filter or join usually mean a missing index:
CREATE INDEX idx_orders_customer_created ON orders (customer_id, created_at);
-- PostgreSQL on a busy table: CREATE INDEX CONCURRENTLY ...
Put equality columns first in composite indexes, then range or sort columns. Do not index everything: each index slows writes and uses memory. Also look for the application-side causes: N+1 query patterns, SELECT * on wide tables and missing pagination.
Step 7: Routine Maintenance
- PostgreSQL: autovacuum keeps tables healthy; leave it on and check that it keeps up on large, busy tables.
- MySQL:
ANALYZE TABLEafter large data changes refreshes statistics. - Remove unused indexes; both databases can report index usage.
- Archive or delete old rows from log and event tables that grow forever.
Step 8: Operating System and Storage
- Avoid swapping: a database that swaps becomes very slow. Lower
vm.swappiness(for example to 10) and size memory settings correctly (see our swap guide). - Use NVMe SSD storage: random I/O latency matters far more to databases than raw capacity.
- Keep free disk space: at least 20%, for temporary files, vacuum and backups.
- Cache in front: Redis for repeated reads and sessions takes load off the database (see our Redis guide).
SkyRainCloud Plans for This Workload
Database performance depends most on RAM for caching and on fast storage. A dedicated database server on the 8 vCore / 32 GB tier keeps a large working set in memory; small applications sharing a server with their database start at 2 vCores / 8 GB.
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Intel Xeon Platinum 8269CY VPS
KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — Intel | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Business websites, small apps, scheduled jobs and bots | Order |
| VPS 2 — Intel | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,169/month | Business software, mid-size databases, several sites on one server | Check stock |
| VPS 3 — Intel | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,249/month | ERP/CRM stacks, heavier databases, multiple production apps | Check stock |
| VPS 4 — Intel | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,299/month | High-memory workloads and consolidated production servers | Check stock |
Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.
Frequently Asked Questions
What is the most important MySQL setting?
innodb_buffer_pool_size. It controls how much data and index pages InnoDB keeps in memory; around 50–70% of RAM on a dedicated database server is a common starting point.What should shared_buffers be in PostgreSQL?
effective_cache_size around 50–75% of RAM, because PostgreSQL also relies on the OS file cache.Why is my database slow even after tuning?
How many connections should I allow?
max_connections into the hundreds.Is work_mem safe to increase?
Should the database run on the same VPS as the app?
Does SSD vs NVMe matter for databases?
Should I add indexes to every column?
Is there a tool to suggest settings?
Which SkyRainCloud plan suits a database server?
Related Guides
- Signs Your Website Has Outgrown Its Server: Diagnosing CPU, RAM and Disk Bottlenecks
- How to Configure Swap Space and Optimize Memory on a Linux VPS
- How to Deploy Redis on a VPS for Application Caching
- How to Set Up Monitoring and Logging for Applications on a VPS
- Database VPS India: PostgreSQL & MySQL from ₹1,299