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.
每列都有可用的索引。例如:col1 上的 indx1 和 col2 上的 indx2。是否可以通过组合 col1 和 col2 再次创建复合索引 indx3?col1 和 col2 用于 where 条件。indx3 会生效吗?
是的,查询优化器将寻找最佳匹配索引。如果您在这两个字段的复合索引和查询 ( ) 中包含col1and ,它将使用该索引。col2where
col1
col2
where
您还应该考虑丢弃索引,col1因为复合索引也可以用于查询col1。它取决于复合索引中列的顺序:第一列可以在没有第二列的情况下查询。