This section provides the formulas for estimating index size requirements.
Symfoware Server provides five index types: B-tree, Hash, GiST, GIN, and SP-GiST (the same as PostgreSQL). If you do not specify the index type in the CREATE INDEX statement, a B-tree index is generated.
The following describes how to estimate a B-tree index.
A B-tree index is saved as a fixed-size page of 8 KB. The page types are meta, root, leaf, internal, deleted, and empty. Since leaf pages usually account for the highest proportion of space required, you need to calculate the requirements for these only.
Item | Estimation formula (bytes) |
---|---|
(1) Entry length | 8 (*1) + key data length (*2) *1: Entry head *2: The key data length depends on its data type (refer to "I.3 Sizes of Data Types" for details). Because each entry is placed in boundaries of 8 bytes, you need to make an adjustment so that the length of the key data is a multiple of 8.
|
(2) Page size requirement | 8152 (*1) *1: Page length (8192) - page header (24) - special data (16) = 8152 |
(3)Number of entries per page | (2) Page size requirement / ((1) entry length + 4 (*1)) *1: Pointer length
|
(4) Number of pages required for storing indexes | Total number of records / (3) number of entries per page
|
(5) Space requirement | (4) Number of pages required for storing indexes x 8192 (*1) / usage rate (*2) *1: Page length *2: Specify 0.7 or lower. |
Item | Estimation formula (bytes) |
---|---|
(5) Space requirement | Total number of records x key data length x compression ratio (*1) / usage rate (*2) *1: The compression ratio depends on the data value, so specify 1. *2: Specify 0.7 or lower as the usage rate. |