Top
Enterprise Postgres 17 Installation and Setup Guide for Server

E.1 Estimating Table Size Requirements

The following tables provide the formulas for estimating table size requirements.

Table E.1 Estimation formula when the record length is 2032 bytes or less

Item

Estimation formula (bytes)

(1) Record length

27(*1) + NULL map + OID + column data

NULL map: Number of columns / 8 (*2)
OID: 4
Column data: Sum of column lengths

*1: Record header section

*2: Round the result up to the next integer.

  • Because the column data is placed in boundaries of 8 bytes, you need to make an adjustment so that the sum of the record header section, NULL map and OID is a multiple of 8.
    For example, if the calculated length is 27 + 1 / 8 (rounded up) + 0 = 28 bytes, add 4 to make the length 32 bytes.

  • Because the data of each column is placed in boundaries of the defined data type, take the boundary of each data type into account for the length of the column data.
    For example, the length of the column data in the table below will not be the sum of the data types, which is 37 bytes, but will instead be 64 bytes following boundary adjustment.
    Definition: create table tb1(c1 char(1), c2 bigint, c3 int, c4 box)
    Estimation: CHAR type 1 byte + boundary adjustment of 7 bytes for BIGINT type 8 bytes + BIGINT type 8 bytes + INT type 4 bytes + boundary adjustment of 12 bytes for BOX type 32 bytes + BOX type 32 bytes = 64 bytes

  • Because each record is placed in boundaries of 8 bytes, you need to make an adjustment so that the length of the column data is a multiple of 8.

  • If the calculated record length exceeds 2,032 bytes, the variable length data in the record might be compressed automatically. If so, use the estimation formulas in "Table E.2 Estimation formula when the record length exceeds 2032 bytes" to estimate the table size.

(2) Page size requirement

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

*1: Page length (8192)

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

*3: Page header (24)

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

(3) Number of records per page

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

*1: Pointer length (4)

  • The result will be rounded down to the nearest integer.

(4) Number of pages required for storing records

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

  • The result will be rounded up to the next integer.

(5) Amount of space

(4) Number of pages required for storing records x page length x safety factor (*1)

*1: Specify 2.0 or higher.

  • This is the safety factor assumed if vacuuming is performed for garbage collection in tables and indexes.

Table E.2 Estimation formula when the record length exceeds 2032 bytes

Item

Estimation formula (bytes)

(5) Amount of space

Total number of records x (1) record length x safety factor (*1)

*1: Specify 2.0 or higher.

  • This is the safety factor assumed if vacuuming is performed for garbage collection in tables and indexes.