+---------

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

----+
| Table | Create Table |
+--------- +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----+
| SmsTest | CREATE TABLE `SmsTest` (
`sn` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增编号',
`phoneNo` int(16) NOT NULL,
`channelType` int(11) DEFAULT NULL COMMENT '通道识别',
`status` tinyint(4) NOT NULL COMMENT '短信转态,1.发送成功,2.发送失败,3.发送异常',
PRIMARY KEY (`sn`)
) ENGINE=InnoDB AUTO_INCREMENT=45209 DEFAULT CHARSET=utf8 COMMENT='短信发送成功记录表' |
+--------- +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----+
1 row in set (0.06 sec) mysql> insert into SmsTest select sn,sn,channelType,status from SmsRecord limit 13;
Query OK, 13 rows affected (0.02 sec)
Records: 13 Duplicates: 0 Warnings: 0 mysql> create index SmsTest_idx1 on SmsTest(phoneNo);
Query OK, 0 rows affected (0.15 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> select * from SmsTest;
+-------+---------+-------------+--------+
| sn | phoneNo | channelType | status |
+-------+---------+-------------+--------+
| 1 | 1 | 2 | 1 |
| 2 | 2 | 2 | 1 |
| 3 | 3 | 2 | 1 |
| 4 | 4 | 2 | 1 |
| 5 | 5 | 2 | 1 |
| 6 | 6 | 2 | 1 |
| 7 | 7 | 2 | 1 |
| 8 | 8 | 2 | 1 |
| 9 | 9 | 2 | 1 |
| 10 | 10 | 2 | 1 |
| 11 | 11 | 2 | 1 |
| 12 | 12 | 2 | 1 |
| 13 | 13 | 2 | 1 |
| 45209 | 16 | 1 | 1 |
| 45210 | 17 | 1 | 1 |
| 45211 | 18 | 1 | 1 |
| 45212 | 19 | 1 | 1 |
| 45213 | 20 | 1 | 1 |
+-------+---------+-------------+--------+
18 rows in set (0.00 sec) Session 1: mysql> select @@tx_isolation;
+-----------------+
| @@tx_isolation |
+-----------------+
| REPEATABLE-READ |
+-----------------+
1 row in set (0.00 sec) mysql> start transaction;
Query OK, 0 rows affected (0.00 sec) mysql> select * from SmsTest where phoneNo between 10 and 20 for update;
+-------+---------+-------------+--------+
| sn | phoneNo | channelType | status |
+-------+---------+-------------+--------+
| 10 | 10 | 2 | 1 |
| 11 | 11 | 2 | 1 |
| 12 | 12 | 2 | 1 |
| 13 | 13 | 2 | 1 |
| 45209 | 16 | 1 | 1 |
| 45210 | 17 | 1 | 1 |
| 45211 | 18 | 1 | 1 |
| 45212 | 19 | 1 | 1 |
| 45213 | 20 | 1 | 1 |
+-------+---------+-------------+--------+
9 rows in set (0.02 sec) Session 2: mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(8,1,1);
Query OK, 1 row affected (0.01 sec) mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(9,1,1); --hang mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(10,1,1);--hang mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(11,1,1); --hang mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(12,1,1); --hang
mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(14,1,1); --hang mysql> insert into zjzc.SmsTest(PhoneNo,channelType,status) values(15,1,1); --hang RR区间锁 不是唯一索引,即使区间内没值,也锁

RR区间锁 不是唯一索引,即使区间内没值,也锁的更多相关文章

  1. mysql 5.6 read-committed隔离级别下并发插入唯一索引导致死锁一例

    今天,某个环境又发生了死锁,如下: *** (1) TRANSACTION:TRANSACTION 735307073, ACTIVE 0 sec insertingmysql tables in u ...

  2. 【译】SQL Server索引进阶第八篇:唯一索引

    原文:[译]SQL Server索引进阶第八篇:唯一索引     索引设计是数据库设计中比较重要的一个环节,对数据库的性能其中至关重要的作用,但是索引的设计却又不是那么容易的事情,性能也不是那么轻易就 ...

  3. mysql 区间锁 对于没有索引 非唯一索引 唯一索引 各种情况

    The locks are normally next-key locks that also block inserts into the "gap" immediately b ...

  4. 对于唯一索引使用唯一条件搜索, InnoDB 只锁定找到的index record,不是它之前的区间

    | test100 | CREATE TABLE `test100` ( `sn` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增编号', `phoneNo` ...

  5. mysql 多列唯一索引在事务中select for update是不是行锁?

    在表中有这么一索引 UNIQUE KEY `customer_id` (`customer_id`,`item_id`,`ref_id`) 问1. 这种多列唯一索引在事务中select for upd ...

  6. MongoDB性能篇之创建索引,组合索引,唯一索引,删除索引和explain执行计划

    这篇文章主要介绍了MongoDB性能篇之创建索引,组合索引,唯一索引,删除索引和explain执行计划的相关资料,需要的朋友可以参考下 一.索引 MongoDB 提供了多样性的索引支持,索引信息被保存 ...

  7. SQL知识整理二:锁、游标、索引

    锁 锁的模式 锁模式 描述 共享(S) 用于不更改或不更新数据(只读操作),如SELECT语句 更新(U) 用于可更新的资源中.防止当多个会话在读取.锁定以及随后可能进行的资源更新时发生常见形式的死锁 ...

  8. MongoDB 创建基础索引、组合索引、唯一索引以及优化

    一.索引 MongoDB 提供了多样性的索引支持,索引信息被保存在system.indexes 中,且默认总是为_id创建索引,它的索引使用基本和MySQL 等关系型数据库一样.其实可以这样说说,索引 ...

  9. mysql索引之一:索引基础(B-Tree索引、哈希索引、聚簇索引、全文(Full-text)索引区别)(唯一索引、最左前缀索引、前缀索引、多列索引)

    没有索引时mysql是如何查询到数据的 索引对查询的速度有着至关重要的影响,理解索引也是进行数据库性能调优的起点.考虑如下情况,假设数据库中一个表有10^6条记录,DBMS的页面大小为4K,并存储10 ...

随机推荐

  1. [转] git config命令使用第一篇——介绍,基本操作,增删改查

    平时我们在使用git的时候,很少去关注其配置是如何,而在实际开发中,对git config这个命令的使用也并不是很多,但是配置对一个程序和项目来说都是很重要的,我们今天来看看git的配置以及git c ...

  2. 自己写的demo。List<HashMap<String,Object>>=new ArrayList<HashMap<String,Object>>

    package com.pb.collection; import java.util.ArrayList; import java.util.HashMap; import java.util.It ...

  3. UIViewAnimationOptions类型

    一个非常强大的博客 http://www.cnblogs.com/kenshincui/    像我这种新手确实应该多看看   常规动画属性设置(可以同时选择多个进行设置) UIViewAnimati ...

  4. ios里面如何压缩图片

    在iOS里面,压缩图片跟在其他环境里面差不多,都和累死, 就是对当前图片从新画图,制定一个尺寸的问题 UIImage* image = [UIImage imageNamed:@"cat.j ...

  5. Nhibernate 智能提示 以及其他类库智能提示

    Nhibernate 的智能提示 Nhibernate.dll 放到以下路径 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framewo ...

  6. Linux 添加epel源

    1.epel-release yum install epel-release 这样有些没办法通过yum 安装  可以这样安装(例如redis)

  7. underscorejs-countBy学习

    2.20 countBy 2.20.1 语法 _.countBy(list, iteratee, [context]) 2.20.2 说明 排序一个列表组成一个组,并且返回各组中的对象的数量的计数.类 ...

  8. Chrome rem bug

    遇到一个bug,发现chrome在初始化页面的时候,会错误的渲染rem单位,导致字体过大. 比如: 正常的应该是这样的: 原因是,为了使用rem单位,我们常常将 html 的font-size设置为6 ...

  9. dedecms 文章内容文章名字和文章网址的调用

    文章标题: <a href="{dede:field name='arcurl'/}">{dede:field.title/}</a> 本文章网址: < ...

  10. linux 定时执行shell

    第一步:安装 crontab ,命令 yum -y install vixie-cron                扩展:service crond start //启动服务            ...