Skip to content

Segment Alignment

NikoNeugebauer edited this page Aug 30, 2015 · 5 revisions

You can use alignment.sql script or as an alternative a stored procedure cstore_GetAlignment for getting information on the Columnstore Indexes Column Segments Alignment. This technique guarantees that your queries agains Columnstore Structure will perform much better, by reading only those Segments that potentially contain interesting information. Segment Alignment is also being called as Segment Ordering, meaning that it is simply an operation of ordering Columnstore Indexes Segments on one particular column.


Parameters:

@showPartitionStats bit = 1 Shows alignment statistics based on the partition. Setting this option to 0 will make the script treating all partitions inside a table as if it would have just 1. This makes sense if you want to have a big view across all partitions.

@showUnsupportedSegments bit = 1 Shows unsupported Segments in the result set

@tableName nvarchar(256) = NULL
Allows to show data filtered down to 1 particular table

@columnName nvarchar(256) = NULL Allows to show data filtered down to 1 particular column name.

@columnId int = NULL Allows to filter one specific column Id


Examples:

exec dbo.cstore_GetAlignment @tableName = 'FactOnlineSales';
Will show data for all the columns and Segments of the FactOnlineSales table.

exec dbo.cstore_GetAlignment @tableName = 'FactOnlineSales', @columnName = 'UnitCost';
Will show Segments alignment for all partitions of the FactOnlineSales table related to the column UnitCost.

exec dbo.cstore_GetAlignment @tableName = 'FactOnlineSales', @columnName = 'UnitCost', @showPartitionStats = 1;
Will show Segments alignment for all partitions of the FactOnlineSales table related to the column UnitCost, but will ignore the partitions and will treat them as if the table would have just 1 big partition.

exec dbo.cstore_GetAlignment;
Will show information about all tables with Columnstore Indexes in the current Database.