Postgresql 中文操作指南
73.3. Free Space Map #
除了哈希索引外,每个堆和索引关系都具有一个空闲空间映射 (FSM),用于跟踪关系中的可用空间。它与主关系数据一起存储在单独的关系分支中,该分支以关系的文件节点号命名,外加一个 _fsm 后缀。例如,如果某个关系的文件节点为 12345,则 FSM 存储在名为 12345_fsm 的文件中,与主关系文件位于同一个目录中。
Each heap and index relation, except for hash indexes, has a Free Space Map (FSM) to keep track of available space in the relation. It’s stored alongside the main relation data in a separate relation fork, named after the filenode number of the relation, plus a _fsm suffix. For example, if the filenode of a relation is 12345, the FSM is stored in a file called 12345_fsm, in the same directory as the main relation file.
空闲空间映射组织为一个 FSM 页面树。底层 FSM 页面使用一个字节表示每个堆(或索引)页面上的可用空间,以存储这些页面中的可用空间。上层汇总下层的相关信息。
The Free Space Map is organized as a tree of FSM pages. The bottom level FSM pages store the free space available on each heap (or index) page, using one byte to represent each such page. The upper levels aggregate information from the lower levels.
在每个 FSM 页面中,都会有一个二叉树,该二叉树存储在一个数组中,每个节点一个字节。每个叶节点表示一个堆页面或一个较低级别的 FSM 页面。在每个非叶节点中,存储的是其子节点的较大值。叶节点中的最大值因此存储在根节点中。
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.
有关 FSM 如何构建及其如何更新和搜索的更多详细信息,请参阅 src/backend/storage/freespace/README。 pg_freespacemap模块可用于检查存储在空闲空间映射中的信息。
See src/backend/storage/freespace/README for more details on how the FSM is structured, and how it’s updated and searched. The pg_freespacemap module can be used to examine the information stored in free space maps.