6
Main
the actual data
Free space map
in pages after
vacuuming
Visibility map
marks pages where
all row versions
are visible
in all snapshots
Forks and Files
segment
1GB
page
8KB
Usually, each object has several corresponding fork s. Each fork is a set of
segments (that is, one or more files). The segment files that make up the
forks are logically divided into pages, usually 8KB each (this size can be set
for the entire cluster only when building the server). The file pages of all
forks are read from disk in a completely uniform way through a shared buffer
cache mechanism. The forks themselves contain different information and
have different internal page structure.
The main fork contains the actual data, such as table row versions and
index records.
The vm fork is the visibility (bit)map. It marks pages containing only the
current row versions visible in all data snapshots. In other words, these
pages have not been changed for so long that they have been completely
vacuumed of obsolete tuples.
The visibility map is used to optimize vacuuming (marked pages do not need
to be vacuumed) and to speed up index access. Row versioning information
exists only for tables, but not for indexes. Therefore, after getting a link to
the required row version from an index, you first need to check its visibility
by reading the corresponding table page. But if the index itself already
contains all the necessary columns, and the page is marked in the visibility
map, then reading the table page can be skipped.
The fsm fork is the free space map. It marks the available space inside the
pages, which is created, for example, during vacuuming. This map is used
when inserting new row versions in order to quickly find the appropriate
page.