zoukankan      html  css  js  c++  java
  • mysql中explain看性能

    select distinct col_name from table where a=X and b=Y and date(time)='xx-xx-xx';
    执行时间 27.9772 秒

    explain select distinct col_name from table where a=X and b=Y and date(time)='xx-xx-xx';

    idselect_typetabletypepossible_keyskeykey_lenrefrowsExtra  
    1 SIMPLE access ALL NULL NULL NULL NULL 38714243 Using where; Using temporary
     

    select distinct col_name from table where a=X and b=Y and time<'xx-xx-xx';
    执行时间 0.0038 秒

    explain select distinct col_name from table where a=X and b=Y and time<'xx-xx-xx';

    idselect_typetabletypepossible_keyskeykey_lenrefrowsExtra  
    1 SIMPLE access range idx_access_dt idx_access_dt 4 NULL 1 Using where; Using temporary

    select distinct col_name from table where a=X and b=Y and time='xx-xx-xx xx:xx:xx';
    执行时间 0.0031 秒

    explain select distinct col_name from table where a=X and b=Y and time='xx-xx-xx xx:xx:xx';

    idselect_typetabletypepossible_keyskeykey_lenrefrowsExtra  
    1 SIMPLE access ref idx_access_dt idx_access_dt 4 const 82 Using where; Using temporary

    参考:
    http://www.cnitblog.com/aliyiyi08/archive/2008/09/09/48878.html 

  • 相关阅读:
    13 内建属性 _getattribute_ 内建函数
    12 垃圾回收GC
    11 元类
    12 动态语言 __slots__
    11 作用域
    10 带参数的装饰器 通用装饰器 类装饰器
    9 装饰器
    8 闭包
    6 生成器 yield 协程
    cmd常用命令
  • 原文地址:https://www.cnblogs.com/nerrissa/p/4214116.html
Copyright © 2011-2022 走看看