PostgreSQL 8.4beta1 Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 53. Database Physical Storage | Fast Forward | Next |
A Free Space Map is stored with every heap and index relation, except for hash indexes, to keep track of available space in the relation. It's stored along the main relation data, in a separate FSM relation fork, named after relfilenode of the relation, but with a _fsm suffix. For example, if the relfilenode of a relation is 12345, the FSM is stored in a file called 12345_fsm, in the same directory as the main relation file.
The Free Space Map is organized as a tree of FSM pages. The bottom level FSM pages stores the free space available on every heap (or index) page, using one byte to represent each heap page. The upper levels aggregate information from the lower levels.
Within each FSM page is a binary tree, stored in an array with one byte per node. Each leaf node represents a heap page, or a lower level FSM page. In each non-leaf node, the higher of its children's values is stored. The maximum value in the leaf nodes is therefore stored at the root.
See src/backend/storage/freespace/README for more details on how the FSM is structured, and how it's updated and searched. Section F.24 contrib module can be used to view the information stored in free space maps.