It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened,
visit the help center 。
9年前关闭。
我正在使用 SQL 2000,并且我正在一个包含大约 3000 万行的表上运行一个简单的选择语句。选择查询如下所示:
select col1, col2, col3 from Table1 where col4=@col4 and col5=@col5 and col6=@col6
该表中有一个聚集索引(即主键),但这并没有用作 where 条件。上面提到的所有 where 标准都没有索引。
如何优化此查询?
如果我在 where 子句中为每一列添加索引,会有什么不同吗?
如果 where 子句中有 10 列,那么所有这 10 列都应该有索引吗?
编辑: 这可能是最常见的面试问题之一:)