MySQL学习笔记(七)–Index Merge

什么是Index Merge

The Index Merge access method retrieves rows with multiple range scans and merges their results into one. This access method merges index scans from a single table only, not scans across multiple tables. The merge can produce unions, intersections, or unions-of-intersections of its underlying scans.

举例说明

• If your query has a complex WHERE clause with deep AND/OR nesting and MySQL does not choose the optimal plan, try distributing terms using the following identity transformations:

• Index Merge is not applicable to full-text indexes.

In EXPLAIN output, the Index Merge method appears as index_merge in the type column. In this case, the key column contains a list of indexes used, and key_len contains a list of the longest key parts for those indexes. The Index Merge access method has several algorithms, which are displayed in the Extra field of EXPLAIN output:Using intersect(…) 或者Using union(…)或者Using sort_union(…)

The Index Merge access method has three algorithms

This access algorithm is applicable when a WHERE clause is converted to several range conditions on different keys combined with AND, and each condition is one of the following:

• An N-part expression of this form, where the index has exactly N parts (that is, all index parts are covered):

• Any range condition over the primary key of an InnoDB table.

例如:

The Index Merge intersection algorithm performs simultaneous(同时的、同步的) scans on all used indexes and produces the intersection of row sequences that it receives from the merged index scans.

If all columns used in the query are covered by the used indexes, full table rows are not retrieved (EXPLAIN output contains Using index in Extra field in this case).

If the used indexes do not cover all columns used in the query, full rows are retrieved only when the range conditions for all used keys are satisfied.

If one of the merged conditions is a condition over the primary key of an InnoDB table, it is not used for row retrieval, but is used to filter out rows retrieved using other conditions.

The criteria(标准、原则) for this algorithm are similar to those for the Index Merge intersection algorithm. The algorithm is applicable when the table’s WHERE clause is converted to several range conditions on different keys combined with OR, and each condition is one of the following:

• An N-part expression of this form, where the index has exactly N parts (that is, all index parts are covered):

• Any range condition over a primary key of an InnoDB table.

• A condition for which the Index Merge intersection algorithm is applicable

例如:

This access algorithm is applicable when the WHERE clause is converted to several range conditions combined by OR, but the Index Merge union algorithm is not applicable.

例如:

The difference between the sort-union algorithm and the union algorithm is that the sort-union algorithm must first fetch row IDs for all rows and sort them before returning any rows.

—转载MySQL官网文档

Original: https://www.cnblogs.com/xuliuzai/p/15542411.html
Author: 东山絮柳仔
Title: MySQL学习笔记(七)–Index Merge

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/621110/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 代码优化记录

    代码优化记录 神龟虽寿,犹有竟时。 神龟虽寿 犹有竟时 Original: https://www.cnblogs.com/taojietaoge/p/15853508.htmlA…

    数据库 2023年6月14日
    085
  • Read View的可见性判断理解

    读了 @SnailMann大佬【MySQL笔记】正确的理解MySQL的MVCC及实现原理 收益颇丰,非常感谢! 但对其中如何判断事务是否可见性还是不太理解,于是作了本文,在原博客基…

    数据库 2023年6月16日
    067
  • SpringBoot下的文件上传

    ; 代码很简单。已经放到码云了,码云地址:https://gitee.com/zhang-zhixi/springboot-upload.git posted @2022-04-2…

    数据库 2023年6月14日
    073
  • 20个数据库常见面试题讲解

    事务四大特性(ACID)原子性、一致性、隔离性、持久性? 事务的并发?事务隔离级别,每个级别会引发什么问题,MySQL默认是哪个级别? MySQL常见的三种存储引擎(InnoDB、…

    数据库 2023年6月16日
    083
  • SQL语句大全–SQL

    前言 本片博客使用mysql数据库进行数据操作,使用Navicat for mysql 这个IDE进行可视化操作。每个SQL语句都是亲身实验验证的,并且经过自己的思考的。能够保证s…

    数据库 2023年5月24日
    055
  • MySQL45讲之表空间回收

    本文介绍了为什么在删除部分表数据后表文件的大小保持不变,以及如何回收表空间。 [En] This article describes why the size of the tab…

    数据库 2023年5月24日
    055
  • MySQL 安全管理

    权限表 MySQL 服务器通过权限表来控制用户对数据库的访问,由 mysql_install_db 脚本初始化,MySQL 会根据这些权限表的内容为每个用户赋予相应的权限 user…

    数据库 2023年5月24日
    067
  • Asp.NET core/net 5接口返回实体含有long/int64的属性序列后最后几位变为0的解决

    Asp.NET core /net 5接口返回实体含有long/int64的属性时,序列后最后几位变为0的。 不得不吐槽一下MS,这种事还有问题,NND。 解决方案在startup…

    数据库 2023年6月14日
    071
  • java读写锁

    工作遇到了金钱计算,需要用到读写锁保证数据安全。记录一下。 单纯读没有限制,读写、写写的时候会有安全问题。 _hashMap_存在并发线程安全问题,而 _hashtable_线程安…

    数据库 2023年6月16日
    069
  • 域名SSL认

    阿里云:域名SSL认证-视频 Hole yor life get everything if you never give up. Original: https://www.cn…

    数据库 2023年6月9日
    0105
  • 创建一个属于自己的linux系统Docker镜像之旅-简单模式

    在创建容器之前首先要把该开启的服务都启动 1.CentOS的虚拟机/服务器 2.Docker 服务开启 systemctl start docker 文件的创建,可以在root下直…

    数据库 2023年6月6日
    070
  • CMU 15-445 Project 0 实现字典树

    原文链接:https://juejin.cn/post/7139572163371073543 项目准备 代码、手册 本文对应 2022 年的课程,Project 0 已经更新为实…

    数据库 2023年6月14日
    087
  • starter包~mica-auto自动生成spring.factories等元文件

    首先,进行springboot2.7之后,官方不推荐使用 /META-INF/spring.factories,转成和SPI比较类似的 /META-INF/spring/org.s…

    数据库 2023年6月6日
    062
  • 上传jar包到私有仓库nexus3

    上传Jar包到私有仓库Nexus3 官方文档 上传组件(Jar包) POST /service/rest/v1/components 官方例子: curl -v -u admin:…

    数据库 2023年6月9日
    073
  • MySQL系统安装与部署

    数据库版本标准化 1.确认Supported Platforms https://www.mysql.com/support/ 2.确认安装版本 推荐:5.7.22 ,8.0.20…

    数据库 2023年5月24日
    074
  • mysql8主从配置

    一、一般配置主从(这里主是m3300,从是3301、3302) 1.配置m3301 从mysql8里拿出这两个文件到m3301 2.配置my.ini 初&am…

    数据库 2023年5月24日
    076
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球