【问题标题】:SQL table partition on same criteria as clustered indexSQL 表分区与聚集索引的条件相同
【发布时间】:2011-03-22 22:02:44
【问题描述】:

按照与聚集索引相同的标准对表进行分区是否有意义?例如,我有一个带有时间戳字段的表。这个时间戳是聚集索引所基于的,我想按那个时间戳将表分区为年。

这样做是否有意义,或者我应该将聚集索引更改为其他一些标准(基本上就像拥有两个聚集索引)?

【问题讨论】:

    标签: sql-server sql-server-2008


    【解决方案1】:

    在聚集索引上进行分区没有真正的问题。

    通常使用递增聚集索引,这样新数据只会进入最后一个分区。

    【讨论】:

      【解决方案2】:

      您不能以一种方式对聚集索引进行分区,而以另一种方式对表进行分区。这仅仅是因为聚集索引表。如果您在分区方案A 上创建一个表(堆),然后在分区方案B 上在其上构建一个聚集索引,那么最后您将在分区方案B 上创建一个表。您根本不能同时拥有一个表(一个堆)一个聚集索引。它们是相互排斥的。

      一个合理的问题是,您是否可以在与聚集索引不同的分区上拥有非聚集索引。从技术上讲是的,您可以,但这会创建所谓的“未对齐索引”,这从两个角度来看是有问题的:

      【讨论】:

      • 我记得您可以在具有多个列的 CL 上进行分区,然后选择其中任何一个列作为分区键。这是一种 CL 一种方式,另一种方式是分区 - 但不是真正独立的。
      • @Andrew:对,分区键可以是组成聚集索引键的任何列:When partitioning a clustered index, the clustering key must contain the partitioning column. When partitioning a nonunique clustered index, and the partitioning column is not explicitly specified in the clustering key, SQL Server adds the partitioning column by default to the list of clustered index keys. If the clustered index is unique, you must explicitly specify that the clustered index key contain the partitioning column.msdn.microsoft.com/en-us/library/ms187526.aspx
      猜你喜欢
      • 1970-01-01
      • 2018-05-08
      • 1970-01-01
      • 2010-11-23
      • 2013-08-20
      • 1970-01-01
      • 1970-01-01
      • 2015-06-14
      • 2020-08-04
      相关资源
      最近更新 更多