Pcornel
Databases

Performance & Capacity

Cheat sheet · https://pcornel.dk/topic.php?topic=6095

Back to the Topic

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 topic
  • psql -c "SELECT now(), version();" — PostgreSQL reachable and version
  • mysql -e "SELECT NOW(), VERSION();" — MariaDB/MySQL reachable and version
  • sqlcmd -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

BoundaryInspectHealthy interpretationDo not infer
IntentCPU, memory and storage-I/O symptomsIntended object/scope is explicit and versioned where relevantIntent is already effective
Owning runtime/control planeBuffer/cache behavior / Connection saturationOwner accepts and reports the expected object stateDownstream dependencies are healthy
Effective stateSlow queriesIndependent read-back matches the intended stateEvery client sees the same result
Consumer outcomeQuery-plan driftThe original bounded check succeeds in the same time windowProduction 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

Confirmation

Confirm action

Continue?