索引优化求助

RXPY2007 2013-11-06 11:45:09
explain select a.id from a inner join (select b.a_id from b where b.type=1 group by b.a_id) as c on c.a_id = a.id where a.state=0

explain select a.id from a inner join (select b.a_id from b where b.type=1 group by b.a_id) as c on c.a_id = a.id where a.state=0
b使用索引成功Using where; Using index for group-by
a使用索引成功Using where
但是有Using temporary; Using filesort;
求助 临时表没有使用索引,如何优化
...全文
92 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACMAIN_CHM 2013-11-06
  • 打赏
  • 举报
回复
贴出完整的 explain select ...以供分析。 另外请提供 show index from ..
Rotel-刘志东 2013-11-06
  • 打赏
  • 举报
回复
create index ind_name on b(type,a_id);
Rotel-刘志东 2013-11-06
  • 打赏
  • 举报
回复
可以在临时表C中建立b.type=1建立索引
RXPY2007 2013-11-06
  • 打赏
  • 举报
回复
主要是临时表c没有索引,导致全表查询
rucypli 2013-11-06
  • 打赏
  • 举报
回复
a.state=0的数据多少 a的数据总共多少

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