A cell whose payload is too large for its page keeps the first part of the payload on the page and puts the rest on a chain of overflow pages. The cell then ends with the number of the first overflow page. Whether a cell spills, and how much of it stays, follows from its payload size alone, by the rules below.
Thresholds
U is the usable size of a page, the page size minus the reserved space, and P the payload size from the cell. Every division is rounded down.
| Value | Meaning | Formula |
|---|---|---|
| X | the most a cell keeps on its page | U − 35 on a table leaf page; ((U − 12) × 64 ÷ 255) − 23 on an index page |
| M | the least a spilling cell keeps on its page | ((U − 12) × 32 ÷ 255) − 23 |
| K | the amount that fills the last overflow page exactly | M + ((P − M) mod (U − 4)) |
- If P ≤ X, the whole payload stays on the page and there is no overflow page number.
- If P > X and K ≤ X, the first K bytes stay on the page.
- If P > X and K > X, the first M bytes stay on the page.
- The rest goes to overflow pages, U − 4 bytes on each.
Table interior cells have no payload, so they never spill. The thresholds for common usable sizes:
| U | X, table leaf | X, index | M | Payload per overflow page |
|---|---|---|---|---|
| 1,024 | 989 | 230 | 103 | 1,020 |
| 4,096 | 4,061 | 1,002 | 489 | 4,092 |
For example, with U = 1,024, a table row of 3,010 bytes has P > 989. K = 103 + (2,907 mod 1,020) = 103 + 867 = 970, which is not more than 989, so 970 bytes stay on the page and the other 2,040 fill two overflow pages of 1,020 bytes each.
Overflow pages
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | Next overflow page | The next page of the chain, or 0 on the last. |
| 4 | U − 4 | bytes | Overflow content | The next part of the payload. |
The pages of a chain need not be next to each other or in order. The payload continues from where the cell’s part stops, page after page; on the last page, the bytes after the end of the payload mean nothing. An overflow page carries no type byte, so a reader knows it only by following a cell’s chain.