SELECT
CONCAT( 'kill ', trx_mysql_thread_id, ';' ) AS id,
concat( t.PROCESSLIST_USER, '@', t.PROCESSLIST_HOST, ':', t.PROCESSLIST_DB ) AS CONNECTION,
trx_state,
trx_started,
concat( timestampdiff( SECOND, trx_started, CURRENT_TIMESTAMP () ), 's' ) AS duration,
group_concat( h.sql_text ORDER BY h.TIMER_START DESC SEPARATOR ';
' ) AS thd_last_query,
trx_query,
t.processlist_state AS state,
sum( h.rows_examined ) AS trx_rows_examined,
trx_rows_locked,
trx_rows_modified,
trx_isolation_level,
t.thread_id
FROM
information_schema.INNODB_TRX b
LEFT JOIN PERFORMANCE_SCHEMA.threads t ON t.processlist_id = b.trx_mysql_thread_id
LEFT JOIN PERFORMANCE_SCHEMA.events_statements_history h USING ( thread_id )
WHERE
( trx_operation_state != 'sleeping before entering InnoDB' OR trx_operation_state IS NULL )
GROUP BY
thread_id
ORDER BY
trx_started;
Mysql查询正在执行的Sql进程
于 2024-09-11 17:45:50 首次发布