简体   繁体   English

切换分区表示索引需要包含分区列

[英]Switch partition says index needs to include partitioned column

'ALTER TABLE SWITCH' statement failed. 'ALTER TABLE SWITCH'语句失败。 The table 'dbo.test' is partitioned while index 'IX_test' is not partitioned." 表'dbo.test'被分区,而索引'IX_test'没有被分区。“

When I run switch partition , I get this error. 当我运行switch partition ,我收到此错误。 To resolve this error, IX_test index should have the partitioned column included in its definition. 要解决此错误, IX_test索引应在其定义中包含分区列。 But if we include the partitioned column in the index, will this decrease the performance? 但是如果我们在索引中包含分区列,这会降低性能吗?

Example: We have Table X which has index on columns A, B, and C and it is partitioned on column D. We create one more table called X1 with the same schema as X. We will use this for a partition switch operation between them (X and X1). 示例:我们有表X,它在列A,B和C上有索引,它在列D上分区。我们再创建一个名为X1的表,其模式与X相同。我们将使用它来进行它们之间的分区切换操作(X和X1)。

As the index is not on column D (it's on A, B, C), I am getting the error above. 由于索引不在D列(它在A,B,C上),我得到上面的错误。 Is it good to add the partitioned column (ie, D) to the index as shown below? 将分区列(即D)添加到索引中是否很好,如下所示?

CREATE NONCLUSTERED INDEX IX_T_MSB_Pseudo ON dbo.T_MSB_Pseudo
(
    A, B, C
)
INCLUDE
(
    D
)
ON PRIMARY

Will this decrease the performance? 这会降低性能吗? Are there other alternatives to resolve this issue? 还有其他方法可以解决这个问题吗?

SWITCHing partitions requires the switched tables are pretty much* identical in every way SWITCHing分区要求切换表在各方面都非常相同
So make them so. 所以,让他们这样做。

The point of partition switching it to be able to swap a few pointers to swap data in and out without any actual processing or checks or data movement. 分区切换它能够交换几个指针以交换数据,而无需任何实际处理或检查或数据移动。 So there are rules. 所以有规则。

From MSDN "Transferring Data Efficiently by Using Partition Switching" , 2 key points 从MSDN “使用分区切换有效传输数据” ,2个关键点

Partitions must be on the same column 分区必须位于同一列

Nonclustered indexes must be defined and must be identical 必须定义非聚簇索引并且必须相同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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