查看锁情况(MySQL 8.0)
SELECT * FROM performance_schema.events_statements_history
WHERE thread_id IN (
SELECT b.`THREAD_ID`
FROM sys.`innodb_lock_waits` a
INNER JOIN performance_schema.threads b ON a.`blocking_pid` = b.`PROCESSLIST_ID`
)
ORDER BY timer_start ASC;
本文提供了一种查询MySQL中锁等待情况的方法。通过特定SQL语句,可以从performance_schema中获取到发生锁等待的线程信息,进而定位数据库性能瓶颈。
2852

被折叠的 条评论
为什么被折叠?



