11# !/usr/bin/env perl
2- # mysqltuner.pl - Version 1.9.8
2+ # mysqltuner.pl - Version 1.9.9
33# High Performance MySQL Tuning Script
44# Copyright (C) 2006-2022 Major Hayden - [email protected] 55# Copyright (C) 2006-2022 Jean-Marie Renouard - [email protected] @@ -57,7 +57,7 @@ package main;
5757# use Env;
5858
5959# Set up a few variables for use in the script
60- my $tunerversion = " 1.9.8 " ;
60+ my $tunerversion = " 1.9.9 " ;
6161my ( @adjvars , @generalrec );
6262
6363# Set defaults
@@ -190,24 +190,24 @@ package main;
190190
191191# check if we need to enable verbose mode
192192if ( $opt {verbose } ) {
193- $opt {checkversion } = 1; # Check for updates to MySQLTuner
194- $opt {dbstat } = 1; # Print database information
195- $opt {tbstat } = 1; # Print database information
196- $opt {idxstat } = 1; # Print index information
197- $opt {sysstat } = 1; # Print index information
198- $opt {buffers } = 1; # Print global and per-thread buffer values
199- $opt {pfstat } = 1; # Print performance schema info.
193+ $opt {checkversion } = 1; # Check for updates to MySQLTuner
194+ $opt {dbstat } = 1; # Print database information
195+ $opt {tbstat } = 1; # Print database information
196+ $opt {idxstat } = 1; # Print index information
197+ $opt {sysstat } = 1; # Print index information
198+ $opt {buffers } = 1; # Print global and per-thread buffer values
199+ $opt {pfstat } = 1; # Print performance schema info.
200200 $opt {cvefile } = ' vulnerabilities.csv' ; # CVE File for vulnerability checks
201201}
202202$opt {nocolor } = 1 if defined ( $opt {outputfile } );
203203$opt {tbstat } = 0 if ( $opt {notbstat } == 1 ); # Don't Print table information
204204$opt {colstat } = 0 if ( $opt {nocolstat } == 1 ); # Don't Print column information
205205$opt {dbstat } = 0 if ( $opt {nodbstat } == 1 ); # Don't Print database information
206206$opt {noprocess } = 0
207- if ( $opt {noprocess } == 1 ); # Don't Print process information
207+ if ( $opt {noprocess } == 1 ); # Don't Print process information
208208$opt {sysstat } = 0 if ( $opt {nosysstat } == 1 ); # Don't Print sysstat information
209209$opt {pfstat } = 0
210- if ( $opt {nopfstat } == 1 ); # Don't Print performance schema information
210+ if ( $opt {nopfstat } == 1 ); # Don't Print performance schema information
211211$opt {idxstat } = 0 if ( $opt {noidxstat } == 1 ); # Don't Print index information
212212
213213# for RPM distributions
@@ -995,7 +995,6 @@ sub mysql_setup {
995995 exit 1;
996996 }
997997 }
998-
999998}
1000999
10011000# MySQL Request Array
@@ -1004,7 +1003,7 @@ sub select_array {
10041003 debugprint " PERFORM: $req " ;
10051004 my @result = ` $mysqlcmd $mysqllogin -Bse "\\ w$req " 2>>/dev/null` ;
10061005 if ( $? != 0 ) {
1007- badprint " failed to execute: $req " ;
1006+ badprint " Failed to execute: $req " ;
10081007 badprint " FAIL Execute SQL / return code: $? " ;
10091008 debugprint " CMD : $mysqlcmd " ;
10101009 debugprint " OPTIONS: $mysqllogin " ;
@@ -1029,7 +1028,7 @@ sub select_one {
10291028 debugprint " PERFORM: $req " ;
10301029 my $result = ` $mysqlcmd $mysqllogin -Bse "\\ w$req " 2>>/dev/null` ;
10311030 if ( $? != 0 ) {
1032- badprint " failed to execute: $req " ;
1031+ badprint " Failed to execute: $req " ;
10331032 badprint " FAIL Execute SQL / return code: $? " ;
10341033 debugprint " CMD : $mysqlcmd " ;
10351034 debugprint " OPTIONS: $mysqllogin " ;
@@ -1050,7 +1049,7 @@ sub select_one_g {
10501049 debugprint " PERFORM: $req " ;
10511050 my @result = ` $mysqlcmd $mysqllogin -re "\\ w$req \\ G" 2>>/dev/null` ;
10521051 if ( $? != 0 ) {
1053- badprint " failed to execute: $req " ;
1052+ badprint " Failed to execute: $req " ;
10541053 badprint " FAIL Execute SQL / return code: $? " ;
10551054 debugprint " CMD : $mysqlcmd " ;
10561055 debugprint " OPTIONS: $mysqllogin " ;
@@ -1377,7 +1376,7 @@ sub log_file_recommendations {
13771376 goodprint " Log file $myvar {'log_error'} exists" ;
13781377 my $size = ( stat $myvar {' log_error' } )[7];
13791378 infoprint " Log file: "
1380- . $myvar {' log_error' } . " ("
1379+ . $myvar {' log_error' } . " ("
13811380 . hr_bytes_rnd($size ) . " )" ;
13821381
13831382 if ( $size > 0 ) {
@@ -2414,7 +2413,7 @@ sub check_storage_engines {
24142413 }
24152414 $result {' Tables' }{' Fragmented tables' } =
24162415 [ select_array
2417- " SELECT CONCAT(CONCAT(TABLE_SCHEMA, '.'), TABLE_NAME),cast(DATA_FREE as signed) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','performance_schema', 'mysql') AND DATA_LENGTH/1024/1024>100 AND cast(DATA_FREE as signed)*100/(DATA_LENGTH+INDEX_LENGTH+cast(DATA_FREE as signed)) > 10 AND NOT ENGINE='MEMORY' $not_innodb "
2416+ " SELECT CONCAT(CONCAT(TABLE_SCHEMA, '.'), TABLE_NAME),cast(DATA_FREE as signed) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql') AND DATA_LENGTH/1024/1024>100 AND cast(DATA_FREE as signed)*100/(DATA_LENGTH+INDEX_LENGTH+cast(DATA_FREE as signed)) > 10 AND NOT ENGINE='MEMORY' $not_innodb "
24182417 ];
24192418 $fragtables = scalar @{ $result {' Tables' }{' Fragmented tables' } };
24202419
@@ -3180,7 +3179,7 @@ sub mysql_stats {
31803179 }
31813180 elsif ( $result {' Variables' }{' skip_name_resolve' } eq ' OFF' ) {
31823181 badprint
3183- " name resolution is active : a reverse name resolution is made for each new connection and can reduce performance" ;
3182+ " Name resolution is active: a reverse name resolution is made for each new connection and can reduce performance" ;
31843183 push ( @generalrec ,
31853184" Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1"
31863185 );
@@ -3481,7 +3480,6 @@ sub mysql_stats {
34813480 $mystat {' Table_open_cache_misses' } )
34823481 . " requests)" ;
34833482 }
3484-
34853483 }
34863484 }
34873485
@@ -3495,19 +3493,19 @@ sub mysql_stats {
34953493 . " ) is in autosizing mode" );
34963494 }
34973495 elsif ( $myvar {' table_definition_cache' } < $nbtables ) {
3498- badprint " table_definition_cache("
3496+ badprint " table_definition_cache ("
34993497 . $myvar {' table_definition_cache' }
3500- . " ) is lower than number of tables($nbtables ) " ;
3498+ . " ) is less than number of tables ($nbtables ) " ;
35013499 push ( @adjvars ,
35023500 " table_definition_cache("
35033501 . $myvar {' table_definition_cache' } . " ) > "
35043502 . $nbtables
35053503 . " or -1 (autosizing if supported)" );
35063504 }
35073505 else {
3508- goodprint " table_definition_cache("
3506+ goodprint " table_definition_cache ("
35093507 . $myvar {' table_definition_cache' }
3510- . " ) is upper than number of tables($nbtables )" ;
3508+ . " ) is greater than number of tables ($nbtables )" ;
35113509 }
35123510 }
35133511 else {
@@ -3738,7 +3736,7 @@ sub mysql_myisam {
37383736sub mariadb_threadpool {
37393737 subheaderprint " ThreadPool Metrics" ;
37403738
3741- # AriaDB
3739+ # MariaDB
37423740 unless ( defined $myvar {'have_threadpool'}
37433741 && $myvar {'have_threadpool'} eq " YES" )
37443742 {
@@ -3988,7 +3986,7 @@ sub mysqsl_pfs {
39883986 if ( $nbL == 1 );
39893987
39903988 # Top user per io
3991- subheaderprint "Performance schema: Top 5 user per io ";
3989+ subheaderprint "Performance schema: Top 5 user per IO ";
39923990 $nbL = 1;
39933991 for my $lQuery (
39943992 select_array(
@@ -4003,7 +4001,7 @@ sub mysqsl_pfs {
40034001 if ( $nbL == 1 );
40044002
40054003 # Top user per io latency
4006- subheaderprint "Performance schema: Top 5 user per io latency";
4004+ subheaderprint "Performance schema: Top 5 user per IO latency";
40074005 $nbL = 1;
40084006 for my $lQuery (
40094007 select_array(
@@ -4498,7 +4496,7 @@ sub mysqsl_pfs {
44984496 if ( $nbL == 1 );
44994497
45004498 # Latest file IO by latency
4501- subheaderprint "Performance schema: Latest FILE IO by latency";
4499+ subheaderprint "Performance schema: Latest File IO by latency";
45024500 $nbL = 1;
45034501 for my $lQuery (
45044502 select_array(
@@ -4513,7 +4511,7 @@ sub mysqsl_pfs {
45134511 if ( $nbL == 1 );
45144512
45154513 # FILE by IO read bytes
4516- subheaderprint "Performance schema: FILE by IO read bytes";
4514+ subheaderprint "Performance schema: File by IO read bytes";
45174515 $nbL = 1;
45184516 for my $lQuery (
45194517 select_array(
@@ -4528,7 +4526,7 @@ sub mysqsl_pfs {
45284526 if ( $nbL == 1 );
45294527
45304528 # FILE by IO written bytes
4531- subheaderprint "Performance schema: FILE by IO written bytes";
4529+ subheaderprint "Performance schema: File by IO written bytes";
45324530 $nbL = 1;
45334531 for my $lQuery (
45344532 select_array(
@@ -4543,7 +4541,7 @@ sub mysqsl_pfs {
45434541 if ( $nbL == 1 );
45444542
45454543 # file per IO total latency
4546- subheaderprint "Performance schema: file per IO total latency";
4544+ subheaderprint "Performance schema: File per IO total latency";
45474545 $nbL = 1;
45484546 for my $lQuery (
45494547 select_array(
@@ -4679,7 +4677,7 @@ sub mysqsl_pfs {
46794677 if ( $nbL == 1 );
46804678
46814679 # TOP 15 most used index
4682- subheaderprint "Performance schema: TOP 15 most modified indexes";
4680+ subheaderprint "Performance schema: Top 15 most modified indexes";
46834681 $nbL = 1;
46844682 for my $lQuery (
46854683 select_array(
@@ -4694,7 +4692,7 @@ sub mysqsl_pfs {
46944692 if ( $nbL == 1 );
46954693
46964694 # TOP 15 high read latency index
4697- subheaderprint "Performance schema: TOP 15 high read latency index";
4695+ subheaderprint "Performance schema: Top 15 high read latency index";
46984696 $nbL = 1;
46994697 for my $lQuery (
47004698 select_array(
@@ -4709,7 +4707,7 @@ sub mysqsl_pfs {
47094707 if ( $nbL == 1 );
47104708
47114709 # TOP 15 high insert latency index
4712- subheaderprint "Performance schema: TOP 15 most modified indexes";
4710+ subheaderprint "Performance schema: Top 15 most modified indexes";
47134711 $nbL = 1;
47144712 for my $lQuery (
47154713 select_array(
@@ -4724,7 +4722,7 @@ sub mysqsl_pfs {
47244722 if ( $nbL == 1 );
47254723
47264724 # TOP 15 high update latency index
4727- subheaderprint "Performance schema: TOP 15 high update latency index";
4725+ subheaderprint "Performance schema: Top 15 high update latency index";
47284726 $nbL = 1;
47294727 for my $lQuery (
47304728 select_array(
@@ -4739,7 +4737,7 @@ sub mysqsl_pfs {
47394737 if ( $nbL == 1 );
47404738
47414739 # TOP 15 high delete latency index
4742- subheaderprint "Performance schema: TOP 15 high delete latency index";
4740+ subheaderprint "Performance schema: Top 15 high delete latency index";
47434741 $nbL = 1;
47444742 for my $lQuery (
47454743 select_array(
@@ -4769,7 +4767,7 @@ sub mysqsl_pfs {
47694767 if ( $nbL == 1 );
47704768
47714769 # TOP 15 most used tables
4772- subheaderprint "Performance schema: TOP 15 most modified tables";
4770+ subheaderprint "Performance schema: Top 15 most modified tables";
47734771 $nbL = 1;
47744772 for my $lQuery (
47754773 select_array(
@@ -4784,7 +4782,7 @@ sub mysqsl_pfs {
47844782 if ( $nbL == 1 );
47854783
47864784 # TOP 15 high read latency tables
4787- subheaderprint "Performance schema: TOP 15 high read latency tables";
4785+ subheaderprint "Performance schema: Top 15 high read latency tables";
47884786 $nbL = 1;
47894787 for my $lQuery (
47904788 select_array(
@@ -4799,7 +4797,7 @@ sub mysqsl_pfs {
47994797 if ( $nbL == 1 );
48004798
48014799 # TOP 15 high insert latency tables
4802- subheaderprint "Performance schema: TOP 15 high insert latency tables";
4800+ subheaderprint "Performance schema: Top 15 high insert latency tables";
48034801 $nbL = 1;
48044802 for my $lQuery (
48054803 select_array(
@@ -4814,7 +4812,7 @@ sub mysqsl_pfs {
48144812 if ( $nbL == 1 );
48154813
48164814 # TOP 15 high update latency tables
4817- subheaderprint "Performance schema: TOP 15 high update latency tables";
4815+ subheaderprint "Performance schema: Top 15 high update latency tables";
48184816 $nbL = 1;
48194817 for my $lQuery (
48204818 select_array(
@@ -4829,7 +4827,7 @@ sub mysqsl_pfs {
48294827 if ( $nbL == 1 );
48304828
48314829 # TOP 15 high delete latency tables
4832- subheaderprint "Performance schema: TOP 15 high delete latency tables";
4830+ subheaderprint "Performance schema: Top 15 high delete latency tables";
48334831 $nbL = 1;
48344832 for my $lQuery (
48354833 select_array(
@@ -5930,7 +5928,7 @@ sub mysql_innodb {
59305928 or $mycalc {'innodb_log_size_pct'} > 30 )
59315929 {
59325930 badprint " Ratio InnoDB log file size / InnoDB Buffer pool size ("
5933- . $mycalc {'innodb_log_size_pct'} . " %): "
5931+ . $mycalc {'innodb_log_size_pct'} . " %): "
59345932 . hr_bytes( $myvar {'innodb_log_file_size'} ) . " * "
59355933 . $myvar {'innodb_log_files_in_group'} . " /"
59365934 . hr_bytes( $myvar {'innodb_buffer_pool_size'} )
@@ -5942,7 +5940,7 @@ sub mysql_innodb {
59425940 $myvar {'innodb_buffer_pool_size'} /
59435941 $myvar {'innodb_log_files_in_group'} / 4
59445942 )
5945- . " ) if possible, so InnoDB total log files size equals to 25% of buffer pool size."
5943+ . " ) if possible, so InnoDB total log files size equals 25% of buffer pool size."
59465944 );
59475945 if ( mysql_version_le( 5, 6, 2 ) ) {
59485946 push( @generalrec ,
@@ -6020,7 +6018,7 @@ sub mysql_innodb {
60206018 " InnoDB Buffer Pool Chunk Size not used or defined in your version" ;
60216019 }
60226020 else {
6023- infoprint " Number of InnoDB Buffer Pool Chunk : "
6021+ infoprint " Number of InnoDB Buffer Pool Chunk: "
60246022 . int( $myvar {'innodb_buffer_pool_size'} ) /
60256023 int( $myvar {'innodb_buffer_pool_chunk_size'} ) . " for "
60266024 . $myvar {'innodb_buffer_pool_instances'}
@@ -6380,7 +6378,6 @@ sub mysql_databases {
63806378 . " table column(s ) has same collation defined for all text like column(s )." ;
63816379 }
63826380 }
6383-
63846381}
63856382
63866383# Recommendations for database columns
@@ -6482,14 +6479,12 @@ sub mysql_tables {
64826479" ALTER TABLE \` $dbname \` .\` $tbname \` MODIFY \` $_ \` $optimal_type ;"
64836480 );
64846481 }
6485-
64866482 }
64876483 else {
64886484 goodprint "$dbname .$tbname ($_ ) type: $current_type ";
64896485 }
64906486 }
64916487 }
6492-
64936488 }
64946489}
64956490
66306625 "Skip Index metrics from information schema missing in this version";
66316626 return;
66326627 }
6633-
66346628}
66356629
66366630sub mysql_routines() {
66406634 "Skip Index metrics from information schema missing in this version";
66416635 return;
66426636 }
6643-
66446637}
66456638
66466639sub mysql_triggers() {
66506643 "Skip Index metrics from information schema missing in this version";
66516644 return;
66526645 }
6653-
66546646}
66556647
66566648# Take the two recommendation arrays and display them at the end of the output
@@ -6875,7 +6867,7 @@ sub which {
68756867
68766868=head1 NAME
68776869
6878- MySQLTuner 1.9.8 - MySQL High Performance Tuning Script
6870+ MySQLTuner 1.9.9 - MySQL High Performance Tuning Script
68796871
68806872=head1 IMPORTANT USAGE GUIDELINES
68816873
0 commit comments