简体   繁体   中英

Why the SSMS display the message of Missing Index on the partitioned column?

I have a table partitioned by column X . However, SSMS displays Missing index (Impact 80.23): Create Nonclustered index [] on [dbo].[Table] ([X]) for the following query

select count(*) from table where X = 'xxx'

Is it still necessary to create an index on the partitioned column X? And it will be low density on a big table.

Edit:
I tried to select max(x) from table . It takes much longer time than running the similar SQL on a non-partitioned table which has a index on X . After enabled show statistics IO on , it shows that the query on partitioned table (without index on X ) has much more scan count (170) and logical reads (600K) than the non-partitioned table with an index (scan count:1, logical reads:4).

This is a feature of SSMS that recommends indexes that would benefit the query. Beware of limitations documented here . Here's some documentation on indexes and partitioning .

SQL Server uses partition elimination to speed up queries against partitioned objects, only accessing partitions containing data needed for the results. In order for partition elimination to occur, SQL Server needs to know how many partitions must be accessed. In SQL Server 2005, this enumeration is done using nested loop joins and scans/seeks on each partition. In SQL Server 2008 the execution plan for accessing a partitioned table will pretty much match that of a non-partitioned table.

In my testing, SQL Server 2005 execution plan showed a benefit from having an index (clustered or nonclustered) on the partitioned column. SQL Server 2008 execution plan changed to show the clustered index seek, but cost was the same whether the partitioned column was indexed or not. However, this partitioning seeks article discusses the skip scan which speeds up (and lowers cost of) data retrieval when the partitioned column and column referenced in the where clause are the same.

More info in these articles: SQL Server 2005 partitioning , SQL Server 2008 partitioning and SQL Server 2008 partitioning seeks .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM