在分区表上设置群集主键的更好方法?

时间:2013-10-10 21:40:43

标签: sql-server sql-server-2008 database-partitioning

我有下表。

create table T (K1 date, K2 int, K3 varchar(10), C1 int, C2....)

该表将由K1分区(K1具有低选择性。数据将按K1的顺序附加)。首选以下哪个主键?

alter table T add primary key (K1, K2, K3)
alter table T add primary key (K2, K3, K1)

1 个答案:

答案 0 :(得分:0)

查看How important is the order of columns in indexes?this answer to Where should the partitioning column go in the primary key on SQL Server?

无论特定字段是否为分区字段,您都应该从最具选择性的字段转到最不具有选择性的字段 - 只要分区字段在索引中,以便保持索引与分区对齐。