• mysql 有索引没走索引 更新锁全表


    Session 1:
    mysql>  select connection_id();
    +-----------------+
    | connection_id() |
    +-----------------+
    |               2 |
    +-----------------+
    1 row in set (0.00 sec)
    
    mysql> start transaction;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select * from t200 where phoneNo between 30 and 40 for update;
    +----+---------+-------------+--------+
    | sn | phoneNo | channelType | status |
    +----+---------+-------------+--------+
    | 30 | 30      |           2 |      1 |
    | 34 | 34      |           3 |      2 |
    | 39 | 39      |           3 |      2 |
    +----+---------+-------------+--------+
    3 rows in set (0.00 sec)
    
    mysql>  select @@tx_isolation; 
    +-----------------+
    | @@tx_isolation  |
    +-----------------+
    | REPEATABLE-READ |
    +-----------------+
    1 row in set (0.00 sec)
    
    mysql> explain  select * from t200 where phoneNo between 30 and 40 for update;
    +----+-------------+-------+------+---------------+------+---------+------+------+-------------+
    | id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra       |
    +----+-------------+-------+------+---------------+------+---------+------+------+-------------+
    |  1 | SIMPLE      | t200  | ALL  | t200_idx1     | NULL | NULL    | NULL |   34 | Using where |
    +----+-------------+-------+------+---------------+------+---------+------+------+-------------+
    
    
    
    Session 2:
    
    mysql>  insert into t200 values(29,29,4,1);
    ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
    mysql>  insert into t200 values(100,100,4,1);
    ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
    mysql>  insert into t200 values(1000,1000,4,1);
    ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
    mysql>  insert into t200 values(1000,1000,4,1);
    

  • 相关阅读:
    批量替换文本的工具
    wcf异常显示错误到客户端
    文件以二进制存入数据库和从数据库读取二进制文件
    关于关系数据库的范式
    对于挑战书上的很久之前都看不懂的DP看懂的突破
    操作系统概念
    关于P,V操作理解的突破,关于并发设计与并行
    关于快速沃尔什变换
    我觉得我应该养成经常翻收藏夹的习惯
    目前我的思考模式
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6198938.html
Copyright © 2020-2023  润新知