为什么 Sql Server 建议在索引已经存在的情况下创建索引?
我对我们的一个表运行了一个非常基本的查询,我注意到执行计划查询处理器建议我们在列上创建索引查询
是
SELECT SUM(DATALENGTH(Data))
FROM Item
WHERE Namespace = 'http://some_url/some_namespace/'
运行后,我收到以下消息
// The Query Processor estimates that implementing the following index could improve the query cost by 96.7211%.
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[Item] ([Namespace])
我的问题是我已经有这样的索引在该专栏上:
CREATE NONCLUSTERED INDEX [IX_ItemNamespace] ON [dbo].[Item]
(
[Namespace] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
为什么 Sql Server 建议我创建这样的索引(当它已经存在时)?
I ran a very basic query against one of our table and I noticed that the execution plan query processor is recommending that we create an index on a column
The query is
SELECT SUM(DATALENGTH(Data))
FROM Item
WHERE Namespace = 'http://some_url/some_namespace/'
After running, I get the following message
// The Query Processor estimates that implementing the following index could improve the query cost by 96.7211%.
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[Item] ([Namespace])
My problem is that I already have such index on that column:
CREATE NONCLUSTERED INDEX [IX_ItemNamespace] ON [dbo].[Item]
(
[Namespace] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
Why is Sql Server recommending me to create such index when it already exist?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
索引列和排序顺序有所不同...
上一页 SO 1 和 SO 2
但是,对于这个简单的事情,请尝试添加 INCLUDE 子句 使其覆盖。
Index column and sort order make a difference...
Previous SO 1 and SO 2
However, for something this simple try adding an INCLUDE clause to make it covering.