<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. phantomjs环境搭建已经运行

    1.下载phantomjs http://phantomjs.org/ 2.运行 新建phantomjs.bat,记得改目录路径 里面内容为: D:\java\phantomjs\phantomjs. ...

  2. Oracle 11g RAC OCR 与 db_unique_name 配置关系 说明

    一. 问题一 在做RAC standby 的alert log里发现如下错误: SUCCESS: diskgroup DATA was mounted ERROR: failed toestablis ...

  3. BZOJ 1025: [SCOI2009]游戏( 背包dp )

    显然题目要求长度为n的置换中各个循环长度的lcm有多少种情况. 判断一个数m是否是满足题意的lcm. m = ∏ piai, 当∑piai ≤ n时是满足题意的. 最简单我们令循环长度分别为piai, ...

  4. C中的链接属性及作用域

    如果相同的标识符出现在几个不同的源文件中时,它们是表示相同的实体,还是不同的实体.标识符的链接属性决定如何处理在不同文件中出现的标识符.标识符的作用域与它的链接属性有关. 链接属性一般有三种:exte ...

  5. Oracle单表的简单查询

    Oracle单表的简单查询 查看表结构 desc emp; 查询所有列 Select * from emp; 查找所以部门编号(查指定的列) select deptnofrom emp; 查找编号不同 ...

  6. xend调用xenstore的出错揭秘

    近期发现几例问题,均是xend里面报了同一个错误 File "/usr/lib64/python2.4/site-packages/xen/xend/xenstore/xstransact. ...

  7. PHP - 接口 - 单一接口

    /* * 接口的使用 */ //定义接口 interface IPerosn{ public function eat(); public function water(); } //定义继承自接口的 ...

  8. gdb 远程qemu-arm调试

    把 c 编译成 arm 指令的可运行文件 /usr/bin/arm-linux-gnueabi-g++ hello.cpp cat hello.cpp #include <stdio.h> ...

  9. c# 调用外部exe程序

    c#调用外部exe程序,首先要 using System.Diagnostics; 然后开启一个新process System.Diagnostics.ProcessStartInfo p=null; ...

  10. CSS未知div高度垂直居中代码_层和布局特效

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...