简体   繁体   中英

SQL Server - creating nonclustered Index on specific partitions

One of the biggest benefits of table partitioning is that, "it is possible to rebuild an index on specific partition".

Imagine there is a partitioned table (has 12 partitions for now), which has clustered and a few non-clustered indices, all partition aligned.

I want to add a new nonclustered index to table, which does not have to be built for old partitions. I need this index for only the last 3 partitions.

So, how can I create a new nonclustered index for last 3 partitions of 12 partitioned table?

That is not possible. It would create problems for parameterized queries because the query planner would never statically know that the index can be used (except if there was a constant-expression predicate).

You can create a filtered index with `where partitionKey >= startOfSomePartition'. Your queries have to include this predicate statically, though.

You might try a view over two partitioned tables which have different schema. That's not very convenient to develop though.

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