]> begriffs open source - ai-pg/blob - full-docs/txt/storage-fsm.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / storage-fsm.txt
1
2 66.3. Free Space Map #
3
4    Each heap and index relation, except for hash indexes, has a Free Space
5    Map (FSM) to keep track of available space in the relation. It's stored
6    alongside the main relation data in a separate relation fork, named
7    after the filenode number of the relation, plus a _fsm suffix. For
8    example, if the filenode of a relation is 12345, the FSM is stored in a
9    file called 12345_fsm, in the same directory as the main relation file.
10
11    The Free Space Map is organized as a tree of FSM pages. The bottom
12    level FSM pages store the free space available on each heap (or index)
13    page, using one byte to represent each such page. The upper levels
14    aggregate information from the lower levels.
15
16    Within each FSM page is a binary tree, stored in an array with one byte
17    per node. Each leaf node represents a heap page, or a lower level FSM
18    page. In each non-leaf node, the higher of its children's values is
19    stored. The maximum value in the leaf nodes is therefore stored at the
20    root.
21
22    See src/backend/storage/freespace/README for more details on how the
23    FSM is structured, and how it's updated and searched. The
24    pg_freespacemap module can be used to examine the information stored in
25    free space maps.