1.查询不是sleep或者有状态的sql

select * from `information_schema`.processlist where command !='Sleep' or state !='';

2.查询运行中的事务
select trx_state, trx_started, trx_mysql_thread_id, trx_query from information_schema.innodb_trx;

3.查看死锁

SELECT b.trx_state, e.state, e.time, d.state AS block_state, d.time AS block_time
, a.requesting_trx_id, a.requested_lock_id, b.trx_query, b.trx_mysql_thread_id, a.blocking_trx_id
, a.blocking_lock_id, c.trx_query AS block_trx_query, c.trx_mysql_thread_id AS block_trx_mysql_tread_id
FROM information_schema.INNODB_LOCK_WAITS a
LEFT JOIN information_schema.INNODB_TRX b ON a.requesting_trx_id = b.trx_id
LEFT JOIN information_schema.INNODB_TRX c ON a.blocking_trx_id = c.trx_id
LEFT JOIN information_schema.PROCESSLIST d ON c.trx_mysql_thread_id = d.id
LEFT JOIN information_schema.PROCESSLIST e ON b.trx_mysql_thread_id = e.id
ORDER BY a.requesting_trx_id;

相关文章:

  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-10-15
猜你喜欢
  • 2021-10-07
  • 2021-11-28
  • 2021-10-15
  • 2021-07-09
  • 2021-07-24
  • 2022-12-23
  • 2021-11-16
相关资源
相似解决方案