我在这里测试了两个表的左连接查询,SQL语句是:
select a.blog_id,a.blog_title,a.blog_thumb,a.blog_click,a.blog_addtime,a.blog_show,b.blog_category_name from `think_blog` a left join `think_blog_category` b on a.blog_category_id=b.blog_category_id where 1 order by blog_addtime desc limit 0,100
两个表分别是,think_blog和think_blog_category,分别有360万条和7条测试数据
如果设计表时没有索引,则执行上述查询语句需要花费的时间是:
我给两个表增加了索引,见下图
然后再执行上述查询语句,奇迹发生了
这一事实告诉我们,不是DBA的运维不是好的PHP程序员!
PS:觉得好要果断关注我哈