MySQL Performance Tuning Tools: mysqltuner.pl, tuning-primer.sh, pt-variable-advisor, and pt-query-digest
This article introduces four open‑source MySQL performance tools—mysqltuner.pl, tuning‑primer.sh, pt‑variable‑advisor, and pt‑query‑digest—explaining their purpose, how to download and run them, and how to interpret the diagnostic reports they generate for database optimization.
MySQL performance can be evaluated and optimized using several open‑source tools.
mysqltuner.pl
mysqltuner.pl is a widely used diagnostic script that checks MySQL/MariaDB/Percona Server configuration, logs, storage engines, security suggestions and performance metrics, offering improvement recommendations.
Project: https://github.com/major/MySQLTuner-perl
Download
[root@localhost ~]# wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.plRun
[root@localhost ~]# ./mysqltuner.pl --socket /var/lib/mysql/mysql.sockReport analysis
Key items marked with [!!] indicate serious issues such as memory over‑allocation. Review the “Recommendations” section for actionable advice.
tuning-primer.sh
tuning‑primer.sh performs a comprehensive health check of a MySQL instance and provides optimization suggestions.
Project: https://github.com/BMDan/tuning-primer.sh
Download
[root@localhost ~]# wget https://launchpad.net/mysql-tuning-primer/trunk/1.6-r1/+download/tuning-primer.shRun
[root@localhost dba]# ./tuning-primer.shReport analysis
Focus on entries highlighted in red; adjust settings according to the tool’s suggestions.
pt-variable-advisor
Part of Percona Toolkit, pt‑variable‑advisor examines MySQL variables and flags potential problems.
Download from Percona Toolkit: https://www.percona.com/downloads/percona-toolkit/LATEST/
Install
[root@localhost ~]# wget https://www.percona.com/downloads/percona-toolkit/3.0.13/binary/redhat/7/x86_64/percona-toolkit-3.0.13-re85ce15-el7-x86_64-bundle.tar
[root@localhost ~]# yum install percona-toolkit-3.0.13-1.el7.x86_64.rpmRun
[root@localhost ~]# pt-variable-advisor localhost --socket /var/lib/mysql/mysql.sockReport analysis
Pay attention to entries marked with WARN for possible misconfigurations.
pt-query-digest
pt‑query‑digest parses MySQL slow‑query logs, process lists or tcpdump captures to produce detailed query performance statistics.
Install
Same as pt‑variable‑advisor (see section 3.1).
Run examples
# Analyze a slow‑log file
pt-query-digest /var/lib/mysql/slowtest-slow.log > slow_report.log
# Analyze the last 12 hours
pt-query-digest --since=12h /var/lib/mysql/slowtest-slow.log > recent_report.log
# Filter by time range
pt-query-digest /var/lib/mysql/slowtest-slow.log --since '2017-01-07 09:30:00' --until '2017-01-07 10:00:00' > range_report.log
# Show only SELECT statements
pt-query-digest --filter '$event->{fingerprint} =~ m/^select/i' /var/lib/mysql/slowtest-slow.log > select_report.log
# Show warnings for full scans or joins
pt-query-digest --filter '(($event->{Full_scan} || "") eq "yes") || (($event->{Full_join} || "") eq "yes")' /var/lib/mysql/slowtest-slow.log > scan_report.logReport analysis
The output is divided into overall statistics, query‑group statistics, and detailed per‑query metrics such as total time, calls, average time per call, and variance‑to‑mean ratio.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.