• explain组合索引是否命中


    新建组合索引

    alter table table1 add index col_index(col1, col2, col3);

    查询:组合查询有向左匹配规则

    使用查询

    select * from table1 where col1='1';//使用索引

    select * from table1 where col1='1' and col2 = '2'; 使用索引

    select * from table1 where col1='1' and col2 = '2' and col3= '3';// 使用索引

    //有 or 条件不是用索引

    select * from table1 where col1='1' or col2='2' ;//不使用索引

    select * from table1 where col1='1' and col2='2' or col3 = '3';//不使用索引;

    //有like的条模糊查询没使用索引,后模糊查询使用索引

    select * from table1 where col1 like '1%'; //使用索引

    select * from table1 where col1 like '%1'; //不使用索引

    //有 > 或者 < 的都不使用索引

    //select * from table1 where col1 > 12 ; //不实用索引

  • 相关阅读:
    如何改变checkbox的样式
    EChart.js 简单入门
    Javascript异步编程的4种方法
    手写手机网站
    Handlebars的基本用法
    装饰器
    using Newtonsoft.Json;
    chrome插件学习笔记
    绩效考核如何快速评分
    wx jssdk
  • 原文地址:https://www.cnblogs.com/wxdr/p/13528050.html
Copyright © 2020-2023  润新知