Postgresql 中文操作指南
73.4. Visibility Map #
每个堆关系都具有可见性映射 (VM) 来跟踪仅包含对所有活动事务已知的可见元组的页面;它还跟踪仅包含冻结元组的页面。它与主关系数据存储在单独的关系分支中,该分支以关系的文件节点编号命名,并加上一个__vm_ 后缀。例如,如果关系的文件节点是 12345,则 VM 存储在名为_12345_vm_ 的文件中,与主关系文件位于同一目录中。请注意,索引没有 VM。
Each heap relation has a Visibility Map (VM) to keep track of which pages contain only tuples that are known to be visible to all active transactions; it also keeps track of which pages contain only frozen tuples. It’s stored alongside the main relation data in a separate relation fork, named after the filenode number of the relation, plus a _vm suffix. For example, if the filenode of a relation is 12345, the VM is stored in a file called 12345_vm, in the same directory as the main relation file. Note that indexes do not have VMs.
可见性映射存储每个堆页两个比特。如果设置了第一个比特,则表示该页全部可见,或者换句话说,该页不包含任何需要真空的元组。 index-only scans 也可以使用这些信息,仅使用索引元组来回答查询。如果设置了第二个比特,则表示页面上的所有元组均已冻结。这意味着即使反环绕真空也不必重新访问页面。
The visibility map stores two bits per heap page. The first bit, if set, indicates that the page is all-visible, or in other words that the page does not contain any tuples that need to be vacuumed. This information can also be used by index-only scans to answer queries using only the index tuple. The second bit, if set, means that all tuples on the page have been frozen. That means that even an anti-wraparound vacuum need not revisit the page.
映射是保守的,因为我们确保每当设置一个位时,我们就知道该条件为真,但如果一个位没有被设置,则它可能是真的,也可能不是真的。可见性映射位仅由清理设置,但会被页面上的任何数据修改操作清除。
The map is conservative in the sense that we make sure that whenever a bit is set, we know the condition is true, but if a bit is not set, it might or might not be true. Visibility map bits are only set by vacuum, but are cleared by any data-modifying operations on a page.
可以使用 pg_visibility 模块检查可见性映射中存储的信息。
The pg_visibility module can be used to examine the information stored in the visibility map.