Calculate row size
For every row of every table, there is a 24-byte fixed overhead of the rowid, createxid, and deletexid. If you have any nullable columns, a null vector is required and it is N/8 bytes where N is the number of columns in the record. The system rounds up the size of this header to a multiple of 4 bytes.
- Column of type VARCHAR
- Column of type CHAR where the length is greater than 16 (stored internally as VARCHAR)
- Column of type NCHAR
- Column of type NVARCHAR
- Column of type JSON
Using UTF-8 encoding, each Unicode code point can require 1 - 4 bytes of storage. A 10-character string requires 10 bytes of storage if it is ASCII and up to 20 bytes if it is Latin, or as many as 40 bytes if it is Kanji.
The only time a record does not contain a header is if all the columns are defined as NOT NULL, there are no character data types larger than 16 bytes, and no variable character data types.
Create XID | Delete XID | Row ID | Null vector | Record length | Column_1 …Column_n |
---|---|---|---|---|---|
8 bytes | 8 bytes | 8 bytes | N/8 bytes | 4 bytes | Number of bytes |