Skip to content



pt-variable-advisor - Analyze MySQL variables and advise on possible problems.



pt-variable-advisor [OPTIONS] [DSN]

pt-variable-advisor analyzes variables and advises on possible problems.

Get SHOW VARIABLES from localhost:

pt-variable-advisor localhost

Get SHOW VARIABLES output saved in vars.txt:

pt-variable-advisor --source-of-variables vars.txt


Percona Toolkit is mature, proven in the real world, and well tested, but all database tools can pose a risk to the system and the database server. Before using this tool, please:

  • Read the tool’s documentation

  • Review the tool’s known “BUGS”

  • Test the tool on a non-production server

  • Backup your production server and verify the backups


pt-variable-advisor examines SHOW VARIABLES for bad values and settings according to the “RULES” described below. It reports on variables that match the rules, so you can find bad settings in your MySQL server.

At the time of this release, pt-variable-advisor only examines SHOW VARIABLES, but other input sources are planned like SHOW STATUS and SHOW SLAVE STATUS.


These are the rules that pt-variable-advisor will apply to SHOW VARIABLES. Each rule has three parts: an ID, a severity, and a description.

The rule’s ID is a short, unique name for the rule. It usually relates to the variable that the rule examines. If a variable is examined by several rules, then the rules’ IDs are numbered like “-1”, “-2”, “-N”.

The rule’s severity is an indication of how important it is that this rule matched a query. We use NOTE, WARN, and CRIT to denote these levels.

The rule’s description is a textual, human-readable explanation of what it means when a variable matches this rule. Depending on the verbosity of the report you generate, you will see more of the text in the description. By default, you’ll see only the first sentence, which is sort of a terse synopsis of the rule’s meaning. At a higher verbosity, you’ll see subsequent sentences.


severity: note

Are you trying to write to more than one server in a dual-master or ring replication configuration? This is potentially very dangerous and in most cases is a serious mistake. Most people’s reasons for doing this are actually not valid at all.


severity: note

Holes (spaces left by deletes) in MyISAM tables might never be reused.


severity: note

A large value of this setting can create a denial of service vulnerability.


severity: crit

Servers built with debugging capability should not be used in production because of the large performance impact.


severity: warn

MyISAM index blocks are never flushed until necessary. If there is a server crash, data corruption on MyISAM tables can be much worse than usual.


severity: warn

This option might decrease performance greatly.


severity: warn

This option might decrease performance greatly.


severity: note

The BDB engine is deprecated. If you aren’t using it, you should disable it with the skip_bdb option.


severity: note

The init_connect option is enabled on this server.


severity: note

The init_file option is enabled on this server.


severity: note

The init_slave option is enabled on this server.


severity: warn

This variable generally doesn’t need to be larger than 20MB.


severity: warn

The InnoDB buffer pool size is unconfigured. In a production environment it should always be configured explicitly, and the default 10MB size is not good.


severity: warn

InnoDB checksums are disabled. Your data is not protected from hardware corruption or other errors!


severity: warn

InnoDB doublewrite is disabled. Unless you use a filesystem that protects against partial page writes, your data is not safe!


severity: warn

InnoDB’s shutdown behavior is not the default. This can lead to poor performance, or the need to perform crash recovery upon startup.


severity: warn

InnoDB is not configured in strictly ACID mode. If there is a crash, some transactions can be lost.


severity: warn

Setting innodb_flush_log_at_trx_commit to 0 has no performance benefits over setting it to 2, and more types of data loss are possible. If you are trying to change it from 1 for performance reasons, you should set it to 2 instead of 0.


severity: warn

InnoDB is in forced recovery mode! This should be used only temporarily when recovering from data corruption or other bugs, not for normal usage.


severity: warn

This option has an unusually long value, which can cause system overload if locks are not being released.


severity: warn

The InnoDB log buffer size generally should not be set larger than 16MB. If you are doing large BLOB operations, InnoDB is not really a good choice of engines anyway.


severity: warn

The InnoDB log file size is set to its default value, which is not usable on production systems.


severity: note

The innodb_max_dirty_pages_pct is lower than the default. This can cause overly aggressive flushing and add load to the I/O system.


severity: warn

This setting is likely to cause very bad performance every flush_time seconds.


severity: warn

The key buffer size is set to its default value, which is not good for most production systems. In a production environment, key_buffer_size should be larger than the default 8MB size.


severity: note

Large pages are enabled.


severity: note

The server is locked in memory with –memlock.


severity: note

Log_warnings is disabled, so unusual events such as statements unsafe for replication and aborted connections will not be logged to the error log.


severity: note

Log_warnings must be set greater than 1 to log unusual events such as aborted connections.


severity: note

The server is running with non-default lock priority for updates. This could cause update queries to wait unexpectedly for read queries.


severity: note

The max_binlog_size is smaller than the default of 1GB.


severity: note

max_connect_errors should probably be set as large as your platform allows.


