Database Reference
In-Depth Information
Figure 34-15.
Building a columnstore index
During encoding, SQL Server replaces all values in the data with 64-bit integers using one of two encoding
algorithms. The first algorithm, called
dictionary encoding
, stores distinct values from the data in a separate structure
called a
dictionary
. Every value in a dictionary has a unique
ID
assigned. SQL Server replaces the actual value in the
data with an
ID
from the dictionary.
SQL Server creates one primary dictionary, which is shared across all row groups that belong to the same index
partition. Moreover, SQL Server can create one secondary dictionary that stores only the values from string columns
per row group. The purpose of secondary dictionaries is to reduce memory requirements during index creation and
scan operations.
Figure
34-16
illustrates dictionary encoding. For simplicity sake, it shows neither multiple row groups nor
secondary dictionaries in order to focus on the main idea of the algorithm.
Figure 34-16.
Dictionary encoding