sys.pdw_nodes_column_store_segments (Transact-SQL)

适用于:Azure Synapse AnalyticsAnalytics Platform System (PDW)

对于 columnstore 索引中的每列包括一行。

列名称 数据类型 说明
partition_id bigint 指示分区 ID。 在数据库中是唯一的。
hobt_id bigint 具有此 columnstore 索引的表的堆或 B 树 (hobt) 的 ID。
column_id int 列存储列的 ID。
segment_id int 列段的 ID。 为了向后兼容,即使这是行组 ID,仍会segment_id继续调用列名称。 可以使用 hobt_id、partition_id、column_id>< segment_id>唯一标识段<。
version int 列段格式的版本。
encoding_type int 用于该段的编码类型:

1 = VALUE_BASED - 无字典的非字符串/二进制 (类似于 4,具有一些内部变体)

2 = VALUE_HASH_BASED - 字典中具有通用值的非字符串/二进制列

3 = STRING_HASH_BASED - 字典中具有通用值的字符串/二进制列

4 = STORE_BY_VALUE_BASED - 无字典的非字符串/二进制

5 = STRING_STORE_BY_VALUE_BASED - 没有字典的字符串/二进制

所有编码都尽可能利用位打包和运行长度编码。
row_count int 行组中的行数。
has_nulls int 1 如果列段具有 Null 值。
base_id bigint 如果使用编码类型 1,则为基值 ID。 如果未使用编码类型 1,base_id设置为 1。
大小 float 如果使用编码类型 1,则为数量级。 如果未使用编码类型 1,则数量级设置为 1。
primary__dictionary_id int 主字典的 ID。 非零值指向当前段 (中此列的本地字典,即行组) 。 值为 -1 表示此段没有本地字典。
secondary_dictionary_id int 辅助字典的 ID。 非零值指向当前段 (中此列的本地字典,即行组) 。 值为 -1 表示此段没有本地字典。
min_data_id bigint 列段中的最小数据 ID。
max_data_id bigint 列段中的最大数据 ID。
null_value bigint 用于表示 Null 的值。
on_disk_size bigint 段大小(字节)。
pdw_node_id int Azure Synapse Analytics 节点的唯一标识符。

示例:Azure Synapse Analytics 和 Analytics Platform System (PDW)

将sys.pdw_nodes_column_store_segments与其他系统表联接,以确定每个逻辑表的列存储段数。

SELECT  sm.name           as schema_nm
,       tb.name           as table_nm
,       nc.name           as col_nm
,       nc.column_id
,       COUNT(*)          as segment_count
FROM    sys.[schemas] sm
JOIN    sys.[tables] tb                   ON  sm.[schema_id]          = tb.[schema_id]
JOIN    sys.[pdw_table_mappings] mp       ON  tb.[object_id]          = mp.[object_id]
JOIN    sys.[pdw_nodes_tables] nt         ON  nt.[name]               = mp.[physical_name]
JOIN    sys.[pdw_nodes_partitions] np     ON  np.[object_id]          = nt.[object_id]
                                          AND np.[pdw_node_id]        = nt.[pdw_node_id]
                                          AND np.[distribution_id]    = nt.[distribution_id]
JOIN    sys.[pdw_nodes_columns] nc        ON  np.[object_id]          = nc.[object_id]
                                          AND np.[pdw_node_id]        = nc.[pdw_node_id]
                                          AND np.[distribution_id]    = nc.[distribution_id]
JOIN    sys.[pdw_nodes_column_store_segments] rg  ON  rg.[partition_id]         = np.[partition_id]
                                                      AND rg.[pdw_node_id]      = np.[pdw_node_id]
                                                      AND rg.[distribution_id]  = np.[distribution_id]
                                                      AND rg.[column_id]        = nc.[column_id]
GROUP BY    sm.name
,           tb.name
,           nc.name
,           nc.column_id  
ORDER BY    table_nm
,           nc.column_id
,           sm.name ;

权限

需要 VIEW SERVER STATE 权限 。

另请参阅

Azure Synapse Analytics 和并行数据仓库目录视图
CREATE COLUMNSTORE INDEX (Transact-SQL)
sys.pdw_nodes_column_store_row_groups (Transact-SQL)
sys.pdw_nodes_column_store_dictionaries (Transact-SQL)