Database Reference
In-Depth Information
The Header byte is a bitmask, which is similar to the Status Bits A byte in the FixedVar row format. It consists of
various bits representing the properties of the row, such as if it is an index row, if it has a versioning tag, if row was
deleted, and a few other attributes.
The CD region stores information about the column data in the row. It starts with either one or two bytes
indicating the number of columns in the CD array. The first bit in the first byte indicates if there are more than 127
columns and two bytes needed to store the number of columns. It is followed by the CD array itself. Each element in
the array stores information about one of columns, and it uses four bits to store one of the following values:
0 (0x0) indicates that the corresponding column is NULL
1 (0x1) indicates that the corresponding column stores an empty value for the data type.
For example, it is 0 for int columns. Empty columns do not use space in the Short or Long
Data Region sections.
2 (0x2) indicates that the corresponding column is a 1-byte short value.
3 (0x3) indicates that the corresponding column is a 2-byte short value.
4 (0x4) indicates that the corresponding column is a 3-byte short value.
5 (0x5) indicates that the corresponding column is a 4-byte short value.
6 (0x6) indicates that the corresponding column is a 5-byte short value.
7 (0x7) indicates that the corresponding column is a 6-byte short value.
8 (0x8) indicates that the corresponding column is a 7-byte short value.
9 (0x9) indicates that the corresponding column is an 8-byte short value.
10 (0xA) indicates that the corresponding column has more than an 8-byte value and is
stored in Long Data Region.
11 (0xB) indicates that the corresponding column is a bit column with the value of one.
Such a column does not use space in the Short Data Region.
Offsets for column data in the Short Data Region can be calculated based on the CD region information.
However, that calculation could be expensive when there are a large number of columns. SQL Server optimizes it by
storing a series of 30-column clusters at the beginning of the Short Column Data region. For example, if the Short Data
Region has 70 columns, SQL Server stores an array with two one-byte elements. The first element/byte stores the size
of the first 30-column cluster. The second element/byte stores the size of the second 30-column cluster. This array is
not stored if the row has less than 30 columns.
Figure 4-16 illustrates such an example. The value 10 (0xA) in the CD array indicates that the column stores long
data, and therefore the actual Short Data Region column cluster can include less than 30 values.
Figure 4-16. Example of CD and Short Data regions data
 
Search WWH ::




Custom Search