severity: warn

If the server ever really has more than a thousand threads running, then the system is likely to spend more time scheduling threads than really doing useful work. This variable’s value should be considered in light of your workload.


severity: note

myisam_repair_threads > 1 enables multi-threaded repair, which is relatively untested and is still listed as beta-quality code in the official documentation.


severity: warn

Old-style passwords are insecure. They are sent in plain text across the wire.


severity: warn

The optimizer will use an exhaustive search when planning complex queries, which can cause the planning process to take a long time.


severity: note

The server is listening on a non-default port.


severity: note

The query cache does not scale to large sizes and can cause unstable performance when larger than 128MB, especially on multi-core machines.


severity: warn

The query cache can cause severe performance problems when it is larger than 256MB, especially on multi-core machines.


severity: note

The read_buffer_size variable should generally be left at its default unless an expert determines it is necessary to change it.


severity: warn

The read_buffer_size variable should not be larger than 8MB. It should generally be left at its default unless an expert determines it is necessary to change it. Making it larger than 2MB can hurt performance significantly, and can make the server crash, swap to death, or just become extremely unstable.


severity: note

The read_rnd_buffer_size variable should generally be left at its default unless an expert determines it is necessary to change it.


severity: warn

The read_rnd_buffer_size variable should not be larger than 4M. It should generally be left at its default unless an expert determines it is necessary to change it.


severity: warn

Setting relay_log_space_limit can cause replicas to stop fetching binary logs from their master immediately. This could increase the risk that your data will be lost if the master crashes. If the replicas have encountered a limit on relay log space, then it is possible that the latest transactions exist only on the master and no replica has retrieved them.


severity: warn

This variable is set too high. This is too long to wait before noticing that the connection to the master has failed and retrying. This should probably be set to 60 seconds or less. It is also a good idea to use pt-heartbeat to ensure that the connection does not appear to time out when the master is simply idle.


severity: crit

You should not set this option. If replication is having errors, you need to find and resolve the cause of that; it is likely that your slave’s data is different from the master. You can find out with pt-table-checksum.


severity: note

The sort_buffer_size variable should generally be left at its default unless an expert determines it is necessary to change it.


severity: note

The sort_buffer_size variable should generally be left at its default unless an expert determines it is necessary to change it. Making it larger than a few MB can hurt performance significantly, and can make the server crash, swap to death, or just become extremely unstable.


severity: note

This server is configured not to log Note level warnings to the error log.


severity: warn

It is best to set sync_frm so that .frm files are flushed safely to disk in case of a server crash.


severity: note

This server’s transaction isolation level is non-default.


severity: warn

Most applications should use the default REPEATABLE-READ transaction isolation level, or in a few cases READ-COMMITTED.


severity: warn

Binary logs are enabled, but automatic purging is not enabled. If you do not purge binary logs, your disk will fill up. If you delete binary logs externally to MySQL, you will cause unwanted behaviors. Always ask MySQL to purge obsolete logs, never delete them externally.


severity: note

This option is useless except on Windows.


severity: note

Auto-extending InnoDB files can consume a lot of disk space that is very difficult to reclaim later. Some people prefer to set innodb_file_per_table and allocate a fixed-size file for ibdata1.


severity: note

Most production database servers that use InnoDB should set innodb_flush_method to O_DIRECT to avoid double-buffering, unless the I/O system is very low performance.


severity: warn

This option makes point-in-time recovery from binary logs, and replication, untrustworthy if statement-based logging is used.


severity: warn

MySQL’s internal XA transaction support between InnoDB and the binary log is disabled. The binary log might not match InnoDB’s state after crash recovery, and replication might drift out of sync due to out-of-order statements in the binary log.


severity: warn

Binary logging is disabled, so point-in-time recovery and replication are not possible.


severity: warn

Directing log output to tables has a high performance impact.


severity: note

A custom max_relay_log_size is defined.


severity: warn

myisam_recover_options should be set to some value such as BACKUP,FORCE to ensure that table corruption is noticed.


severity: note

The server is using a non-standard storage engine as default.


severity: warn

Binary logging is enabled, but sync_binlog isn’t configured so that every transaction is flushed to the binary log for durability.


severity: note

The effective minimum size of in-memory implicit temporary tables used internally during query execution is min(tmp_table_size, max_heap_table_size), so max_heap_table_size should be at least as large as tmp_table_size.

old mysql version

severity: warn

These are the recommended minimum version for each major release: 3.23, 4.1.20, 5.0.37, 5.1.30.

end-of-life mysql version

severity: note

Every release older than 5.1 is now officially end-of-life.


This tool accepts additional command-line arguments. Refer to the “SYNOPSIS” and usage information for details.


Prompt for a password when connecting to MySQL.


short form: -A; type: string

