Columnstore index 列式索引也是一大特色,从SQL SERVER 2012起,支持列式索引了。我们要谈一谈列式索引的概念,用法,比较下与row-based index的区别,特别是列式索引的存储。据说列式索引采用了独特的压缩方式。这种压缩方式叫xVelocity(前称VertiPaq),专门用于 Analysis Service和Power Pivot的数据存储,现将其移到relational database storage engine中来。
mssql列存自SQL Server 2012引入,以应对数据分析(OLAP)和数据仓库(Data Warehouse)场景的查询。
以下三张图摘自:《Inside the SQL Server 2012 Columnstore Indexes》。
“关闭batch mode”方法比较隐蔽。可以使用 DBCC命令,DBCC命令有两种:
(1)、关闭/启用所有算子Batch Mode
关闭命令(即使用row mode):
DBCC TRACEON(9453,1)
启用命令:
DBCC TRACEOFF(9453,1)
(2)、关闭/启用Sort算子Batch Mode
关闭命令(即使用row mode):
DBCC TRACEON(9347,1)
启用命令:
DBCC TRACEOFF(9347,1)
The following query returns information about segments of a columnstore index.
SELECT i.name, p.object_id, p.index_id, i.type_desc, COUNT(*) AS number_of_segments FROM sys.column_store_segments AS s INNER JOIN sys.partitions AS p ON s.hobt_id = p.hobt_id INNER JOIN sys.indexes AS i ON p.object_id = i.object_id WHERE i.type = 5 OR i.type = 6 GROUP BY i.name, p.object_id, p.index_id, i.type_desc; GO