SELECT t1.c1, t2.c2 FROM table1 t1, table1 t2 WHERE t2.c2>0 AND t2.c3=1 AND t1.c2=0 AND t1.c4=t2.c4;
[quote=引用 6 楼 ACMAIN_CHM 的回复:] 创建如下索引。 create index x1 on table1 (c2,c4,c1); create index x3 on table1 (c4,c3,c2); create index x2 on table1 (c3,c2,c4); create index x4 on table1 (c4,c2,c1);
创建如下索引。 create index x1 on table1 (c2,c4,c1); create index x3 on table1 (c4,c3,c2); create index x2 on table1 (c3,c2,c4); create index x4 on table1 (c4,c2,c1);
执行计划中的ref都是const 属于很好的计划了 所以建议不用再进一步优化
执行explain SELECT t1.c1, t2.c2 FROM table1 t1, table1 t2 WHERE t2.c2>0 AND t2.c3=1 AND t1.c2=0 AND t1.c4=t2.c4; 贴出结果
56,940
社区成员
56,756
社区内容
加载中
试试用AI创作助手写篇文章吧