文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>有时候 group by 为什么这么慢呢

有时候 group by 为什么这么慢呢

时间:2011-05-31  来源:吴永富

假设三个表 t_user , t_user_detail , t_log_info  记录都比较多(5000~1000)。

 

select count(user_id),a.user_type from t_user a inner join t_user_detail b on a.user_id=b.user_id inner join t_log_info c on b.user_id=c.user_id

where a.user_type=100     

这样会比较慢。

 

一个小小的改进速度会快很多。 c.user_id 改成 a.user_id

select count(user_id),a.user_type from t_user a inner join t_user_detail b on a.user_id=b.user_id inner join t_log_info c on b.user_id=a.user_id

where a.user_type=100    

 

个人观点, 表关联时尽量用where过滤后记录比较少的表的字段关联。  

 

相关阅读 更多 +
排行榜 更多 +
宝宝切水果安卓版

宝宝切水果安卓版

休闲益智 下载
儿童脑筋急转弯

儿童脑筋急转弯

休闲益智 下载
袭击现场2

袭击现场2

飞行射击 下载