From e03ba821878e830b856967fe59d6498b234ff018 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 8 Feb 2024 23:56:35 +0100 Subject: [PATCH] Check against performance_schema.global_variables fails (Table not found) #759 --- mysqltuner.pl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index efcfc96ac..702e19f6e 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -3221,11 +3221,11 @@ sub calculations { $mystat{'Innodb_buffer_pool_pages_total'} ) if defined $mystat{'Innodb_buffer_pool_pages_total'}; - $mycalc{'innodb_buffer_alloc_pct'} = select_one( - "select round( 100* sum(allocated)/( select VARIABLE_VALUE " - . "FROM performance_schema.global_variables " - . "WHERE VARIABLE_NAME='innodb_buffer_pool_size' ) ,2)" - . 'FROM sys.x\$innodb_buffer_stats_by_table;' ) + my $lreq= "select ROUND( 100* sum(allocated)/ ". + $myvar{'innodb_buffer_pool_size'} . + ',1) FROM sys.x\$innodb_buffer_stats_by_table;'; + debugprint("lreq: $lreq"); + $mycalc{'innodb_buffer_alloc_pct'} = select_one( $lreq ) if ($opt{experimental}); # Binlog Cache if ( $myvar{'log_bin'} ne 'OFF' ) { @@ -6379,7 +6379,9 @@ sub mysql_innodb { #from sys.x$innodb_buffer_stats_by_table; if ( $opt{experimental} ) { - if (defined $mycalc{innodb_buffer_alloc_pct}) { + debugprint ('innodb_buffer_alloc_pct: "'.$mycalc{innodb_buffer_alloc_pct}.'"'); + if (defined $mycalc{innodb_buffer_alloc_pct} and + $mycalc{innodb_buffer_alloc_pct} ne '' ) { if ( $mycalc{innodb_buffer_alloc_pct} < 80 ) { badprint "Ratio Buffer Pool allocated / Buffer Pool Size: " . $mycalc{'innodb_buffer_alloc_pct'} . '%';