我有下表。
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)
答案 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?:
无论特定字段是否为分区字段,您都应该从最具选择性的字段转到最不具有选择性的字段 - 只要分区字段在索引中,以便保持索引与分区对齐。