From 6300c3a2c7d007239ad45f69226579983001ecc6 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Aug 2016 11:44:22 +0200 Subject: [PATCH] Adjust request for table without primary key #229 --- mysqltuner.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 7e9823e..f10a0a7 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -3242,8 +3242,14 @@ sub mariadb_galera { infoprint "GCache is using " . hr_bytes_rnd( get_wsrep_option('gcache.mem_size') ); my @primaryKeysNbTables = select_array( -"select CONCAT(table_schema,CONCAT('.', table_name)) from information_schema.columns where table_schema not in ('mysql', 'information_schema', 'performance_schema') group by table_schema,table_name having sum(if(column_key in ('PRI','UNI'), 1,0)) = 0" - ); +"Select CONCAT(c.table_schema,CONCAT('.', c.table_name)) +from information_schema.columns c +join information_schema.tables t using (TABLE_SCHEMA, TABLE_NAME) +where c.table_schema not in ('mysql', 'information_schema', 'performance_schema') + and t.table_type != 'VIEW' +group by c.table_schema,c.table_name +having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0" +); if ( scalar(@primaryKeysNbTables) > 0 ) { badprint "Following table(s) don't have primary key:";