diff --git a/mysqltuner.pl b/mysqltuner.pl index 7ab7be9..5df44b0 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -681,7 +681,7 @@ sub mysql_setup { $opt{port} = ( $opt{port} eq 0 ) ? 3306 : $opt{port}; # If we're doing a remote connection, but forcemem wasn't specified, we need to exit - if ( $opt{'forcemem'} eq 0 + if ( $opt{'forcemem'} eq 0 && ( $opt{host} ne "127.0.0.1" ) && ( $opt{host} ne "localhost" ) ) { @@ -805,17 +805,18 @@ sub mysql_setup { "Attempted to use login credentials from debian maintenance account, but they failed."; exit 1; } - } elsif ($opt{'defaults-file'} ne 0 and -r "$opt{'defaults-file'}") { - # defaults-file - debugprint "defaults file detected: $opt{'defaults-file'}"; - my $mysqlclidefaults = `$mysqlcmd --print-defaults`; - debugprint "MySQL Client Default File: $opt{'defaults-file'}"; + } + elsif ( $opt{'defaults-file'} ne 0 and -r "$opt{'defaults-file'}" ) { - $mysqllogin = "--defaults-file=".$opt{'defaults-file'}; + # defaults-file + debugprint "defaults file detected: $opt{'defaults-file'}"; + my $mysqlclidefaults = `$mysqlcmd --print-defaults`; + debugprint "MySQL Client Default File: $opt{'defaults-file'}"; + + $mysqllogin = "--defaults-file=" . $opt{'defaults-file'}; my $loginstatus = `$mysqladmincmd $mysqllogin ping 2>&1`; if ( $loginstatus =~ /mysqld is alive/ ) { - goodprint - "Logged in using credentials from defaults file account."; + goodprint "Logged in using credentials from defaults file account."; return 1; } } @@ -1525,10 +1526,11 @@ sub security_recommendations { # Looking for Empty Password if ( mysql_version_ge( 5, 5 ) ) { - @mysqlstatlist = select_array + @mysqlstatlist = select_array "SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE ($PASS_COLUMN_NAME = '' OR $PASS_COLUMN_NAME IS NULL) AND plugin NOT IN ('unix_socket', 'win_socket')"; - } else { - @mysqlstatlist = select_array + } + else { + @mysqlstatlist = select_array "SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE ($PASS_COLUMN_NAME = '' OR $PASS_COLUMN_NAME IS NULL)"; } if (@mysqlstatlist) { @@ -1658,7 +1660,7 @@ sub get_replication_status { badprint "This replication slave is not running but seems to be configured."; } - if ( defined($io_running) + if ( defined($io_running) && $io_running =~ /yes/i && $sql_running =~ /yes/i ) { @@ -1898,7 +1900,7 @@ sub check_storage_engines { # Now we build a database list, and loop through it to get storage engine stats for tables foreach my $db (@dblist) { chomp($db); - if ( $db eq "information_schema" + if ( $db eq "information_schema" or $db eq "performance_schema" or $db eq "mysql" or $db eq "lost+found" ) @@ -2516,7 +2518,7 @@ sub mysql_stats { } } - if ( $arch + if ( $arch && $arch == 32 && $mycalc{'max_used_memory'} > 2 * 1024 * 1024 * 1024 ) { @@ -2751,7 +2753,7 @@ sub mysql_stats { # Temporary tables if ( $mystat{'Created_tmp_tables'} > 0 ) { - if ( $mycalc{'pct_temp_disk'} > 25 + if ( $mycalc{'pct_temp_disk'} > 25 && $mycalc{'max_tmp_table_size'} < 256 * 1024 * 1024 ) { badprint @@ -2889,7 +2891,8 @@ sub mysql_stats { . hr_num( $myvar{'open_files_limit'} ) . ")"; push( @adjvars, "open_files_limit (> " . $myvar{'open_files_limit'} . ")" ); - } else { + } + else { goodprint "Open file limit used: $mycalc{'pct_files_open'}% (" . hr_num( $mystat{'Open_files'} ) . "/" . hr_num( $myvar{'open_files_limit'} ) . ")"; @@ -2903,7 +2906,8 @@ sub mysql_stats { "Table locks acquired immediately: $mycalc{'pct_table_locks_immediate'}%"; push( @generalrec, "Optimize queries and/or use InnoDB to reduce lock wait" ); - } else { + } + else { goodprint "Table locks acquired immediately: $mycalc{'pct_table_locks_immediate'}% (" . hr_num( $mystat{'Table_locks_immediate'} ) @@ -2916,11 +2920,13 @@ sub mysql_stats { # Binlog cache if ( defined $mycalc{'pct_binlog_cache'} ) { - if ( $mycalc{'pct_binlog_cache'} < 90 - && $mystat{'Binlog_cache_use'} > 0 ) { + if ( $mycalc{'pct_binlog_cache'} < 90 + && $mystat{'Binlog_cache_use'} > 0 ) + { badprint "Binlog cache memory access: " . $mycalc{'pct_binlog_cache'} . "% (" - . ( $mystat{'Binlog_cache_use'} - $mystat{'Binlog_cache_disk_use'} ) + . ( + $mystat{'Binlog_cache_use'} - $mystat{'Binlog_cache_disk_use'} ) . " Memory / " . $mystat{'Binlog_cache_use'} . " Total)"; @@ -2932,10 +2938,12 @@ sub mysql_stats { "binlog_cache_size (" . hr_bytes( $myvar{'binlog_cache_size'} + 16 * 1024 * 1024 ) . ")" ); - } else { + } + else { goodprint "Binlog cache memory access: " . $mycalc{'pct_binlog_cache'} . "% (" - . ( $mystat{'Binlog_cache_use'} - $mystat{'Binlog_cache_disk_use'} ) + . ( + $mystat{'Binlog_cache_use'} - $mystat{'Binlog_cache_disk_use'} ) . " Memory / " . $mystat{'Binlog_cache_use'} . " Total)"; @@ -2947,9 +2955,11 @@ sub mysql_stats { # Performance options if ( !mysql_version_ge( 5, 1 ) ) { push( @generalrec, "Upgrade to MySQL 5.5+ to use asynchronous write" ); - } elsif ( $myvar{'concurrent_insert'} eq "OFF" ) { + } + elsif ( $myvar{'concurrent_insert'} eq "OFF" ) { push( @generalrec, "Enable concurrent_insert by setting it to 'ON'" ); - } elsif ( $myvar{'concurrent_insert'} eq 0 ) { + } + elsif ( $myvar{'concurrent_insert'} eq 0 ) { push( @generalrec, "Enable concurrent_insert by setting it to 1" ); } } @@ -2980,7 +2990,8 @@ sub mysql_myisam { . hr_num( $myvar{'key_buffer_size'} ) . " cache)"; } - } else { + } + else { # No queries have run that would use keys debugprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% (" . hr_num( @@ -2995,14 +3006,17 @@ sub mysql_myisam { push( @generalrec, "Unable to calculate MyISAM indexes on remote MySQL server < 5.0.0" ); - } elsif ( $mycalc{'total_myisam_indexes'} =~ /^fail$/ ) { + } + elsif ( $mycalc{'total_myisam_indexes'} =~ /^fail$/ ) { badprint "Cannot calculate MyISAM index size - re-run script as root user"; - } elsif ( $mycalc{'total_myisam_indexes'} == "0" ) { + } + elsif ( $mycalc{'total_myisam_indexes'} == "0" ) { badprint "None of your MyISAM tables are indexed - add indexes immediately"; - } else { - if ( $myvar{'key_buffer_size'} < $mycalc{'total_myisam_indexes'} + } + else { + if ( $myvar{'key_buffer_size'} < $mycalc{'total_myisam_indexes'} && $mycalc{'pct_keys_from_mem'} < 95 ) { badprint "Key buffer size / total MyISAM indexes: " @@ -3012,7 +3026,8 @@ sub mysql_myisam { "key_buffer_size (> " . hr_bytes( $mycalc{'total_myisam_indexes'} ) . ")" ); - } else { + } + else { goodprint "Key buffer size / total MyISAM indexes: " . hr_bytes( $myvar{'key_buffer_size'} ) . "/" . hr_bytes( $mycalc{'total_myisam_indexes'} ) . ""; @@ -3025,7 +3040,8 @@ sub mysql_myisam { . " cached / " . hr_num( $mystat{'Key_reads'} ) . " reads)"; - } else { + } + else { goodprint "Read Key buffer hit rate: $mycalc{'pct_keys_from_mem'}% (" . hr_num( $mystat{'Key_read_requests'} ) @@ -3033,7 +3049,8 @@ sub mysql_myisam { . hr_num( $mystat{'Key_reads'} ) . " reads)"; } - } else { + } + else { # No queries have run that would use keys debugprint "Key buffer size / total MyISAM indexes: " . hr_bytes( $myvar{'key_buffer_size'} ) . "/" @@ -3047,7 +3064,8 @@ sub mysql_myisam { . " cached / " . hr_num( $mystat{'Key_writes'} ) . " writes)"; - } else { + } + else { goodprint "Write Key buffer hit rate: $mycalc{'pct_wkeys_from_mem'}% (" . hr_num( $mystat{'Key_write_requests'} ) @@ -3055,7 +3073,8 @@ sub mysql_myisam { . hr_num( $mystat{'Key_writes'} ) . " writes)"; } - } else { + } + else { # No queries have run that would use keys debugprint "Write Key buffer hit rate: $mycalc{'pct_wkeys_from_mem'}% (" @@ -3088,7 +3107,7 @@ sub mariadb_threadpool { } if ( $myvar{'have_innodb'} eq 'YES' ) { - if ( $myvar{'thread_pool_size'} < 16 + if ( $myvar{'thread_pool_size'} < 16 or $myvar{'thread_pool_size'} > 36 ) { badprint @@ -3153,790 +3172,1300 @@ sub mysqsl_pfs { infoprint "Memory used by P_S: " . hr_bytes( get_pf_memory() ); unless ( grep /^sys$/, select_array("SHOW DATABASES") ) { - infoprint "Sys schema isn't installed."; - return; + infoprint "Sys schema isn't installed."; + return; } infoprint "Sys schema is installed."; return if ( $opt{pfstat} == 0 ); - infoprint "Sys schema Version: ".select_one("select sys_version from sys.version"); + infoprint "Sys schema Version: " + . select_one("select sys_version from sys.version"); # Top user per connection subheaderprint "Performance schema: Top 5 user per connection"; - my $nbL=1; - for my $lQuery(select_array ('select user, total_connections from sys.user_summary order by total_connections desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery conn(s)"; - $nbL++; + my $nbL = 1; + for my $lQuery ( + select_array( +'select user, total_connections from sys.user_summary order by total_connections desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery conn(s)"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top user per statement subheaderprint "Performance schema: Top 5 user per statement"; - $nbL=1; - for my $lQuery(select_array ('select user, statements from sys.user_summary order by statements desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery stmt(s)"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select user, statements from sys.user_summary order by statements desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery stmt(s)"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top user per statement latency subheaderprint "Performance schema: Top 5 user per statement latency"; - $nbL=1; - for my $lQuery(select_array ('select user, statement_avg_latency from sys.user_summary order by statement_avg_latency desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select user, statement_avg_latency from sys.user_summary order by statement_avg_latency desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top user per lock latency subheaderprint "Performance schema: Top 5 user per lock latency"; - $nbL=1; - for my $lQuery(select_array ('select user, lock_latency from sys.user_summary_by_statement_latency order by lock_latency desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select user, lock_latency from sys.user_summary_by_statement_latency order by lock_latency desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top user per full scans subheaderprint "Performance schema: Top 5 user per nb full scans"; - $nbL=1; - for my $lQuery(select_array ('select user, full_scans from sys.user_summary_by_statement_latency order by full_scans desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select user, full_scans from sys.user_summary_by_statement_latency order by full_scans desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top user per row_sent subheaderprint "Performance schema: Top 5 user per rows sent"; - $nbL=1; - for my $lQuery(select_array ('select user, rows_sent from sys.user_summary_by_statement_latency order by rows_sent desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select user, rows_sent from sys.user_summary_by_statement_latency order by rows_sent desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top user per row modified subheaderprint "Performance schema: Top 5 user per rows modified"; - $nbL=1; - for my $lQuery(select_array ('select user, rows_affected from sys.user_summary_by_statement_latency order by rows_affected desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select user, rows_affected from sys.user_summary_by_statement_latency order by rows_affected desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top user per io subheaderprint "Performance schema: Top 5 user per io"; - $nbL=1; - for my $lQuery(select_array ('select user, file_ios from sys.user_summary order by file_ios desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select user, file_ios from sys.user_summary order by file_ios desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top user per io latency subheaderprint "Performance schema: Top 5 user per io latency"; - $nbL=1; - for my $lQuery(select_array ('select user, file_io_latency from sys.user_summary order by file_io_latency desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select user, file_io_latency from sys.user_summary order by file_io_latency desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top host per connection subheaderprint "Performance schema: Top 5 host per connection"; - $nbL=1; - for my $lQuery(select_array ('select host, total_connections from sys.host_summary order by total_connections desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery conn(s)"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, total_connections from sys.host_summary order by total_connections desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery conn(s)"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top host per statement subheaderprint "Performance schema: Top 5 host per statement"; - $nbL=1; - for my $lQuery(select_array ('select host, statements from sys.host_summary order by statements desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery stmt(s)"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, statements from sys.host_summary order by statements desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery stmt(s)"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top host per statement latency subheaderprint "Performance schema: Top 5 host per statement latency"; - $nbL=1; - for my $lQuery(select_array ('select host, statement_avg_latency from sys.host_summary order by statement_avg_latency desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, statement_avg_latency from sys.host_summary order by statement_avg_latency desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top host per lock latency subheaderprint "Performance schema: Top 5 host per lock latency"; - $nbL=1; - for my $lQuery(select_array ('select host, lock_latency from sys.host_summary_by_statement_latency order by lock_latency desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, lock_latency from sys.host_summary_by_statement_latency order by lock_latency desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top host per full scans subheaderprint "Performance schema: Top 5 host per nb full scans"; - $nbL=1; - for my $lQuery(select_array ('select host, full_scans from sys.host_summary_by_statement_latency order by full_scans desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, full_scans from sys.host_summary_by_statement_latency order by full_scans desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top host per rows sent subheaderprint "Performance schema: Top 5 host per rows sent"; - $nbL=1; - for my $lQuery(select_array ('select host, rows_sent from sys.host_summary_by_statement_latency order by rows_sent desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, rows_sent from sys.host_summary_by_statement_latency order by rows_sent desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top host per rows modified subheaderprint "Performance schema: Top 5 host per rows modified"; - $nbL=1; - for my $lQuery(select_array ('select host, rows_affected from sys.host_summary_by_statement_latency order by rows_affected desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, rows_affected from sys.host_summary_by_statement_latency order by rows_affected desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top host per io subheaderprint "Performance schema: Top 5 host per io"; - $nbL=1; - for my $lQuery(select_array ('select host, file_ios from sys.host_summary order by file_ios desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, file_ios from sys.host_summary order by file_ios desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top 5 host per io latency subheaderprint "Performance schema: Top 5 host per io latency"; - $nbL=1; - for my $lQuery(select_array ('select host, file_io_latency from sys.host_summary order by file_io_latency desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, file_io_latency from sys.host_summary order by file_io_latency desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top IO type order by total io subheaderprint "Performance schema: Top IO type order by total io"; - $nbL=1; - for my $lQuery(select_array ('use sys;select substring(event_name,14), SUM(total)AS total from sys.host_summary_by_file_io_type GROUP BY substring(event_name,14) ORDER BY total DESC;')) { - infoprint " +-- $nbL: $lQuery i/o"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select substring(event_name,14), SUM(total)AS total from sys.host_summary_by_file_io_type GROUP BY substring(event_name,14) ORDER BY total DESC;' + ) + ) + { + infoprint " +-- $nbL: $lQuery i/o"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top IO type order by total latency subheaderprint "Performance schema: Top IO type order by total latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select substring(event_name,14), format_time(ROUND(SUM(total_latency),1)) AS total_latency from sys.host_summary_by_file_io_type GROUP BY substring(event_name,14) ORDER BY total_latency DESC;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select substring(event_name,14), format_time(ROUND(SUM(total_latency),1)) AS total_latency from sys.host_summary_by_file_io_type GROUP BY substring(event_name,14) ORDER BY total_latency DESC;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top IO type order by max latency subheaderprint "Performance schema: Top IO type order by max latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select substring(event_name,14), MAX(max_latency) as max_latency from sys.host_summary_by_file_io_type GROUP BY substring(event_name,14) ORDER BY max_latency DESC;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select substring(event_name,14), MAX(max_latency) as max_latency from sys.host_summary_by_file_io_type GROUP BY substring(event_name,14) ORDER BY max_latency DESC;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top Stages order by total io subheaderprint "Performance schema: Top Stages order by total io"; - $nbL=1; - for my $lQuery(select_array ('use sys;select substring(event_name,7), SUM(total)AS total from sys.host_summary_by_stages GROUP BY substring(event_name,7) ORDER BY total DESC;')) { - infoprint " +-- $nbL: $lQuery i/o"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select substring(event_name,7), SUM(total)AS total from sys.host_summary_by_stages GROUP BY substring(event_name,7) ORDER BY total DESC;' + ) + ) + { + infoprint " +-- $nbL: $lQuery i/o"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top Stages order by total latency subheaderprint "Performance schema: Top Stages order by total latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select substring(event_name,7), format_time(ROUND(SUM(total_latency),1)) AS total_latency from sys.host_summary_by_stages GROUP BY substring(event_name,7) ORDER BY total_latency DESC;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select substring(event_name,7), format_time(ROUND(SUM(total_latency),1)) AS total_latency from sys.host_summary_by_stages GROUP BY substring(event_name,7) ORDER BY total_latency DESC;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top Stages order by avg latency subheaderprint "Performance schema: Top Stages order by avg latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select substring(event_name,7), MAX(avg_latency) as avg_latency from sys.host_summary_by_stages GROUP BY substring(event_name,7) ORDER BY avg_latency DESC;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select substring(event_name,7), MAX(avg_latency) as avg_latency from sys.host_summary_by_stages GROUP BY substring(event_name,7) ORDER BY avg_latency DESC;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top host per table scans subheaderprint "Performance schema: Top 5 host per table scans"; - $nbL=1; - for my $lQuery(select_array ('select host, table_scans from sys.host_summary order by table_scans desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select host, table_scans from sys.host_summary order by table_scans desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # InnoDB Buffer Pool by schema subheaderprint "Performance schema: InnoDB Buffer Pool by schema"; - $nbL=1; - for my $lQuery(select_array ('select object_schema, allocated, data, pages from sys.innodb_buffer_stats_by_schema ORDER BY pages DESC')) { - infoprint " +-- $nbL: $lQuery page(s)"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select object_schema, allocated, data, pages from sys.innodb_buffer_stats_by_schema ORDER BY pages DESC' + ) + ) + { + infoprint " +-- $nbL: $lQuery page(s)"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # InnoDB Buffer Pool by table subheaderprint "Performance schema: InnoDB Buffer Pool by table"; - $nbL=1; - for my $lQuery(select_array ("select CONCAT(object_schema,CONCAT('.', object_name)), allocated,data, pages from sys.innodb_buffer_stats_by_table ORDER BY pages DESC")) { - infoprint " +-- $nbL: $lQuery page(s)"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +"select CONCAT(object_schema,CONCAT('.', object_name)), allocated,data, pages from sys.innodb_buffer_stats_by_table ORDER BY pages DESC" + ) + ) + { + infoprint " +-- $nbL: $lQuery page(s)"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Process per allocated memory subheaderprint "Performance schema: Process per allocated memory"; - $nbL=1; - for my $lQuery(select_array ("select concat(user,concat('/', IFNULL(Command,'NONE'))) AS PROC, current_memory from sys.processlist ORDER BY current_memory DESC;" )) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +"select concat(user,concat('/', IFNULL(Command,'NONE'))) AS PROC, current_memory from sys.processlist ORDER BY current_memory DESC;" + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # InnoDB Lock Waits subheaderprint "Performance schema: InnoDB Lock Waits"; - $nbL=1; - for my $lQuery(select_array ("use sys;select wait_age_secs, locked_table, locked_type, waiting_query from innodb_lock_waits order by wait_age_secs DESC;" )) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +"use sys;select wait_age_secs, locked_table, locked_type, waiting_query from innodb_lock_waits order by wait_age_secs DESC;" + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Threads IO Latency subheaderprint "Performance schema: Thread IO Latency"; - $nbL=1; - for my $lQuery(select_array ("use sys;select user, total_latency, max_latency from io_by_thread_by_latency order by total_latency;" )) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +"use sys;select user, total_latency, max_latency from io_by_thread_by_latency order by total_latency;" + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # High Cost SQL statements subheaderprint "Performance schema: Top 5 Most latency statements"; - $nbL=1; - for my $lQuery(select_array ('select query, avg_latency from sys.statement_analysis order by avg_latency desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select query, avg_latency from sys.statement_analysis order by avg_latency desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top 5% slower queries subheaderprint "Performance schema: Top 5 slower queries"; - $nbL=1; - for my $lQuery(select_array ('select query, exec_count from sys.statements_with_runtimes_in_95th_percentile order by exec_count desc LIMIT 5')) { - infoprint " +-- $nbL: $lQuery s"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select query, exec_count from sys.statements_with_runtimes_in_95th_percentile order by exec_count desc LIMIT 5' + ) + ) + { + infoprint " +-- $nbL: $lQuery s"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top 10 nb statement type subheaderprint "Performance schema: Top 10 nb statement type"; - $nbL=1; - for my $lQuery(select_array ('use sys;select statement, sum(total) as total from host_summary_by_statement_type group by statement order by total desc LIMIT 10;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select statement, sum(total) as total from host_summary_by_statement_type group by statement order by total desc LIMIT 10;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top statement by total latency subheaderprint "Performance schema: Top statement by total latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select statement, sum(total_latency) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select statement, sum(total_latency) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top statement by lock latency subheaderprint "Performance schema: Top statement by lock latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select statement, sum(lock_latency) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select statement, sum(lock_latency) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top statement by full scans subheaderprint "Performance schema: Top statement by full scans"; - $nbL=1; - for my $lQuery(select_array ('use sys;select statement, sum(full_scans) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select statement, sum(full_scans) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top statement by rows sent subheaderprint "Performance schema: Top statement by rows sent"; - $nbL=1; - for my $lQuery(select_array ('use sys;select statement, sum(rows_sent) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select statement, sum(rows_sent) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Top statement by rows modified subheaderprint "Performance schema: Top statement by rows modified"; - $nbL=1; - for my $lQuery(select_array ('use sys;select statement, sum(rows_affected) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select statement, sum(rows_affected) as total from sys.host_summary_by_statement_type group by statement order by total desc LIMIT 10;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Use temporary tables subheaderprint "Performance schema: Some queries using temp table"; - $nbL=1; - for my $lQuery(select_array ('use sys;select query from sys.statements_with_temp_tables LIMIT 20')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( + 'use sys;select query from sys.statements_with_temp_tables LIMIT 20' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Unused Indexes subheaderprint "Performance schema: Unused indexes"; - $nbL=1; - for my $lQuery(select_array ('select * from sys.schema_unused_indexes')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( select_array('select * from sys.schema_unused_indexes') ) { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Full table scans subheaderprint "Performance schema: Tables with full table scans"; - $nbL=1; - for my $lQuery(select_array ('select * from sys.schema_tables_with_full_table_scans order by rows_full_scanned DESC')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select * from sys.schema_tables_with_full_table_scans order by rows_full_scanned DESC' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Latest file IO by latency subheaderprint "Performance schema: Latest FILE IO by latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select thread, file, latency, operation from latest_file_io ORDER BY latency LIMIT 10;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select thread, file, latency, operation from latest_file_io ORDER BY latency LIMIT 10;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # FILE by IO read bytes subheaderprint "Performance schema: FILE by IO read bytes"; - $nbL=1; - for my $lQuery(select_array ("use sys;(select file, total_read from io_global_by_file_by_bytes where total_read like '%MiB' order by total_read DESC) UNION (select file, total_read from io_global_by_file_by_bytes where total_read like '%KiB' order by total_read DESC LIMIT 15);")) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +"use sys;(select file, total_read from io_global_by_file_by_bytes where total_read like '%MiB' order by total_read DESC) UNION (select file, total_read from io_global_by_file_by_bytes where total_read like '%KiB' order by total_read DESC LIMIT 15);" + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # FILE by IO written bytes subheaderprint "Performance schema: FILE by IO written bytes"; - $nbL=1; - for my $lQuery(select_array ("use sys;(select file, total_written from io_global_by_file_by_bytes where total_written like '%MiB' order by total_written DESC) UNION (select file, total_written from io_global_by_file_by_bytes where total_written like '%KiB' order by total_written DESC LIMIT 15);")) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +"use sys;(select file, total_written from io_global_by_file_by_bytes where total_written like '%MiB' order by total_written DESC) UNION (select file, total_written from io_global_by_file_by_bytes where total_written like '%KiB' order by total_written DESC LIMIT 15);" + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # file per IO total latency subheaderprint "Performance schema: file per IO total latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select file, total_latency from io_global_by_file_by_latency ORDER BY total_latency DESC LIMIT 20;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select file, total_latency from io_global_by_file_by_latency ORDER BY total_latency DESC LIMIT 20;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # file per IO read latency subheaderprint "Performance schema: file per IO read latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select file, read_latency from io_global_by_file_by_latency ORDER BY read_latency DESC LIMIT 20;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select file, read_latency from io_global_by_file_by_latency ORDER BY read_latency DESC LIMIT 20;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # file per IO write latency subheaderprint "Performance schema: file per IO write latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select file, write_latency from io_global_by_file_by_latency ORDER BY write_latency DESC LIMIT 20;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select file, write_latency from io_global_by_file_by_latency ORDER BY write_latency DESC LIMIT 20;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Event Wait by read bytes subheaderprint "Performance schema: Event Wait by read bytes"; - $nbL=1; - for my $lQuery(select_array ("use sys;(select event_name, total_read from io_global_by_wait_by_bytes where total_read like '%MiB' order by total_read DESC) UNION (select event_name, total_read from io_global_by_wait_by_bytes where total_read like '%KiB' order by total_read DESC LIMIT 15);")) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +"use sys;(select event_name, total_read from io_global_by_wait_by_bytes where total_read like '%MiB' order by total_read DESC) UNION (select event_name, total_read from io_global_by_wait_by_bytes where total_read like '%KiB' order by total_read DESC LIMIT 15);" + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Event Wait by write bytes subheaderprint "Performance schema: Event Wait written bytes"; - $nbL=1; - for my $lQuery(select_array ("use sys;(select event_name, total_written from io_global_by_wait_by_bytes where total_written like '%MiB' order by total_written DESC) UNION (select event_name, total_written from io_global_by_wait_by_bytes where total_written like '%KiB' order by total_written DESC LIMIT 15);")) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +"use sys;(select event_name, total_written from io_global_by_wait_by_bytes where total_written like '%MiB' order by total_written DESC) UNION (select event_name, total_written from io_global_by_wait_by_bytes where total_written like '%KiB' order by total_written DESC LIMIT 15);" + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # event per wait total latency subheaderprint "Performance schema: event per wait total latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select event_name, total_latency from io_global_by_wait_by_latency ORDER BY total_latency DESC LIMIT 20;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select event_name, total_latency from io_global_by_wait_by_latency ORDER BY total_latency DESC LIMIT 20;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # event per wait read latency subheaderprint "Performance schema: event per wait read latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select event_name, read_latency from io_global_by_wait_by_latency ORDER BY read_latency DESC LIMIT 20;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select event_name, read_latency from io_global_by_wait_by_latency ORDER BY read_latency DESC LIMIT 20;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # event per wait write latency subheaderprint "Performance schema: event per wait write latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select event_name, write_latency from io_global_by_wait_by_latency ORDER BY write_latency DESC LIMIT 20;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select event_name, write_latency from io_global_by_wait_by_latency ORDER BY write_latency DESC LIMIT 20;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); #schema_index_statistics # TOP 15 most read index subheaderprint "Performance schema: TOP 15 most read indexes"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name,index_name, rows_selected from schema_index_statistics ORDER BY ROWs_selected DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name,index_name, rows_selected from schema_index_statistics ORDER BY ROWs_selected DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 most used index subheaderprint "Performance schema: TOP 15 most modified indexes"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name,index_name, rows_inserted+rows_updated+rows_deleted AS changes from schema_index_statistics ORDER BY rows_inserted+rows_updated+rows_deleted DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name,index_name, rows_inserted+rows_updated+rows_deleted AS changes from schema_index_statistics ORDER BY rows_inserted+rows_updated+rows_deleted DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 high read latency index subheaderprint "Performance schema: TOP 15 high read latency index"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name,index_name, select_latency from schema_index_statistics ORDER BY select_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name,index_name, select_latency from schema_index_statistics ORDER BY select_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 high insert latency index subheaderprint "Performance schema: TOP 15 most modified indexes"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name,index_name, insert_latency from schema_index_statistics ORDER BY insert_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name,index_name, insert_latency from schema_index_statistics ORDER BY insert_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 high update latency index subheaderprint "Performance schema: TOP 15 high update latency index"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name,index_name, update_latency from schema_index_statistics ORDER BY update_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name,index_name, update_latency from schema_index_statistics ORDER BY update_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 high delete latency index subheaderprint "Performance schema: TOP 15 high delete latency index"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name,index_name, delete_latency from schema_index_statistics ORDER BY delete_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name,index_name, delete_latency from schema_index_statistics ORDER BY delete_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 most read tables subheaderprint "Performance schema: TOP 15 most read tables"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name, rows_fetched from schema_table_statistics ORDER BY ROWs_fetched DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name, rows_fetched from schema_table_statistics ORDER BY ROWs_fetched DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 most used tables subheaderprint "Performance schema: TOP 15 most modified tables"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name, rows_inserted+rows_updated+rows_deleted AS changes from schema_table_statistics ORDER BY rows_inserted+rows_updated+rows_deleted DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name, rows_inserted+rows_updated+rows_deleted AS changes from schema_table_statistics ORDER BY rows_inserted+rows_updated+rows_deleted DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 high read latency tables subheaderprint "Performance schema: TOP 15 high read latency tables"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name, fetch_latency from schema_table_statistics ORDER BY fetch_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name, fetch_latency from schema_table_statistics ORDER BY fetch_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 high insert latency tables subheaderprint "Performance schema: TOP 15 high insert latency tables"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name, insert_latency from schema_table_statistics ORDER BY insert_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name, insert_latency from schema_table_statistics ORDER BY insert_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 high update latency tables subheaderprint "Performance schema: TOP 15 high update latency tables"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name, update_latency from schema_table_statistics ORDER BY update_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name, update_latency from schema_table_statistics ORDER BY update_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # TOP 15 high delete latency tables subheaderprint "Performance schema: TOP 15 high delete latency tables"; - $nbL=1; - for my $lQuery(select_array ('use sys;select table_schema, table_name, delete_latency from schema_table_statistics ORDER BY delete_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select table_schema, table_name, delete_latency from schema_table_statistics ORDER BY delete_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); # Redundant indexes subheaderprint "Performance schema: Redundant indexes"; - $nbL=1; - for my $lQuery(select_array ('use sys;select * from schema_redundant_indexes;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array('use sys;select * from schema_redundant_indexes;') ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: Tables not using InnoDB buffer"; - $nbL=1; - for my $lQuery(select_array (' Select table_schema, table_name from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +' Select table_schema, table_name from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: Table not using InnoDB buffer"; - $nbL=1; - for my $lQuery(select_array (' Select table_schema, table_name from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +' Select table_schema, table_name from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - subheaderprint "Performance schema: Table not using InnoDB buffer"; - $nbL=1; - for my $lQuery(select_array (' Select table_schema, table_name from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); + subheaderprint "Performance schema: Table not using InnoDB buffer"; + $nbL = 1; + for my $lQuery ( + select_array( +' Select table_schema, table_name from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: Top 15 Tables using InnoDB buffer"; - $nbL=1; - for my $lQuery(select_array ('select table_schema,table_name,innodb_buffer_allocated from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NOT NULL ORDER BY innodb_buffer_allocated DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select table_schema,table_name,innodb_buffer_allocated from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NOT NULL ORDER BY innodb_buffer_allocated DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: Top 15 Tables with InnoDB buffer free"; - $nbL=1; - for my $lQuery(select_array ('select table_schema,table_name,innodb_buffer_free from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NOT NULL ORDER BY innodb_buffer_free DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'select table_schema,table_name,innodb_buffer_free from sys.schema_table_statistics_with_buffer where innodb_buffer_allocated IS NOT NULL ORDER BY innodb_buffer_free DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: Top 15 Most executed queries"; - $nbL=1; - for my $lQuery(select_array ('select db, query, exec_count from sys.statement_analysis order by exec_count DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: Top 15 Most executed queries"; + $nbL = 1; + for my $lQuery ( + select_array( +'select db, query, exec_count from sys.statement_analysis order by exec_count DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: Latest SQL queries in errors or warnings"; - $nbL=1; - for my $lQuery(select_array ('select query, last_seen from sys.statements_with_errors_or_warnings ORDER BY last_seen LIMIT 100;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint + "Performance schema: Latest SQL queries in errors or warnings"; + $nbL = 1; + for my $lQuery ( + select_array( +'select query, last_seen from sys.statements_with_errors_or_warnings ORDER BY last_seen LIMIT 100;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: Top 20 queries with full table scans"; - $nbL=1; - for my $lQuery(select_array ('select db, query, exec_count from sys.statements_with_full_table_scans order BY exec_count DESC LIMIT 20;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: Top 20 queries with full table scans"; + $nbL = 1; + for my $lQuery ( + select_array( +'select db, query, exec_count from sys.statements_with_full_table_scans order BY exec_count DESC LIMIT 20;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: Last 50 queries with full table scans"; - $nbL=1; - for my $lQuery(select_array ('select db, query, last_seen from sys.statements_with_full_table_scans order BY last_seen DESC LIMIT 50;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: Last 50 queries with full table scans"; + $nbL = 1; + for my $lQuery ( + select_array( +'select db, query, last_seen from sys.statements_with_full_table_scans order BY last_seen DESC LIMIT 50;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: TOP 15 reader queries (95% percentile)"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query , rows_sent from statements_with_runtimes_in_95th_percentile ORDER BY ROWs_sent DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: TOP 15 reader queries (95% percentile)"; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query , rows_sent from statements_with_runtimes_in_95th_percentile ORDER BY ROWs_sent DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: TOP 15 most row look queries (95% percentile)"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, rows_examined AS search from statements_with_runtimes_in_95th_percentile ORDER BY rows_examined DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint + "Performance schema: TOP 15 most row look queries (95% percentile)"; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, rows_examined AS search from statements_with_runtimes_in_95th_percentile ORDER BY rows_examined DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: TOP 15 total latency queries (95% percentile)"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, total_latency AS search from statements_with_runtimes_in_95th_percentile ORDER BY total_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint + "Performance schema: TOP 15 total latency queries (95% percentile)"; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, total_latency AS search from statements_with_runtimes_in_95th_percentile ORDER BY total_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: TOP 15 max latency queries (95% percentile)"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, max_latency AS search from statements_with_runtimes_in_95th_percentile ORDER BY max_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint + "Performance schema: TOP 15 max latency queries (95% percentile)"; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, max_latency AS search from statements_with_runtimes_in_95th_percentile ORDER BY max_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: TOP 15 average latency queries (95% percentile)"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, avg_latency AS search from statements_with_runtimes_in_95th_percentile ORDER BY avg_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint + "Performance schema: TOP 15 average latency queries (95% percentile)"; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, avg_latency AS search from statements_with_runtimes_in_95th_percentile ORDER BY avg_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - - subheaderprint "Performance schema: Top 20 queries with sort"; - $nbL=1; - for my $lQuery(select_array ('select db, query, exec_count from sys.statements_with_sorting order BY exec_count DESC LIMIT 20;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: Top 20 queries with sort"; + $nbL = 1; + for my $lQuery ( + select_array( +'select db, query, exec_count from sys.statements_with_sorting order BY exec_count DESC LIMIT 20;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: Last 50 queries with sort"; - $nbL=1; - for my $lQuery(select_array ('select db, query, last_seen from sys.statements_with_sorting order BY last_seen DESC LIMIT 50;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: Last 50 queries with sort"; + $nbL = 1; + for my $lQuery ( + select_array( +'select db, query, last_seen from sys.statements_with_sorting order BY last_seen DESC LIMIT 50;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: TOP 15 row sorting queries with sort"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query , rows_sorted from statements_with_sorting ORDER BY ROWs_sorted DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: TOP 15 row sorting queries with sort"; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query , rows_sorted from statements_with_sorting ORDER BY ROWs_sorted DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: TOP 15 total latency queries with sort"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, total_latency AS search from statements_with_sorting ORDER BY total_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, total_latency AS search from statements_with_sorting ORDER BY total_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: TOP 15 merge queries with sort"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, sort_merge_passes AS search from statements_with_sorting ORDER BY sort_merge_passes DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, sort_merge_passes AS search from statements_with_sorting ORDER BY sort_merge_passes DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: TOP 15 average sort merges queries with sort"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, avg_sort_merges AS search from statements_with_sorting ORDER BY avg_sort_merges DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint + "Performance schema: TOP 15 average sort merges queries with sort"; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, avg_sort_merges AS search from statements_with_sorting ORDER BY avg_sort_merges DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: TOP 15 scans queries with sort"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, sorts_using_scans AS search from statements_with_sorting ORDER BY sorts_using_scans DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, sorts_using_scans AS search from statements_with_sorting ORDER BY sorts_using_scans DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: TOP 15 range queries with sort"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, sort_using_range AS search from statements_with_sorting ORDER BY sort_using_range DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, sort_using_range AS search from statements_with_sorting ORDER BY sort_using_range DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); - - + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); ################################################################################## -#statements_with_temp_tables + #statements_with_temp_tables #mysql> desc statements_with_temp_tables; #+--------------------------+---------------------+------+-----+---------------------+-------+ @@ -3956,40 +4485,65 @@ sub mysqsl_pfs { #+--------------------------+---------------------+------+-----+---------------------+-------+ #11 rows in set (0,01 sec)# # - subheaderprint "Performance schema: Top 20 queries with temp table"; - $nbL=1; - for my $lQuery(select_array ('select db, query, exec_count from sys.statements_with_temp_tables order BY exec_count DESC LIMIT 20;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: Top 20 queries with temp table"; + $nbL = 1; + for my $lQuery ( + select_array( +'select db, query, exec_count from sys.statements_with_temp_tables order BY exec_count DESC LIMIT 20;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: Last 50 queries with temp table"; - $nbL=1; - for my $lQuery(select_array ('select db, query, last_seen from sys.statements_with_temp_tables order BY last_seen DESC LIMIT 50;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: Last 50 queries with temp table"; + $nbL = 1; + for my $lQuery ( + select_array( +'select db, query, last_seen from sys.statements_with_temp_tables order BY last_seen DESC LIMIT 50;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: TOP 15 total latency queries with temp table"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, total_latency AS search from statements_with_temp_tables ORDER BY total_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint + "Performance schema: TOP 15 total latency queries with temp table"; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, total_latency AS search from statements_with_temp_tables ORDER BY total_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: TOP 15 queries with temp table to disk"; - $nbL=1; - for my $lQuery(select_array ('use sys;select db, query, disk_tmp_tables from statements_with_sorting ORDER BY disk_tmp_tables DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select db, query, disk_tmp_tables from statements_with_sorting ORDER BY disk_tmp_tables DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); ################################################################################## -#wait_classes_global_by_latency + #wait_classes_global_by_latency #ysql> select * from wait_classes_global_by_latency; #-----------------+-------+---------------+-------------+-------------+-------------+ @@ -4002,52 +4556,88 @@ sub mysqsl_pfs { # rows in set (0,00 sec) subheaderprint "Performance schema: TOP 15 class events by number"; - $nbL=1; - for my $lQuery(select_array ('use sys;select event_class, total from wait_classes_global_by_latency ORDER BY total DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select event_class, total from wait_classes_global_by_latency ORDER BY total DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: TOP 30 events by number"; - $nbL=1; - for my $lQuery(select_array ('use sys;select events, total from waits_global_by_latency ORDER BY total DESC LIMIT 30;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select events, total from waits_global_by_latency ORDER BY total DESC LIMIT 30;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: TOP 15 class events by total latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select event_class, total_latency from wait_classes_global_by_latency ORDER BY total_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select event_class, total_latency from wait_classes_global_by_latency ORDER BY total_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: TOP 30 events by total latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select events, total_latency from waits_global_by_latency ORDER BY total_latency DESC LIMIT 30;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select events, total_latency from waits_global_by_latency ORDER BY total_latency DESC LIMIT 30;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); - subheaderprint "Performance schema: TOP 15 class events by max latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select event_class, max_latency from wait_classes_global_by_latency ORDER BY max_latency DESC LIMIT 15;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + subheaderprint "Performance schema: TOP 15 class events by max latency"; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select event_class, max_latency from wait_classes_global_by_latency ORDER BY max_latency DESC LIMIT 15;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); subheaderprint "Performance schema: TOP 30 events by max latency"; - $nbL=1; - for my $lQuery(select_array ('use sys;select events, max_latency from waits_global_by_latency ORDER BY max_latency DESC LIMIT 30;')) { - infoprint " +-- $nbL: $lQuery"; - $nbL++; + $nbL = 1; + for my $lQuery ( + select_array( +'use sys;select events, max_latency from waits_global_by_latency ORDER BY max_latency DESC LIMIT 30;' + ) + ) + { + infoprint " +-- $nbL: $lQuery"; + $nbL++; } - infoprint "No information found or indicators desactivated." if ($nbL == 1); + infoprint "No information found or indicators desactivated." + if ( $nbL == 1 ); } @@ -4151,6 +4741,7 @@ sub mariadb_xtradb { # All is to done here } + # Recommendations for RocksDB sub mariadb_rockdb { subheaderprint "RocksDB Metrics"; @@ -4166,6 +4757,7 @@ sub mariadb_rockdb { # All is to done here } + # Recommendations for Spider sub mariadb_spider { subheaderprint "Spider Metrics"; @@ -4181,6 +4773,7 @@ sub mariadb_spider { # All is to done here } + # Recommendations for Connect sub mariadb_connect { subheaderprint "Connect Metrics"; @@ -4511,11 +5104,13 @@ sub mysql_innodb { } if ( defined $myvar{'innodb_log_file_size'} ) { infoprint " +-- InnoDB Log File Size: " - . hr_bytes( $myvar{'innodb_log_file_size'} ) . "(".$mycalc{'innodb_log_size_pct'}." % of buffer pool)"; + . hr_bytes( $myvar{'innodb_log_file_size'} ) . "(" + . $mycalc{'innodb_log_size_pct'} + . " % of buffer pool)"; } if ( defined $myvar{'innodb_log_buffer_size'} ) { infoprint " +-- InnoDB Log Buffer: " - . hr_bytes( $myvar{'innodb_log_buffer_size'} ) ; + . hr_bytes( $myvar{'innodb_log_buffer_size'} ); } if ( defined $mystat{'Innodb_buffer_pool_pages_free'} ) { infoprint " +-- InnoDB Log Buffer Free: " @@ -4528,16 +5123,16 @@ sub mysql_innodb { } if ( defined $myvar{'innodb_thread_concurrency'} ) { infoprint "InnoDB Thread Cucurrency: " - . $myvar{'innodb_thread_concurrency'} ; + . $myvar{'innodb_thread_concurrency'}; } + # InnoDB Buffer Pull Size if ( $myvar{'innodb_file_per_table'} eq "ON" ) { goodprint "InnoDB File per table is activated"; } else { badprint "InnoDB File per table is not activated"; - push( @adjvars, - "innodb_file_per_table=ON" ); + push( @adjvars, "innodb_file_per_table=ON" ); } # InnoDB Buffer Pull Size @@ -4555,19 +5150,26 @@ sub mysql_innodb { . hr_bytes_rnd( $enginestats{'InnoDB'} ) . ") if possible." ); } - if ($mycalc{'innodb_log_size_pct'} < 20 or $mycalc{'innodb_log_size_pct'} > 30) { - badprint "Ratio InnoDB log file size / InnoDB Buffer pool size (". - $mycalc{'innodb_log_size_pct'}. - " %): " . hr_bytes( $myvar{'innodb_log_file_size'} ) . "/" - . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) . " should be equal 25%"; - push( @adjvars, - "innodb_log_file_size should be equals to 1/4 of buffer pool size (=" - . hr_bytes_rnd( $myvar{'innodb_buffer_pool_size'}/4 ) . ") if possible." ); - } else { - goodprint "InnoDB log file size / InnoDB Buffer pool size: " + if ( $mycalc{'innodb_log_size_pct'} < 20 + or $mycalc{'innodb_log_size_pct'} > 30 ) + { + badprint "Ratio InnoDB log file size / InnoDB Buffer pool size (" + . $mycalc{'innodb_log_size_pct'} . " %): " . hr_bytes( $myvar{'innodb_log_file_size'} ) . "/" - . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) . " should be equal 25%"; + . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) + . " should be equal 25%"; + push( @adjvars, +"innodb_log_file_size should be equals to 1/4 of buffer pool size (=" + . hr_bytes_rnd( $myvar{'innodb_buffer_pool_size'} / 4 ) + . ") if possible." ); } + else { + goodprint "InnoDB log file size / InnoDB Buffer pool size: " + . hr_bytes( $myvar{'innodb_log_file_size'} ) . "/" + . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) + . " should be equal 25%"; + } + # InnoDB Buffer Pull Instances (MySQL 5.6.6+) if ( defined( $myvar{'innodb_buffer_pool_instances'} ) ) { @@ -4652,7 +5254,6 @@ sub mysql_innodb { } } - # InnoDB Read efficency if ( defined $mycalc{'pct_read_efficiency'} && $mycalc{'pct_read_efficiency'} < 90 ) @@ -4783,7 +5384,7 @@ sub mysql_databases { foreach (@dblist) { chomp($_); - if ( $_ eq "information_schema" + if ( $_ eq "information_schema" or $_ eq "performance_schema" or $_ eq "mysql" or $_ eq "" ) @@ -5182,7 +5783,7 @@ mariadb_tokudb; # Print MariaDB Tokudb stats mariadb_xtradb; # Print MariaDB XtraDB stats mariadb_rockdb; # Print MariaDB RockDB stats mariadb_spider; # Print MariaDB Spider stats -mariadb_connect; # Print MariaDB Connect stats +mariadb_connect; # Print MariaDB Connect stats mariadb_galera; # Print MariaDB Galera Cluster stats get_replication_status; # Print replication info make_recommendations; # Make recommendations based on stats