zoukankan      html  css  js  c++  java
  • mysql执行计划

    通过EXPLAIN关键分析的结果由以下列组成,接下来挨个分析每一个列

    1.1.1.1.        ID列

    ID列:描述select查询的序列号,包含一组数字,表示查询中执行select子句或操作表的顺序

    根据ID的数值结果可以分成一下三种情况

    l  id相同:执行顺序由上至下

    l  id不同:如果是子查询,id的序号会递增,id值越大优先级越高,越先被执行

    l  id相同不同:同时存在

    分别举例来看

     

    1.1.1.1.1.      Id相同

     

    如上图所示,ID列的值全为1,代表执行的允许从t1开始加载,依次为t3与t2

     

    EXPLAIN
    select t2.* from t1,t2,t3  where t1.id = t2.id and t1.id = t3.id
    and t1.other_column = '';

    1.1.1.1.1.      Id不同

    如果是子查询,id的序号会递增,id值越大优先级越高,越先被执行

    EXPLAIN
    select t2.* from  t2 where id = (
    select id from t1 where id =  (select t3.id from t3 where t3.other_column='')
    );

    1.1.1.1.1.      Id相同又不同

    id如果相同,可以认为是一组,从上往下顺序执行;

    在所有组中,id值越大,优先级越高,越先执行

    EXPLAIN
    select t2.* from (
     select t3.id
    from t3 where t3.other_column = ''
    ) s1 ,t2 where s1.id = t2.id

     

     

    select_type

    Select_type:查询的类型,

    要是用于区别:普通查询、联合查询、子查询等的复杂查询

     

    类型如下

     simple

    EXPLAIN select * from t1

    简单的 select 查询,查询中不包含子查询或者UNION

  • 相关阅读:
    python_接口基础知识
    python_基础总结
    python_配置文件_yaml
    python_loggin日志处理
    python_数据驱动_ddt
    python_unittest_单元测试_openpyxl
    python_类与对象总结_继承
    python_路径操作及类和对象
    python_导包
    Codeforces Round #655 (Div. 2) B. Omkar and Last Class of Math
  • 原文地址:https://www.cnblogs.com/coder-lzh/p/11034103.html
Copyright © 2011-2022 走看看