美文网首页
mysql-三表索引优化

mysql-三表索引优化

作者: 有心人2021 | 来源:发表于2020-02-24 20:21 被阅读0次

接双表索引篇

drop index idx_card on book;
//都没有索引
explain select * from class left join book on class.card = book.card left join phone on book.card = phone.card;
初始索引.png

3个表联合查询,同理应该是在后面2个表上创建索引,

create index idx_card on book(card);
create index idx_card on phone(card);
优化后的索引分析.png

索引均被使用上,后面两个type由ALL提升为为ref,rows 24,1,1比优化前好上不少。

相关文章

网友评论

      本文标题:mysql-三表索引优化

      本文链接:https://www.haomeiwen.com/subject/lvxwqhtx.html