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)

大家都在看

  • docker-compose部署rocketmq

    docker-compose安装: Ubuntu下载docker-compose文件 sudo curl -L https:/…

    数据库 2023年6月11日
    084
  • Proxy代理模式(结构型)

    一:描述: 为其他对象提供一种代理,来控制对这个对象的访问。如当操作某个对象很复杂时,我们可以建个代理来操作复杂对象,并开放一些简单的接口/方法来让我们比较简单的间接操作,也可在代…

    数据库 2023年6月11日
    092
  • Airbnb JavaScript 代码规范(转载)

    一种写JavaScript更合理的代码风格。 其他代码风格指南 1.1 原始值: 当你访问一个原始类型的时候,你可以直接使用它的值。 string number boolean n…

    数据库 2023年6月11日
    0122
  • Spring(四)-声明式事务

    Spring-04 声明式事务 1、事务的定义 事务就是由 一组逻辑上紧密关联的 多个工作单元(数据库操作)而合并成一个整体,这些操作 要么都执行,要么都不执行。 2、事务的特性:…

    数据库 2023年6月16日
    0115
  • vue导入UEditor报错问题分析

    直接上报错信息,如下。。。。 1.看看js是否导入 2.看看ue是否加入 F12 控制台输入则可看见那就是导入了,不是这个问题。 在查看问题的目标方向……….

    数据库 2023年6月6日
    0135
  • MySQL变量、流程控制和游标

    变量、流程控制和游标 变量 在MySQL数据库的存储过程和函数中,可以使用变量来存储查询或计算的中间结果数据,或者输出最终的结果的数据 系统变量 变量由系统定义,属于服务器级别 […

    数据库 2023年5月24日
    068
  • MySQL之外键、表关系及SQL查询关键字

    一、外键 假设我们现在有一个员工信息表,其中包含以下字段: [En] Suppose we now have an employee information table with …

    数据库 2023年5月24日
    076
  • Linux 实用命令

    实用命令: 1、查看端口占用情况 查看该端口是&…

    数据库 2023年6月16日
    078
  • MySQL select语句中where条件的提取过程

    select语句中where条件的提取过程 孔个个依然,在整理where条件提取过程时,发现中文互联网上关于这一块的知识要么是存在错误自相矛盾的,要么是版本过老,遂自己整理了一版。…

    数据库 2023年6月16日
    092
  • 开源者的自我修养|为 ShardingSphere 贡献了千万行代码的程序员,后来当了 CEO

    当一个人处在持续地追求与锋锐地思索状态中,他将收获怎样的价值与自由? 有人说,敲过万行代码的程序员,可以写一份基础版入行指南,给初阶人群作入门参考。码过十万行代码的程序员,能写一本…

    数据库 2023年6月16日
    0107
  • git 清除账号密码缓存

    配置用户名和邮箱: git config –global user.name “username”git config –globa…

    数据库 2023年6月11日
    089
  • Mybatis-Plus json 格式数据查询

    // List 存储 json 格式后的查询 .apply("JSON_CONTAINS(JSON_EXTRACT(order_id_list, ‘$.data[*]’)…

    数据库 2023年6月6日
    0273
  • 002从零开始入门Entity Framework Core——DbContext生存期、配置和初始化

    阅读须知:本文为入门介绍、指引文章,所示代码皆为最简易(或仅为实现功能)的演示示例版本,不一定切实符合个人(企业)实际开发需求。 DbContext 的生存期从创建实例时开始,并在…

    数据库 2023年6月14日
    084
  • Mysql_事务_存储过程_触发器

    一、什么是事务? 事务(Transaction),一般是指要做的或所做的事情。在计算机术语中是指访问并可能更新数据库中各种数据项的一个程序执行单元(unit)。事务通常由高级数据库…

    数据库 2023年6月11日
    094
  • 贪心算法原理及其应用

    概述 贪心算法应该算是那种”只闻其声不见其人”的算法,我们可能在好多地方都会听到贪心算法这一概念,并且它的算法思想也比较简单就是说算法只保证局部最优,进而达…

    数据库 2023年6月11日
    0148
  • windows安装mysql8.0.29(ZIP解压安装版本)

    一. 下载mysql 8.0.29软件包 二. 解压,初始化安装 1,打开下载后文件所在目录,使用解压软件解压,打开文件夹!(如图,文件路径不要出现中文!) 2,创建my.ini文…

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