您的位置:首页 > 数据库 > MySQL

mysql中explain看性能

2015-01-09 20:46 85 查看
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
1SIMPLEaccessALLNULLNULLNULLNULL38714243Using 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
1SIMPLEaccessrangeidx_access_dtidx_access_dt4NULL1Using 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
1SIMPLEaccessrefidx_access_dtidx_access_dt4const82Using where; Using temporary
参考:
http://www.cnitblog.com/aliyiyi08/archive/2008/09/09/48878.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: