mysql中查看sql語句的加鎖信息


打開開關innodb_lock_monitor用來查看一條語句執行的時候,使用命令show engine innodb status對系統中的lock信息。

開啟
mysql> use marketing
Database changed
mysql>

mysql> create table innodb_lock_monitor(x int) engine=innodb;
Query OK, 0 rows affected (0.08 sec)

mysql> exit
Bye
關閉
mysql> use marketing
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> drop table innodb_lock_monitor;
Query OK, 0 rows affected (0.02 sec)

然后使用show engine innodb status進行顯示,關於lock的部分是

---TRANSACTION 31C, ACTIVE 42 sec
2 lock struct(s), heap size 320, 6 row lock(s)
MySQL thread id 2, OS thread handle 0x1220, query id 128 localhost 127.0.0.1 root
Trx read view will not see trx with id >= 31D, sees < 31D
TABLE LOCK table `test`.`ta` trx id 31C lock mode IX   (-------------對表加了IX意向鎖)
RECORD LOCKS space id 0 page no 312 n bits 72 index `GEN_CLUST_INDEX` of table `test`.`ta` trx id 31C lock_mode X(對以下的行加了X鎖)
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
 0: len 8; hex 73757072656d756d; asc supremum;;

Record lock, heap no 2 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
 0: len 6; hex 000000000203; asc       ;;
 1: len 6; hex 00000000030a; asc       ;;
 2: len 7; hex 8b000001390110; asc     9  ;;
 3: len 4; hex 80000003; asc     ;;
 4: SQL NULL;

Record lock, heap no 3 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
 0: len 6; hex 000000000204; asc       ;;
 1: len 6; hex 00000000030a; asc       ;;
 2: len 7; hex 8b00000139011e; asc     9  ;;
 3: len 4; hex 80000004; asc     ;;
 4: SQL NULL;

Record lock, heap no 4 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
 0: len 6; hex 000000000205; asc       ;;
 1: len 6; hex 00000000030a; asc       ;;
 2: len 7; hex 8b00000139012c; asc     9 ,;;
 3: len 4; hex 80000005; asc     ;;
 4: SQL NULL;

Record lock, heap no 5 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
 0: len 6; hex 000000000206; asc       ;;
 1: len 6; hex 000000000312; asc       ;;
 2: len 7; hex 900000013f0110; asc     ?  ;;
 3: len 4; hex 8000000b; asc     ;;
 4: len 4; hex 8000000c; asc     ;;

Record lock, heap no 6 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
 0: len 6; hex 00000000020c; asc       ;;
 1: len 6; hex 000000000316; asc       ;;
 2: len 7; hex 94000001420110; asc     B  ;;
 3: len 4; hex 8000000c; asc     ;;
 4: len 4; hex 8000000d; asc     ;;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM