2019-08-03 InnoDB常用命令

mysql> SHOW ENGINE INNODB STATUS\G

https://dev.mysql.com/doc/refman/5.7/en/innodb-standard-monitor.html

------------
TRANSACTIONS
------------
Trx id counter 152476
Purge done for trx's n:o < 152472 undo n:o < 0 state: running but idle
History list length 2
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 281479467061704, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 281479467058992, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 152475, ACTIVE 9 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 1136, 1 row lock(s)
MySQL thread id 23, OS thread handle 123145357332480, query id 3012 localhost root Sending data
select * from a where c=7 for update
------- TRX HAS BEEN WAITING 9 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 12130 page no 5 n bits 72 index idx_c of table `pinyougoudb`.`a` trx id 152475 lock_mode X waiting
Record lock, heap no 3 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
 0: len 4; hex 80000007; asc     ;;
 1: len 4; hex 80000003; asc     ;;

------------------
---TRANSACTION 152474, ACTIVE 489 sec
4 lock struct(s), heap size 1136, 3 row lock(s)
MySQL thread id 24, OS thread handle 123145358168064, query id 3013 localhost root starting
SHOW ENGINE INNODB STATUS

mysql> show processlist;

执行计划

https://segmentfault.com/a/1190000008131735

https://dev.mysql.com/doc/refman/5.7/en/explain-output.html

mysql> explain select * from t1 where id between 10 and 20 for update\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: t1
   partitions: NULL
         type: ALL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 12
     filtered: 11.11
        Extra: Using where
1 row in set, 1 warning (0.00 sec)

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容