Mysql RR隔离更新列没有索引 会锁全表
<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隔离更新列没有索引 会锁全表的更多相关文章
- 解读SQL Server 2014可更新列存储索引——存储机制
概述 SQL Server 2014被号称是微软数据库的一个革命性版本,其性能的提升的幅度是有史以来之最. 可更新的列存储索引作为SQL Server 2014的一个关键功能之一,在提升数据库的查询性 ...
- mysql不会使用索引,导致全表扫描情况
不会使用索引,导致全表扫描情况 1.不要使用in操作符,这样数据库会进行全表扫描,推荐方案:在业务密集的SQL当中尽量不采用IN操作符 2.not in 使用not in也不会走索引推荐方案:用not ...
- MySQL RR隔离 读一致性
MySQL RR 模式下 事务隔离问题: Session 1: mysql> select * from test; +------+------+ | id | name | +------+ ...
- mysql-update时where条件无索引锁全表
1 5.3日数据处理需求 UPDATE md_meter set warranty_end_date = DATE_ADD(warranty_begin_date,INTERVAL 10 ...
- SQL SERVER中关于OR会导致索引扫描或全表扫描的浅析
在SQL SERVER的查询语句中使用OR是否会导致不走索引查找(Index Seek)或索引失效(堆表走全表扫描 (Table Scan).聚集索引表走聚集索引扫描(Clustered Index ...
- SQL SERVER中关于OR会导致索引扫描或全表扫描的浅析 (转载)
在SQL SERVER的查询语句中使用OR是否会导致不走索引查找(Index Seek)或索引失效(堆表走全表扫描 (Table Scan).聚集索引表走聚集索引扫描(Clustered Index ...
- [原创]MySQL RR隔离级别下begin或start transaction开启事务后的可重复读?
Server version: 5.6.21-log MySQL Community Server (GPL) 前提提要: 我们知道MySQL的RR(repeatable read)隔 ...
- mysql 有索引没走索引 更新锁全表
Session 1: mysql> select connection_id(); +-----------------+ | connection_id() | +-------------- ...
- MySQL 没有索引 锁全表
<h3 class="title" style="box-sizing: inherit; margin: 8px 0px 15px; padding: 0px; ...
随机推荐
- 【四】注入框架RoboGuice使用:(Your First System Service Injection)
上一篇我们简单的介绍了一下RoboGuice的使用([三]注入框架RoboGuice使用:(Your First Resource Injection)),今天我们来看下系统服务的使用注解的方法: 为 ...
- Permutations【python】
class Solution: # @param num, a list of integer # @return a list of lists of integers def permute(se ...
- 一些Xcode 5的使用提示和技巧
摘自:http://www.cocoachina.com/newbie/env/2014/0127/7766.html 感谢论坛成员郭亚鑫的热心翻译. 在iOS开发中,Xcode 是最使用最多的I ...
- 在mac os 中安装 autoconf and automake
转载地址:http://www.mattvsworld.com/blog/2010/02/install-the-latest-autoconf-and-automake-on-mac-os-10-6 ...
- Qt 富文本处理(QTextDocument和QTextBlock和QTextFrame和QTextTable和QTextList和QTextDocument)
最近使用 Qt 做一个离线博客编辑器,因而用到了 Qt 的富文本处理.参考 Qt 的文档,记录下 Qt 的富文本处理的相关技术.文档地址是 http://doc.qt.nokia.com/4.7/ri ...
- c#与java中byte字节的区别及转换方法
原文:c#与java中byte字节的区别及转换方法 在java中 byte的范围在 [-128,127] 在C#中 byte的范围在 [0,255] 所以 java程序与C#程序 进行数据传输的时 ...
- 一步一步重写 CodeIgniter 框架 (1) —— url 如何映射到具体的方法
CodeIgniter 框架最显著的特征就是 MVC 模式,它的做法就是提取 url 中的'分段', 映射到某个类的某个方法,从而由该方法来输出最终显示的页面内容.那么我们第一课中就是实现一个这样的原 ...
- RTSP调试代码
#ifdef _WIN32_WCE #include "stdafx.h" #endif #ifndef _WIN32_WCE #define WIN32_LEAN_AND_MEA ...
- HDU 4836 The Query on the Tree lca || 欧拉序列 || 动态树
lca的做法还是非常明显的.简单粗暴, 只是不是正解.假设树是长链就会跪,直接变成O(n).. 最后跑的也挺快,出题人还是挺阳光的.. 动态树的解法也是听别人说能ac的.预计就是放在splay上剖分一 ...
- could not create the java virtual machine(转)
打开不了myeclipse,报错“could not create the java virtual machine”,解决问题过程如下: 1.在D:\MyEclipse\eclipse有个eclip ...