3 <sect1 id=
"pgfreespacemap">
4 <title>pg_freespacemap
</title>
6 <indexterm zone=
"pgfreespacemap">
7 <primary>pg_freespacemap
</primary>
11 The
<filename>pg_freespacemap<
/> module provides a means for examining the
12 free space map (FSM). It provides a function called
13 <function>pg_freespace
</function>, or two overloaded functions, to be
14 precise. The functions show the value recorded in the free space map for
15 a given page, or for all pages in the relation.
19 By default public access is revoked from the functions, just in case
20 there are security issues lurking.
24 <title>Functions
</title>
29 <function>pg_freespace(rel regclass IN, blkno bigint IN) returns int2
</function>
34 Returns the amount of free space on the page of the relation, specified
35 by
<literal>blkno<
/>, according to the FSM.
44 <function>pg_freespace(rel regclass IN, blkno OUT bigint, avail OUT int2)
</function>
49 Displays the the amount of free space on each page of the relation,
50 according to the FSM. A set of
<literal>(blkno bigint, avail int2)<
/>
51 tuples is returned, one tuple for each page in the relation.
58 The values stored in the free space map are not exact. They're rounded
59 to precision of
1/
256th of BLCKSZ (
32 bytes with default BLCKSZ), and
60 they're not kept fully up-to-date as tuples are inserted and updated.
64 For indexes, what is tracked is entirely-unused pages, rather than free
65 space within pages. Therefore, the values are not meaningful, just
66 whether a page is full or empty.
70 NOTE: The interface was changed in version
8.4, to reflect the new FSM
71 implementation introduced in the same version.
76 <title>Sample output
</title>
79 postgres=# SELECT * FROM pg_freespace('foo');
104 postgres=# SELECT * FROM pg_freespace('foo',
7);
114 <title>Author
</title>
117 Original version by Mark Kirkwood
<email>markir@paradise.net.nz
</email>.
118 Rewritten in version
8.4 to suit new FSM implementation by Heikki
119 Linnakangas
<email>heikki@enterprisedb.com
</email>