Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 php/mysql 应用程序,我在项目中的所有操作期间都有所有选择查询的日志。select x, y from t1 where (con1 AND con2) OR con3 order by colx我想知道是否有可能获得关于哪些列必须在我的日志中作为索引的任何建议?
select x, y from t1 where (con1 AND con2) OR con3 order by colx
我有很多这样的查询也加入了。我听说EXPLAIN可以帮助我为这个查询建议哪些列必须是索引。我想知道如何确定哪些列必须是索引。多列索引,单列索引。order by 需要是索引等。
EXPLAIN
您需要索引con1并con2作为多列索引。而con3作为单列索引
con1
con2
con3
INDEX (con1, con2), INDEX(con3)