Performance & Capacity
Cheat sheet · https://pcornel.dk/topic.php?topic=6095
Answer
Database performance and capacity: query efficiency, connections, memory (buffer pools), I/O, locks and growth of data and logs.
Remember
Find the top queries by total time first (pg_stat_statements, Performance Schema, Query Store). Then check waits, memory hit ratios and I/O latency. Plan capacity from growth trends.
First checks
SELECT query,calls,total_exec_time FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;— first check for this topicpsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
Verify in this order
workload → queries → waits (CPU, I/O, locks) → resources
Where it usually breaks
Common errors are tuning from one host metric, raising connection limits without memory analysis, adding indexes without write-cost review, ignoring plan/statistics drift, allowing log/temp/data volumes to fill and assuming high cache hit rate means queries are efficient.
Performance & Capacity verification boundary matrix
| Boundary | Inspect | Healthy interpretation | Do not infer |
|---|---|---|---|
| Intent | CPU, memory and storage-I/O symptoms | Intended object/scope is explicit and versioned where relevant | Intent is already effective |
| Owning runtime/control plane | Buffer/cache behavior / Connection saturation | Owner accepts and reports the expected object state | Downstream dependencies are healthy |
| Effective state | Slow queries | Independent read-back matches the intended state | Every client sees the same result |
| Consumer outcome | Query-plan drift | The original bounded check succeeds in the same time window | Production correctness outside this scope |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6095