Top
Enterprise Postgres 17 Installation and Setup Guide for Server

E.2 Estimating Index Size Requirements

This section provides the formulas for estimating index size requirements.

Fujitsu Enterprise Postgres provides six index types: B-tree, Hash, GiST, GIN, SP-GiST, and VCI. 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. Refer to "E.7 Estimating VCI Disk Space Requirements" for information on how to estimate VCI.

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.

Table E.3 Estimation formula when the key data length is 512 bytes or less

Item

Estimation formula (bytes)

(1) Entry length

8 (*1) + key data length (*2)

*1: Entry header

*2: The key data length depends on its data type (refer to "E.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.
For example, if the calculated length is 28 bytes, add 4 to make the length 32 bytes.

(2) Page size requirement

8192 (*1) × fillfactor (*2) - 24 (*3) - 16 (*4)

*1: Page length (8192)

*2: Value of the fillfactor specified in the index definitions (if omitted, 90%)

In the case of indexes of primary key constraints and unique constraints,

the value of the fillfactor specified for each constraint in the table definitions (if omitted, 90%)

*3: Page header (24)

*4: Special data (16)

  • The calculated (2) page size requirement will be rounded down to the nearest integer.

(3) Number of entries per page

(2) Page size requirement / ((1) entry length + 4 (*1))

*1: Pointer length

  • Result of (3) number of entries per page will be rounded down to the nearest integer.

(4) Number of pages required for storing indexes

Total number of records / (3) number of entries per page

  • Result of (4) number of pages required for storing indexes will be rounded up to the nearest integer.

(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.

Table E.4 Estimation formula when the key data length exceeds 512 bytes

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.