Mysql查询优化随笔记录

select SQL_CALC_FOUND_ROWS * from (select * from  oses_vehdata201606 union all  select * from  oses_vehdata201605)  t where 1=1 and t.Check_Time between '2016-06-23 00:00:00' and '2016-06-23 23:59:59'  order by Check_Time desc 

结果:45.66 s 、36.5s

select SQL_CALC_FOUND_ROWS * from (select * from  oses_vehdata201606)  t where 1=1 and t.Check_Time between '2016-06-23 00:00:00' and '2016-06-23 23:59:59'  order by Check_Time desc 

结果:8s、9s

select SQL_CALC_FOUND_ROWS * from (select * from  oses_vehdata201605)  t where 1=1 and t.Check_Time between '2016-06-23 00:00:00' and '2016-06-23 23:59:59'  order by Check_Time desc 

结果:7s

select SQL_CALC_FOUND_ROWS * from oses_vehdata201606  t where 1=1 and t.Check_Time between '2016-06-23 00:00:00' and '2016-06-23 23:59:59'  order by Check_Time desc 

结果:0.176s、0.052

数据库优化博客http://www.ihref.com/read-16422.html

MySQL索引和查询优化

 

posted @ 2016-06-24 09:24  Mars、少年  阅读(190)  评论(0编辑  收藏  举报