MySQL Performance Tuning: Tips, Scripts and Tools

With MySQL, common configuration mistakes can cause serious performance problems. In fact, if you misconfigure just one of the many config parameters, it can cripple performance. Of course, the performance of MySQL is often tied to the efficiency of your MySQL queries. It’s important to ensure that your performance issues are not due to poorly written MySQL queries. You can use MySQL’s slow query log, log_queries_not_using_indexes or APM tools which offer MySQL performance monitoring such as Datadog, InstrumentalPanoptaSite24x7Solarwinds, and other monitoring tools.

MySQL tuning is quite an expansive topic. As such, today I won’t try to place any recommended config lines, values, or settings here. Be very cautious with recommended-settings based articles. This post assumes that you’ve already optimized your queries and now seek guidance with selecting the best performance config options (ex: my.cnf) for MySQL. This can vary greatly case by case as there’s very little no one-size-fits-all advice. Therefore, also included below the tips, are additional links to popular free MySQL tuning scripts and tools.


Stay up to date with the latest MySQL server versions

With each new version of MySQL released, there’s substantial performance and feature enhancements over previous versions. So the most important advice would be to upgrade, upgrade, upgrade. Have a look at some version performance comparisons here.

If you are seeking additional features or flexibility you may already be using MariaDB, or Percona, which are enhanced drop-in replacements for MySQL Server. If you’ve seen notable improvements in using MariaDB or Percona over stock MySQL please share your experience below. They are both great options.


MySQL Performance Tuning Advice

Before continuing please have a look at the following MySQL performance tuning articles: MySQL Database Performance: Avoid this common mistake and note that due to the limitations of MySQL query cache, it has been deprecated as of MySQL 5.7.20 and is removed in MySQL 8.0.

Other than the tuning scripts listed below, try to avoid online advice unless its via or those that reference directly MySQL, Pecona’s, or MariaDB articles or documentation. You will notice that both of the above blog posts reference or quote MySQL’s docs. There’s a ton of conflicting advice and opinions online. As such, my advice is to always crosscheck your config changes with official documentation. This includes everything I say here. In fact, when venturing to change MySQL’s defaults, unless you have a basis for changes, its best to leave it as is. When there’s doubt… stick with the defaults.  Always, base your changes on benchmarks, comparisons, and time-tested firsthand data.


Selecting MySQL Storage Engine

This is simple, use InnoDB and avoid MyISAM when possible. For these reasons:

  • Versions of MySQL 5.5 and greater have switched to the InnoDB engine to ensure referential integrity constraints and higher concurrency.
  • InnoDB has better crash recovery.
  • InnoDB has row-level locking, MyISAM can only do full table-level locking.
  • Like MyISAM, InnoDB now has FULLTEXT search indexes as of MySQL 5.6
  • InnoDB supports transactions, foreign keys and relationship constraints, MyISAM does not.


MySQL Performance Tuning Scripts

You cannot replace Professional MySQL tuning with scripts. Scripts serve as basic guides, sometimes spot-on, but most times loose guides which will only solve the most grievous misconfigured parameters. Use them as a starting point. Meaning, before you contact a professional to tune MySQL use these tuning scripts so that at the very least you don’t have any so-called embarrassing config in your my.cnf file. For example, join_buffer_size set to 4GB when the total DB size is less than 1GB.

Now, let’s look at popular scripts and tools available for MySQL performance tuning: MySqlTuner, Tuning-Primer, MySQLreport, Percona Toolkit, and phpMyAdmin Advisor.



A script thas is written in Perl that will assist you with your MySQL configuration and make recommendations for increased performance and stability.

MySQLTuner is maintained and indicator collect is increasing week after week supporting a lot of configurations such as Galera Cluster, TokuDB, Performance schema, Linux OS metrics, InnoDB, MyISAM, Aria, etc. – MySQLTuner on Github.



This script takes information from “SHOW STATUS LIKE…” and “SHOW VARIABLES LIKE…” to produce sane recommendations for tuning server variables. It is compatible with all versions of MySQL 3.23 and higher (including 5.1).

Tuning-Primer Screenshot

The original script is no longer updated. I’ve been using this Tuning-primer version on Github which fully supports MariaDB.


Percona Toolkit

Percona Toolkit is a collection of advanced open-source command-line tools, developed to perform a variety of MySQL tasks that are too difficult or complex to perform manually – freeing your DBAs for work that helps you achieve your business goals.

Useful tools include: pt-align, pt-archiver, pt-config-diff, pt-deadlock-logger, pt-diskstats, pt-duplicate-key-checker, pt-fifo-split, pt-find, pt-fingerprint, pt-fk-error-logger, pt-heartbeat, pt-index-usage, pt-ioprofile, pt-kill, pt-mext, pt-mongodb-query-digest, pt-mongodb-summary, pt-mysql-summary, pt-online-schema-change, pt-pg-summary, pt-pmp, pt-query-digest, pt-secure-collect, pt-show-grants, pt-sift, pt-slave-delay, pt-slave-find, pt-slave-restart, pt-stalk, pt-summary, pt-table-checksum, pt-table-sync, pt-table-usage, pt-upgrade, pt-variable-advisor and pt-visual-explain.


phpMyAdmin Advisor

The Advisor system provides recommendations on server variables by analyzing MySQL status variables.

phpMyAdmin Advisor

phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. Visit: phpmyadmin.



Mysqlreport transforms the values from SHOW STATUS into an easy-to-read report that provides an in-depth understanding of how well MySQL is running. mysqlreport is a better alternative (and practically the only alternative) to manually interpreting SHOW STATUS.

mysqlreport percona Screenshot


Tags: , , , , ,