1:如果索引是唯一的,则间隙锁不起作用。

Gap locking is not needed for statements that lock rows using a unique index to search for a unique row. (This does not include the case that the search condition includes only some columns of a multiple-column unique index; in that case, gap locking does occur.)

For example, if the id column has a unique index, the following statement uses only an index-record lock for the row having idvalue 100 and it does not matter whether other sessions insert rows in the preceding gap:

If id is not indexed or has a nonunique index, the statement does lock the preceding gap.

2:间隙锁即使冲突也可以共存。

It is also worth noting here that conflicting locks can be held on a gap by different transactions. For example, transaction A can hold a shared gap lock (gap S-lock) on a gap while transaction B holds an exclusive gap lock (gap X-lock) on the same gap. The reason conflicting gap locks are allowed is that if a record is purged from an index, the gap locks held on the record by different transactions must be merged.

Gap locks inInnoDBare“purely inhibitive”, which means they only stop other transactions from inserting to the gap. They do not prevent different transactions from taking gap locks on the same gap. Thus, a gap X-lock has the same effect as a gap S-lock.

Gap locking can be disabled explicitly. This occurs if you change the transaction isolation level toREAD COMMITTEDor enable theinnodb_locks_unsafe_for_binlogsystem variable. Under these circumstances, gap locking is disabled for searches and index scans and is used only for foreign-key constraint checking and duplicate-key checking.

mysql 间隙锁 作用_关于Mysql 间隙锁的理解相关推荐

  1. mysql 校对规则作用_讲讲Mysql中的校对规则究竟是怎么一回事

    关键词:Mysql 字符集 charset  校对规则,collation, Illegal mix of collations 0.前言 有时候遇到这种情况,你用一个like语句查询,查到的结果中有 ...

  2. 1. 请简述mysql数据库的锁机制_【MySQL入门】之MySQL数据库的锁机制(二)

    上篇文章主要聊了全局锁和表锁,并详细分析MDL锁的作用以及可能带来的问题.今天我们主要来聊一聊Innodb存储引擎的行锁.MySQL的行锁是在引擎层由引擎自己实现的,并不是所有的引擎都支持行锁,MyI ...

  3. mysql slave是什么_是mysql作用

    php连接mysql数据库基础 bool define ( string name, mixed value [, bool case_insensitive] )define函数作用是定义常量 de ...

  4. mysql锁争用_关于MYSQL条件竞争与锁的问题

    最近在整理关支付安全的内容,其中就是涉及到了一个在支付过程中的条件竞争问题.以下都是基于mysql的与php的架构来描述该问题,大佬勿喷. 0x01. 条件竞争 什么是条件竞争: 竞争条件 发生在多个 ...

  5. delimiter在mysql中的作用_细细研究MySql中delimiter起到的作用_MySQL

    MySql中delimiter究竟可以起到些什么作用呢?可能不少人都有这样的疑惑,下文就为您介绍MySql中delimiter的作用,供您参考. MYSQL导出一个SQL后: DELIMITER $$ ...

  6. mysql 高并发写入锁表_使用mysql中的锁解决高并发问题

    阿里云产品通用代金券,最高可领1888分享一波阿里云红包. 阿里云的购买入口 为什么要加锁 多核计算机的出现,计算机实现真正并行计算,可以在同一时刻,执行多个任务.在多线程编程中,因为线程执行顺序不可 ...

  7. mysql server_id作用_在MySQL中设置`server-id`变量不起作用

    我一直在努力建立两个数据库作为主人和奴隶. 但我的奴隶服务器没有运气, 我遇到的问题是设置server-id变量. 无论我在哪里定义它(我查看了可能允许我定义变量的所有可能的cnf文件) 我试着像这样 ...

  8. mysql 中有什么命令_常用mysql命令大全

    常用的MySQL命令大全 连接MySQL格式: mysql -h主机地址 -u用户名 -p用户密码 1.例1:连接到本机上的MYSQL. 首先在打开DOS窗口,然后进入目录 mysqlbin,再键入命 ...

  9. mysql mvcc 隔离级别_关于 Mysql 四种隔离级别中 Lock 和 MVCC 的关系

    读写锁 共享锁(share lock)| 读锁(read lock) 读锁是共享的,或者说是相互不阻塞的.多个客户在同一时刻可以同时读取同一个资源,而互不干扰 SELECT ... LOCK IN S ...

  10. mysql for update场景_一个mysql死锁场景实例分析

    前言 最近遇到一个mysql在RR级别下的死锁问题,感觉有点意思,研究了一下,做个记录. 涉及知识点:共享锁.排他锁.意向锁.间隙锁.插入意向锁.锁等待队列 场景 隔离级别:Repeatable-Re ...

最新文章

  1. HTTP一个 TCP 连接可以发多少个 HTTP 请求等面试题
  2. linux发挥显卡性能,Linux Kernel 2.6.30下Intel显卡性能有大幅提升!
  3. APP开发者到期续费说明
  4. [PAT乙级]1030 完美数列
  5. 漫画:如何证明sleep不释放锁,而wait释放锁?
  6. php引用计数器,PHP 引用计数器 通俗版解释_PHP教程
  7. 百度网盘欲分拆闯关科创板?
  8. 只需五步,快速构建Python聊天室
  9. 全球排名前50网站使用的开发语言及系统平台
  10. 【OpenCV】配置OpenCV教程,OpenCV入门
  11. 服务器拒绝mac访问共享文件,Mac共享文件连接失败怎么办?Mac无法访问打开共享文件解决方法...
  12. GUI图形用户界面设计
  13. 微型计算机的cpu分类,微处理器分类及组成
  14. android怎样换背景图片,手机怎么抠图换背景 安卓和iPhone一键抠图换背景教程
  15. 苹果鼠标右键怎么按_精选分享,你不了解的这些鼠标增强神器
  16. 线性降维算法简介及PCA主成分分析
  17. Android Accessibility大致解析,通过adb运行纯java代码打开应用的辅助功能
  18. Android热修复-Tinker简析
  19. 最全的Windows7 服务优化、详解。
  20. kafka 不可以脱离 zookeeper

热门文章

  1. 希尔密码(原理+代码)
  2. 【常见手机操作系列】开启微信收款语音功能
  3. python各种源码下载
  4. 不同维度、元素的容器vector初始化自定义(C++)
  5. 清风老师数学建模笔记——层次分析法
  6. 解析2016中国智慧城市发展新趋势
  7. win7常见问题汇总
  8. avx2指令集对php有用吗,AVX2指令集的作用
  9. GitHub桌面版汉化
  10. 开发实现物理加速度移动_2019年最受物理老师欢迎的7款软件发布!不要错过!...