zoukankan      html  css  js  c++  java
  • 索引命中规则详解

    索引命中规则详解:

    t这张表 a,b,c 三个字段组成组合索引

    1.  索引命中规则详解:
    2.  t这张表 a,b,c 三个字段组成组合索引
    3.  select * from t where a=? and b=? and c=? 全命中
    4.  select * from t where c=? and b=? and a=? 全命中 解析MySQL的查询优化器会自动调整where子句的条件顺序以使用适合的索引
    5.  select * from t where a=? 命中a 解析:最左前缀匹配
    6.  select * from t where a=? and b=? 命中a和b 解析:最左前缀匹配
    7.  select * from t where a=? or b=? 一个没命中 解析or无法命中
    8.  select * from t where a=? and c=? 命中a 解析:最左前缀匹配,中间没有则无法使用索引
    9.  select * from t where a=? and b in ( x, y, z) and c=? 全部命中 in精确匹配可以使用索引
    10.  select * from t where b=? 一个没命中 解析:最左前缀匹配原则
    11.  select * from t where b=? and c=? 一个没命中 解析:最左前缀匹配原则
    12.  select * from t where a=? and b like 'xxx%' 命中a
    13.  select * from t where a=? and b like '%xxx' 命中a和b
    14.   select * from t where a<? and b=? 命中a 解析这个是范围查找
    15.  select * from t where a between ? and ? and b=? 命中a和b 解析BETWEEN相当于in操作是精确匹配
    16.  select * from t where a between ? and ? and b=? and c and between ? and ? 全部命解析中同上
    17.  select * from where a-1=? 函数和表达式无法命中索引
  • 相关阅读:
    Navicat Premium 15 永久激活版安装教程
    win10安装redis
    Linux下安装Go环境
    IoT platforms that deserves to be noticed
    TortoiseGit配置
    impot和require区别
    websocket搭建简单的H264实时视频流播放
    应用索引技术优化SQL 语句(Part 3)
    应用索引技术优化SQL 语句(Part 2)
    应用索引技术优化SQL 语句(Part 1)
  • 原文地址:https://www.cnblogs.com/Wl55387370/p/13601894.html
Copyright © 2011-2022 走看看