Default character set. If the value is utf8, sets Perl’s binmode on STDOUT to utf8, passes the mysql_enable_utf8 option to DBD::mysql, and runs SET NAMES UTF8 after connecting to MySQL. Any other value sets binmode on STDOUT without the utf8 layer, and runs SET NAMES after connecting to MySQL.


type: Array

Read this comma-separated list of config files; if specified, this must be the first option on the command line.


Fork to the background and detach from the shell. POSIX operating systems only.


short form: -D; type: string

Connect to this database.


short form: -F; type: string

Only read mysql options from the given file. You must give an absolute pathname.


Show help and exit.


short form: -h; type: string

Connect to host.


type: hash

Ignore these rule IDs.

Specify a comma-separated list of rule IDs (e.g. LIT.001,RES.002,etc.) to ignore.


short form: -p; type: string

Password to use when connecting. If password contains commas they must be escaped with a backslash: “exam,ple”


type: string

Create the given PID file. The tool won’t start if the PID file already exists and the PID it contains is different than the current PID. However, if the PID file exists and the PID it contains is no longer running, the tool will overwrite the PID file with the current PID. The PID file is removed automatically when the tool exits.


short form: -P; type: int

Port number to use for connection.


type: Array

Set the MySQL variables in this comma-separated list of variable=value pairs.

By default, the tool sets:


Variables specified on the command line override these defaults. For example, specifying --set-vars wait_timeout=500 overrides the defaultvalue of 10000.

The tool prints a warning and continues if a variable cannot be set.


short form: -S; type: string

Socket file to use for connection.


type: string; default: mysql

Read SHOW VARIABLES from this source. Possible values are “mysql”, “none” or a file name. If “mysql” is specified then you must also specify a DSN on the command line.


short form: -u; type: string

User for login if not current user.


short form: -v; cumulative: yes; default: 1

Increase verbosity of output. At the default level of verbosity, the program prints only the first sentence of each rule’s description. At higher levels, the program prints more of the description.


Show version and exit.


default: yes

Check for the latest version of Percona Toolkit, MySQL, and other programs.

This is a standard “check for updates automatically” feature, with two additional features. First, the tool checks its own version and also the versions of the following software: operating system, Percona Monitoring and Management (PMM), MySQL, Perl, MySQL driver for Perl (DBD::mysql), and Percona Toolkit. Second, it checks for and warns about versions with known problems. For example, MySQL 5.5.25 had a critical bug and was re-released as 5.5.25a.

A secure connection to Percona’s Version Check database server is done to perform these checks. Each request is logged by the server, including software version numbers and unique ID of the checked system. The ID is generated by the Percona Toolkit installation script or when the Version Check database call is done for the first time.

Any updates or known problems are printed to STDOUT before the tool’s normal output. This feature should never interfere with the normal operation of the tool.

For more information, visit


These DSN options are used to create a DSN. Each option is given like option=value. The options are case-sensitive, so P and p are not the same option. There cannot be whitespace before or after the = and if the value contains whitespace it must be quoted. DSN options are comma-separated. See the percona-toolkit manpage for full details.

  • A

dsn: charset; copy: yes

Default character set.

  • D

dsn: database; copy: yes

Default database.

  • F

dsn: mysql_read_default_file; copy: yes

Only read default options from the given file

  • h

dsn: host; copy: yes

Connect to host.

  • p

dsn: password; copy: yes

Password to use when connecting. If password contains commas they must be escaped with a backslash: “exam,ple”

  • P

dsn: port; copy: yes

Port number to use for connection.

  • S

dsn: mysql_socket; copy: yes

Socket file to use for connection.

  • u

dsn: user; copy: yes

User for login if not current user.


The environment variable PTDEBUG enables verbose debugging output to STDERR. To enable debugging and capture all output to a file, run the tool like:

PTDEBUG=1 pt-variable-advisor ... > FILE 2>&1

Be careful: debugging output is voluminous and can generate several megabytes of output.


Using <PTDEBUG> might expose passwords. When debug is enabled, all command line parameters are shown in the output.


You need Perl, DBI, DBD::mysql, and some core packages that ought to be installed in any reasonably new version of Perl.


For a list of known bugs, see

Please report bugs at Include the following information in your bug report:

  • Complete command-line used to run the tool

  • Tool --version

  • MySQL version of all servers involved

  • Output from the tool including STDERR

  • Input files (log/dump/config files, etc.)

If possible, include debugging output by running the tool with PTDEBUG; see “ENVIRONMENT”.


Visit to download the latest release of Percona Toolkit. Or, get the latest release from the command line:




You can also get individual tools from the latest release:


Replace TOOL with the name of any tool.


Baron Schwartz and Daniel Nichter


This tool is part of Percona Toolkit, a collection of advanced command-line tools for MySQL developed by Percona. Percona Toolkit was forked from two projects in June, 2011: Maatkit and Aspersa. Those projects were created by Baron Schwartz and primarily developed by him and Daniel Nichter. Visit to learn about other free, open-source software from Percona.


pt-variable-advisor 3.5.7