SELECT concat('kill ',id,';') FROM information_schema.PROCESSLIST where id notin (select trx_mysql_thread_id from information_schema.innodb_trx) and Command='Sleep';
官方文档: Adding Rewrite Rules Toadd rules for the Rewriter plugin, addrowsto the rewrite_rules table, then invoke the flush_rewrite_rules() stored procedureto load the rules from the tableinto the plugin. The following example creates a simple rule tomatch statements that select a single literal value:
INSERTINTO query_rewrite.rewrite_rules (pattern, replacement) VALUES('SELECT ?', 'SELECT ? + 1'); The resulting table contents look like this:
mysql>SELECT*FROM query_rewrite.rewrite_rules\G ***************************1.row*************************** id: 1 pattern: SELECT ? pattern_database: NULL replacement: SELECT ? +1 enabled: YES message: NULL pattern_digest: NULL normalized_pattern: NULL The rule specifies a pattern template indicating which SELECT statements tomatch, and a replacement template indicating how to rewrite matching statements. However, adding the rule to the rewrite_rules tableisnot sufficient to cause the Rewriter plugin to use the rule. You must invoke flush_rewrite_rules() to load the table contents into the plugin in-memory cache:
"root@localhost:mysql.sock [aa]>insert into query_rewrite.rewrite_rules(pattern, replacement, pattern_database) values ("select*from emp where empno+1=7789","select*from emp where empno=7788", "test");