-- 给出一条查询,待优化
select sql_no_cache * from user left join article on(user.id = article.user_id)
where user.name like 'user_4%';
-- 给article表加个索引
CREATE INDEX user_id ON article (user_id);
-- 执行查询
-- 加了索引后,时间缩短了97%
Mysql Join 查询创建索引,提高查询效率
最新推荐文章于 2022-11-13 20:10:27 发布