70.3. Free Space Map

|   70.3. Free Space Map   |                  |                                     |                  |                        |
|:------------------------:|------------------|-------------------------------------|------------------|------------------------|
|[Prev](storage-toast.html)|[Up](storage.html)|Chapter 70. Database Physical Storage|[Home](index.html)| [Next](storage-vm.html)|

---

## 70.3. Free Space Map

[]()[]()

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.

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.

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 levelFSM 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.
The [pg\_freespacemap](pgfreespacemap.html) module
can be used to examine the information stored in free space maps.

---

|[Prev](storage-toast.html)|[Up](storage.html)| [Next](storage-vm.html)|
|:-------------------------|:----------------:|-----------------------:|
|       70.2. TOAST        |[Home](index.html)|  70.4. Visibility Map  |

 // \<![CDATA[ \<-- For SVG support if ('WebSocket' in window) { (function() { function refreshCSS() { var sheets = [].slice.call(document.getElementsByTagName("link")); var head = document.getElementsByTagName("head")[0]; for (var i = 0; i \< sheets.length; ++i) { var elem = sheets[i]; head.removeChild(elem); var rel = elem.rel; if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") { var url = elem.href.replace(/(&|\\?)\_cacheOverride=\\d+/, ''); elem.href = url + (url.indexOf('?') \>= 0 ? '&' : '?') + '\_cacheOverride=' + (new Date().valueOf()); } head.appendChild(elem); } } var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; var address = protocol + window.location.host + window.location.pathname + '/ws'; var socket = new WebSocket(address); socket.onmessage = function(msg) { if (msg.data == 'reload') window.location.reload(); else if (msg.data == 'refreshcss') refreshCSS(); }; console.log('Live reload enabled.'); })(); } // ]]\>