分区边界 ID(例如 sys.partition_range_values 中)是否保证按分区范围排序?

Are Partition Boundaries IDs (in sys.partition_range_values eg.) guaranteed to be ordered by partition range?

假设您有一个分区函数,并且您使用 ALTER PARTITION SPLIT RANGEALTER PARTITION MERGE RANGE.

动态添加和删除该函数的范围边界

您可以询问 sys.partition_range_values 以确定当前范围边界是什么。

似乎无论您创建、拆分和合并范围,sys.partition_range_values table 将始终显示 boundary_ids(以及等效的分区 ID,在其他 sys tables) 按边界值的升序排列。

真的有保障吗?

我能确定boundary_id 1 永远是分区函数的最左边界吗?

Can I be certain that boundary_id 1 will always be the left-most boundary of the Partition Function?

是的。这是在 sys.partition_range_values documentation:

中特别提到的

ID (1-based ordinal) of the boundary value tuple, with left-most boundary starting at an ID of 1.

我对“最左边的边界从 ID 1 开始”的解释是边界值是有序的。 CREATE PARTITION FUNCTION doc也提到边界值排序:

If the values are not in order, the Database Engine sorts them, creates the function, and returns a warning that the values are not provided in order. The Database Engine returns an error if n includes any duplicate values