2 F.27. pg_freespacemap — examine the free space map #
8 The pg_freespacemap module provides a means for examining the free
9 space map (FSM). It provides a function called pg_freespace, or two
10 overloaded functions, to be precise. The functions show the value
11 recorded in the free space map for a given page, or for all pages in
14 By default use is restricted to superusers and roles with privileges of
15 the pg_stat_scan_tables role. Access may be granted to others using
20 pg_freespace(rel regclass IN, blkno bigint IN) returns int2
21 Returns the amount of free space on the page of the relation,
22 specified by blkno, according to the FSM.
24 pg_freespace(rel regclass IN, blkno OUT bigint, avail OUT int2)
25 Displays the amount of free space on each page of the relation,
26 according to the FSM. A set of (blkno bigint, avail int2) tuples
27 is returned, one tuple for each page in the relation.
29 The values stored in the free space map are not exact. They're rounded
30 to precision of 1/256th of BLCKSZ (32 bytes with default BLCKSZ), and
31 they're not kept fully up-to-date as tuples are inserted and updated.
33 For indexes, what is tracked is entirely-unused pages, rather than free
34 space within pages. Therefore, the values are not meaningful, just
35 whether a page is in-use or empty.
37 F.27.2. Sample Output #
39 postgres=# SELECT * FROM pg_freespace('foo');
64 postgres=# SELECT * FROM pg_freespace('foo', 7);
72 Original version by Mark Kirkwood <markir@paradise.net.nz>. Rewritten
73 in version 8.4 to suit new FSM implementation by Heikki Linnakangas
74 <heikki@enterprisedb.com>