The Visibility Map (and other relation forks)
The Visibility Map is a simple data structure associated with every heap relation (table). It is a "relation fork"; an on-disk ancillary file associated with a particular relation (table or index). Note that index relations (that is, indexes) do not have a visibility map associated with them. The visibility map is concerned with tracking which tuples are visible to all transactions at a high level. Tuples from one transaction may or may not be visible to any given other transaction, depending on whether or not their originating transaction actually committed (yet, or ever, if the transaction aborted), and when that occurred relative to our transaction's current snapshot. Note that the exact behaviour depends on our transaction isolation level. Note also that it is quite possible for one transaction to see one physical tuple/set of values for one logical tuple, while another transaction sees other, distinct values for that same logical tuple, because, in effect, each of the two transaction has a differing idea of what constitutes "now". This is the core idea of MVCC. When there is absolute consensus that all physical tuples (row versions) in a heap page are visible, the page's corresponding bit may be set.
Another relation fork that you may be familiar with is the freespace map. In contrast to the visibility map, there is a FSM for both heap and index relations (with the sole exception of hash index relations, which have none).
The purpose of the freespace map is to quickly locate a page with enough free space to hold a tuple to be stored, or to determine if no such page exists and the relation has to be extended.
In PostgreSQL 8.4, the current freespace map implementation was added. It made the freespace map an on-disk relation fork. The previous implementation required administrators to guestimate the number of relations, and the required freespace map size for each, so that the freespace map existed only in a fixed allocation of shared memory. This tended to result in wasted space due to undersizing, as the core system's storage manager needlessly extended relations.
[peter@peterlaptop 12935]$ ls -l -h -a -rw-------. 1 peter peter 8.0K Sep 28 00:00 12910 -rw-------. 1 peter peter 24K Sep 28 00:00 12910_fsm -rw-------. 1 peter peter 8.0K Sep 28 00:00 12910_vm ***SNIP***
The FSM is structured as a binary tree . There is one leaf node per heap page, with non-leaf nodes stores the maximum amount of free space for any of its children. So, unlike EXPLAIN output's node costs, the values are not cumulative.
The visibility map is a simpler structure. There is one bit for each page in the heap relation that the visibility map corresponds to.
The primary practical reason for having and maintaining the visibility map is to optimise VACUUM. A set bit indicates that all tuples on the corresponding heap page are known to be visible to all transactions, and therefore that vacuuming the page is unnecessary. Like the new freespace map implementation, the visibility map was added in Postgres 8.4.
The visibility map is conservative in that a set bit (1) indicates that all tuples are visible on the page, but an unset bit (0) indicates that that condition may or may not be true .
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26477398/viewspace-2128518/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- other 1878
- No need to add that my being happy in Forks is an impossibility.APP
- What is an SQL relation?SQL
- 淺談visibility
- WPF筆記10——Visibility.Hidden和Visibility.Collapsed筆記
- read by other session等待事件Session事件
- Python class中的otherPython
- Page Visibility API 教程API
- read by other session 等待事件分析Session事件
- How to draw a simple relation graph in PythonPython
- CSS3 backface-visibilityCSSS3
- 重學 JavaScript API - Page Visibility APIJavaScriptAPI
- [ABC126D] Even Relation 題解
- display:none和visibility:hidden的區別None
- display: none與visibility: hidden的區別None
- 投稿004期 | CSS中用 opacity、visibility、dCSS
- 使用 content-visibility 優化渲染效能優化
- 單詞分類記憶_雜物(other things)
- MySQL資料庫出現 Ignoring query to other databaseMySql資料庫Database
- Flutter GridView 中使用Offstage 或者 Visibility 無效FlutterView
- Oracle 19c Concepts(04):Partitions, Views, and Other Schema ObjectsOracleViewObject
- 【TUNE_ORACLE】等待事件之IO等待“read by other session”Oracle事件Session
- Laravel 根據 relation sum 結果排序的小技巧Laravel排序
- 論文閱讀:A neuralized feature engineering method for entity relation extractionZed
- 元素的隱藏和顯示(display ,visibility ,overflow)
- 說說display:none和visibility:hidden的區別None
- presence_of_element_located對比visibility_of_element_located
- 《REBEL Relation Extraction By End-to-end Language generation》閱讀筆記筆記
- 【論文閱讀筆記】An Improved Neural Baseline for Temporal Relation Extraction筆記
- 在Java SE下測試CDI Bean和持久層 - relationJavaBean
- Map
- CSS魔法堂:display:none與visibility:hidden的恩怨情仇CSSNone
- 【Flutter 元件集錄】Visibility| 8月更文挑戰Flutter元件
- MapReduce關於key的定義、hashCode()、equals(Object obj)、compareTo(CustomCombineKey other)Object
- source map
- JavaScript map()JavaScript
- Map集合
- 求救Beego大神們,Beego orm 怎麼限制Relation裡返回的Variable?GoORM
- c++ map和unordered_map比較C++