PmaControl logo PmaControl
  • Home
  • PmaControl
    • AI Agents 13 on-premise agents
    • Plans Community, Cloud, On-Premise, Premium
    • Documentation Guides, API, architecture
    • Changelog Every stable 5.x release
    • Marketplace Community plugins
    • Clients 28+ companies
    • FAQ 25 questions / 7 categories
    Databases
    • MariaDB 35 articles
    • MySQL 15 articles
    • Galera Cluster 6 articles
    • MaxScale 4 articles
    • ProxySQL 3 articles
    • Amazon Aurora MySQL 0 article
    • Azure Database 0 article
    • ClickHouse 0 article
    • GCP CloudSQL 0 article
    • Percona Server 0 article
    • SingleStore 0 article
    • TiDB 0 article
    • Vitess 0 article
    Solutions
    • Support 24×7 MariaDB & MySQL emergencies
    • Observabilité SQL Monitoring, alerts, topology
    • Haute disponibilité Replication, failover, Galera
    • Disaster Recovery Backup, restore, RPO/RTO
    • Sécurité & conformité Audit, GDPR, SOC2
    • Migration & upgrade Zero downtime, pt-osc, gh-ost
  • Plans
  • Resources
    • Documentation Technical guides & API
    • MySQL optimization center Markdown index, metrics, parameters, incidents
    • FAQ 25 frequently asked questions
    • Testimonials Client feedback & use cases
    • Blog Articles & insights
    • Roadmap Upcoming features
    Areas of expertise
    • Observabilité SQL Monitoring, alerts, Dot3 topology
    • Haute disponibilité Replication, failover, Galera
    • Sécurité & conformité Audit, GDPR, SOC2, ISO 27001
    • Disaster Recovery Backup, restore, RPO/RTO
    • Performance & optimisation Digests, EXPLAIN, tuning
    • Migration & upgrade Zero downtime, pt-osc
    Quick links
    • GitHub Wiki 26 pages — install, engine, plugins
    • Source code Official GitHub repository
    • Support 24×7 MariaDB & MySQL emergencies
    • Book a demo 30 min — real architecture
  • Support 24×7
  • Book a demo
Book a demo
🇫🇷 FR Français 🇬🇧 EN English 🇵🇱 PL Polski 🇷🇺 RU Русский 🇨🇳 ZH 中文 🇸🇦 AR العربية
Resources › MySQL optimization center › MySQL Performance Tuning

MySQL Performance Tuning

Structured Markdown documentation to diagnose, measure, and optimize MySQL.

This page is original PmaControl documentation. It keeps a practical index structure for MySQL optimization work, without copying third-party content or depending on an external product.

Objective

MySQL tuning reduces latency, stabilizes throughput, and avoids repeated saturation. The work must start from real measurements rather than generic values copied from one server to another.

Recommended Work Order

  1. Capture the real workload: QPS, latency, errors, connections, disk I/O, memory, and CPU.
  2. Identify dominant queries with performance_schema, the slow log, or a digest tool.
  3. Check the schema: missing indexes, redundant indexes, oversized types, and tables without a primary key.
  4. Tune InnoDB: buffer pool, redo log, flush, I/O threads, and durability strategy.
  5. Review server limits: connections, open files, table caches, and temporary table sizes.
  6. Test during a controlled window, with a documented rollback.

Useful Commands

SHOW GLOBAL STATUS LIKE 'Threads_connected';
SHOW GLOBAL STATUS LIKE 'Questions';
SHOW GLOBAL STATUS LIKE 'Innodb_buffer_pool_reads';
SHOW VARIABLES LIKE 'innodb_buffer_pool_size';

Key Point

Good MySQL tuning is incremental. A variable changed without before/after measurement becomes operational debt.

Build a comparable baseline

Record the exact server version, host resources, dataset size, application release, traffic mix and observation window. Separate client response time from SQL execution time: connection-pool queues, network round trips and application work can dominate a request even when individual queries are fast. Use the same workload and concurrency before and after a change.

SELECT VERSION() AS server_version, @@version_comment AS distribution;
SHOW GLOBAL STATUS WHERE Variable_name IN (
  'Uptime', 'Questions', 'Threads_connected', 'Threads_running',
  'Innodb_buffer_pool_read_requests', 'Innodb_buffer_pool_reads',
  'Innodb_log_waits', 'Created_tmp_tables', 'Created_tmp_disk_tables'
);

Take two snapshots over a representative interval. Questions is cumulative: client statement rate = ΔQuestions / elapsed seconds, not the raw counter. A restart or counter reset invalidates the interval. Record p50, p95 and p99 request latency alongside completed work and errors; a lower average alone can hide a worse tail.

Find the queries that consume the budget

SELECT SCHEMA_NAME, LEFT(DIGEST_TEXT, 140) AS digest,
       COUNT_STAR AS executions,
       ROUND(SUM_TIMER_WAIT / 1000000000000, 3) AS total_seconds,
       ROUND(AVG_TIMER_WAIT / 1000000000, 3) AS average_ms,
       SUM_ROWS_EXAMINED, SUM_ROWS_SENT
FROM performance_schema.events_statements_summary_by_digest
WHERE DIGEST IS NOT NULL
ORDER BY SUM_TIMER_WAIT DESC
LIMIT 10;

This MySQL Performance Schema query ranks accumulated execution time, not a recent-window p95. Timers are expressed in picoseconds. Check instrumentation and reset history; an empty result does not prove an idle server. Frequent short queries can cost more overall than one slow query. Compare rows examined with rows returned, then inspect representative parameters with EXPLAIN FORMAT=JSON. EXPLAIN ANALYZE executes the statement: use a controlled environment and a supported version.

Match the intervention to the bottleneck

Signal How to confirm Next action
High CPU Digest cost, scans, active threads Reduce examined rows and unnecessary work
Read I/O pressure Physical-read deltas and storage latency Check access paths and working-set fit
Write stalls Log waits, flush latency, transaction size Review redo capacity and storage; retain required durability
Lock waits Blocking transaction and access order Shorten transactions and review indexing

Validate one change at a time

Write down the hypothesis, previous setting or schema, expected benefit and rollback trigger. Warm caches consistently, repeat representative trials, and retain raw results. Compare latency, throughput, errors, CPU, memory, I/O and replica lag together. Reject a faster query if correctness, durability or other important workloads regress. Recheck during peak traffic and a full business cycle before keeping the change.

Continue the investigation

  • Health checks establish availability and capacity.
  • Schema checks and performance parameters cover targeted interventions.

Official references

  • MySQL Performance Schema
  • MySQL EXPLAIN
PmaControl
+33 6 63 28 27 47 contact@pmacontrol.com
Legal notice GitHub Contact
Do not wait for an incident to understand your architecture. © 2014-2026 PmaControl — 68Koncept