Change storage engine of log tables
mysql.slow_log and mysql.general_log are CSV engine.
CSV engine is hard to make secondary indexes.
So change storage engine of log tables and make secondary indexes.
Sample : mysql.slow_log
SET GLOBAL slow_query_log = OFF; ALTER TABLE mysql.slow_log ENGINE = MyISAM; ALTER TABLE mysql.slow_log ADD INDEX idx_start_time (start_time); SET GLOBAL slow_query_log = ON;