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     ;;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值