From 821de219dbe48d81094fe075d0b226a227cc9e90 Mon Sep 17 00:00:00 2001 From: Askar Timirgazin Date: Tue, 23 May 2017 17:26:20 +0300 Subject: [PATCH] Fix for messages about defragmented tables Schema name must be divided from table name, now both of them joined, so you can't copy-paste recomendations to mysql console. Was: OPTIMIZE TABLE `test_db.test_table`; -- can free xx MB Must: OPTIMIZE TABLE `test_db`.`test_table`; -- can free xx MB --- mysqltuner.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 15cf06c..75b6326 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -2173,12 +2173,13 @@ sub check_storage_engines { "Run OPTIMIZE TABLE to defragment tables for better performance" ); my $total_free = 0; foreach my $table_line ( @{ $result{'Tables'}{'Fragmented tables'} } ) { - my ( $table_name, $data_free ) = split( /\s+/, $table_line ); + my ( $full_table_name, $data_free ) = split( /\s+/, $table_line ); $data_free = 0 if ( !defined($data_free) or $data_free eq '' ); $data_free = $data_free / 1024 / 1024; $total_free += $data_free; + my ( $table_schema, $table_name ) = split( /\./, $full_table_name ); push( @generalrec, - " OPTIMIZE TABLE `$table_name`; -- can free $data_free MB" ); + " OPTIMIZE TABLE `$table_schema`.`$table_name`; -- can free $data_free MB" ); } push( @generalrec, "Total freed space after theses OPTIMIZE TABLE : $total_free Mb" );