728x90
반응형
[MySQL] Table lock 조회 쿼리
SHOW OPEN TABLES WHERE In_use > 0;
# MySQL 8.0
SELECT
r.trx_id waiting_trx_id,
r.trx_mysql_thread_id waiting_thread,
r.trx_query waiting_query,
b.trx_id blocking_trx_id,
b.trx_mysql_thread_id blocking_thread,
b.trx_query blocking_query
FROM performance_schema.data_lock_waits w
INNER JOIN information_schema.innodb_trx b
ON b.trx_id = w.blocking_engine_transaction_id
INNER JOIN information_schema.innodb_trx r
ON r.trx_id = w.requesting_engine_transaction_id;
# MySQL 5.7
SELECT
r.trx_id waiting_trx_id,
r.trx_mysql_thread_id waiting_thread,
r.trx_query waiting_query,
b.trx_id blocking_trx_id,
b.trx_mysql_thread_id blocking_thread,
b.trx_query blocking_query
FROM information_schema.innodb_lock_waits w
INNER JOIN information_schema.innodb_trx b
ON b.trx_id = w.blocking_trx_id
INNER JOIN information_schema.innodb_trx r
ON r.trx_id = w.requesting_trx_id;
Ref
https://dev.mysql.com/doc/refman/8.0/en/show-open-tables.html
https://dev.mysql.com/doc/refman/8.0/en/innodb-information-schema-examples.html
728x90
반응형
'Database > MySQL' 카테고리의 다른 글
[MySQL] GROUP BY Optimization (0) | 2023.12.24 |
---|---|
[MySQL] ORDER BY Optimization (1) | 2023.12.06 |
[MySQL] Show Index (0) | 2023.08.24 |
[MySQL] binlog to SQL(텍스트) 변환 (0) | 2022.05.09 |
MariaDB sharding using docker (0) | 2020.07.14 |