zoukankan      html  css  js  c++  java
  • MySQL 最左前缀(Leftmost Prefix) & 组合索引(复合索引,多列索引)

    资料来源于网络,仅供参考学习。

    CREATE TABLE test(
    a INT,
    b INT,
    c INT,
    KEY idx(a,b,c)
    );

    优: SELECT * FROM test WHERE a=10 AND b>50;
    差: SELECT * FROM test WHERE b>50;

    优: SELECT * FROM test ORDER BY a;
    差: SELECT * FROM test ORDER BY b;
    差: SELECT * FROM test ORDER BY c;

    优: SELECT * FROM test WHERE a=10 ORDER BY a;
    优: SELECT * FROM test WHERE a=10 ORDER BY b;
    差: SELECT * FROM test WHERE a=10 ORDER BY c;

    优: SELECT * FROM test WHERE a>10 ORDER BY a;
    差: SELECT * FROM test WHERE a>10 ORDER BY b;
    差: SELECT * FROM test WHERE a>10 ORDER BY c;

    优: SELECT * FROM test WHERE a=10 AND b=10 ORDER BY a;
    优: SELECT * FROM test WHERE a=10 AND b=10 ORDER BY b;
    优: SELECT * FROM test WHERE a=10 AND b=10 ORDER BY c;

    优: SELECT * FROM test WHERE a=10 AND b=10 ORDER BY a;
    优: SELECT * FROM test WHERE a=10 AND b>10 ORDER BY b;
    差: SELECT * FROM test WHERE a=10 AND b>10 ORDER BY c;

  • 相关阅读:
    Linux正则和grep命令
    Linux用户和权限
    XP下安装ubuntu
    Linux命令行和shell编程
    Linux软件安装及基本概念
    Linux历史,安装,分区,版本
    Eric Linux
    批量插入数据
    Django 相关
    标签,
  • 原文地址:https://www.cnblogs.com/huangzejun/p/8143718.html
Copyright © 2011-2022 走看看