<pre name="code" class="html">mysql> show variables like '%tx_isolation%';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| tx_isolation | REPEATABLE-READ |
+---------------+-----------------+
1 row in set (0.00 sec) Session 1:
mysql> show index from test;
Empty set (0.00 sec) mysql> update test set name='xxxx' where id=2;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0 Session 2:
mysql> select * from test;
+------+------+
| id | name |
+------+------+
| 1 | b |
| 11 | aa |
| 2 | xxxx |
| 10 | a |
+------+------+
4 rows in set (0.00 sec) mysql> update test set name='xxxx' where id=10;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction 没有索引的情况 ,RR隔离级别 是锁全表 //********************************************************************* Session 1:
mysql> update test set id=99 where id=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 Session 2:
mysql> update test set id=100 where id=2; --HANG //测试有主键的情况下: mysql> CREATE TABLE `s100` (
-> `sn` int(11) NOT NULL AUTO_INCREMENT,
-> `id` int,
-> `info` varchar(40) DEFAULT NULL,
-> PRIMARY KEY (`sn`)
-> ) ENGINE=InnoDB AUTO_INCREMENT=225 DEFAULT CHARSET=utf8 ;
Query OK, 0 rows affected (0.04 sec) mysql> show index from s100;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| s100 | 0 | PRIMARY | 1 | sn | A | 0 | NULL | NULL | | BTREE | | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec) Session 1: mysql> update s100 set id=100 where id=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 Session 2: mysql> update s100 set id=200 where id=2;---Hang //测试更新是否锁全表: mysql> explain update Product set
-> status = '3'
-> where status = '2' and buyToTime < '2016-05-10 12:54:00';
+----+-------------+---------+-------+---------------+---------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+-------+---------------+---------+---------+------+------+-------------+
| 1 | SIMPLE | Product | index | NULL | PRIMARY | 4 | NULL | 506 | Using where |
+----+-------------+---------+-------+---------------+---------+---------+------+------+-------------+
1 row in set (0.00 sec) 从possible_keys中所选择使用的索引 正常走索引的更新是: mysql> explain update test set id=100 where id=1;
+----+-------------+-------+-------+---------------+-----------+---------+-------+------+------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+-----------+---------+-------+------+------------------------------+
| 1 | SIMPLE | test | range | test_idx1 | test_idx1 | 5 | const | 1 | Using where; Using temporary |
+----+-------------+-------+-------+---------------+-----------+---------+-------+------+------------------------------+
1 row in set (0.00 sec)
												

Mysql RR隔离更新列没有索引 会锁全表的更多相关文章

  1. 解读SQL Server 2014可更新列存储索引——存储机制

    概述 SQL Server 2014被号称是微软数据库的一个革命性版本,其性能的提升的幅度是有史以来之最. 可更新的列存储索引作为SQL Server 2014的一个关键功能之一,在提升数据库的查询性 ...

  2. mysql不会使用索引,导致全表扫描情况

    不会使用索引,导致全表扫描情况 1.不要使用in操作符,这样数据库会进行全表扫描,推荐方案:在业务密集的SQL当中尽量不采用IN操作符 2.not in 使用not in也不会走索引推荐方案:用not ...

  3. MySQL RR隔离 读一致性

    MySQL RR 模式下 事务隔离问题: Session 1: mysql> select * from test; +------+------+ | id | name | +------+ ...

  4. mysql-update时where条件无索引锁全表

          1 5.3日数据处理需求 UPDATE md_meter set warranty_end_date = DATE_ADD(warranty_begin_date,INTERVAL 10 ...

  5. SQL SERVER中关于OR会导致索引扫描或全表扫描的浅析

    在SQL SERVER的查询语句中使用OR是否会导致不走索引查找(Index Seek)或索引失效(堆表走全表扫描 (Table Scan).聚集索引表走聚集索引扫描(Clustered Index ...

  6. SQL SERVER中关于OR会导致索引扫描或全表扫描的浅析 (转载)

    在SQL SERVER的查询语句中使用OR是否会导致不走索引查找(Index Seek)或索引失效(堆表走全表扫描 (Table Scan).聚集索引表走聚集索引扫描(Clustered Index ...

  7. [原创]MySQL RR隔离级别下begin或start transaction开启事务后的可重复读?

    Server version:         5.6.21-log MySQL Community Server (GPL) 前提提要: 我们知道MySQL的RR(repeatable read)隔 ...

  8. mysql 有索引没走索引 更新锁全表

    Session 1: mysql> select connection_id(); +-----------------+ | connection_id() | +-------------- ...

  9. MySQL 没有索引 锁全表

    <h3 class="title" style="box-sizing: inherit; margin: 8px 0px 15px; padding: 0px; ...

随机推荐

  1. go - 变量和常量

    1.定义变量 goLang中定义变量的方式很多 先声明再使用:如果定义的变量未使用编译时会报错 a. /*定义单个变量*/ var varName type //定义一个 type 类型的变量 var ...

  2. NGUI字体贴图压缩以及相关Shader解读

    一般游戏中,字体贴图是游戏贴图压缩的一个重点,特别是对于中文的游戏.考虑的字体贴图的特殊性,一般我们输出的字体贴图是不含颜色信息的,所以正常情况下,我们输出的字体贴图RGBA每一个通道都是一样的.这样 ...

  3. 无法启动outlook mapi

    office2013 管理员权限,在命令行中定位到office15文件夹,然后运行命令"outlook /importprf ..prf"

  4. BZOJ 2427: [HAOI2010]软件安装( dp )

    软件构成了一些树和一些环, 对于环我们要不不选, 要么选整个环. 跑tarjan缩点后, 新建个root, 往每个入度为0的点(强连通分量) 连边, 然后跑树dp( 01背包 ) ---------- ...

  5. HDOJ 1325 并查集

    跟小希的迷宫基本一样,只是此题是有向图,要注意:1无环 2 只有一个入度为0的结点(根结点), 不存在入度大于1的结点.输入结束条件是两个负数,而不是-1,不然会TLE. #include<st ...

  6. Qt属性系统

    The Property System Qt提供一个类似于其他编译器供应商提供的精致的属性系统.然而,作为一个编译器和平台独立的库,Qt并不依赖于非标准编译器特性,如__property 或 [pro ...

  7. Unix/Linux环境C编程新手教程(24) MySQL 5.7.4 for Red Hat Enterprise 7(RHEL7)的安装

    远观历史, MySQL的主要目的是为了可以在单处理器核心的商业服务器上执行.现在MySQL的一个变化用户可能不会注意到,那就是甲骨文已经開始又一次架构MySQL的代码,使它大量的模块化.如软件解析器, ...

  8. Win8.1应用开发之动态磁贴

    using demo02.Common; using System; using System.Collections.Generic; using System.IO; using System.L ...

  9. log4net结构

    log4net是.Net下一个非常优秀的开源日志记录组件.log4net记录日志的功能非常强大.它可以将日志分不同的等级,以不同的格式,输出到不同的媒介.其大致分为如下这些模块. Appenders模 ...

  10. java 一个函数EnumMap返回多个值

    java 一个函数如何返回多个值   在开发过程中,经常会有这种情况,就是一个函数需要返回多个值,这是一个问题!! 网上这个问题的解决方法: 1.使用map返回值:这个方法问题是,你并不知道如何返回值 ...