]> begriffs open source - ai-pg/blob - full-docs/txt/pgfreespacemap.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / pgfreespacemap.txt
1
2 F.27. pg_freespacemap — examine the free space map #
3
4    F.27.1. Functions
5    F.27.2. Sample Output
6    F.27.3. Author
7
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
12    the relation.
13
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
16    GRANT.
17
18 F.27.1. Functions #
19
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.
23
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.
28
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.
32
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.
36
37 F.27.2. Sample Output #
38
39 postgres=# SELECT * FROM pg_freespace('foo');
40  blkno | avail
41 -------+-------
42      0 |     0
43      1 |     0
44      2 |     0
45      3 |    32
46      4 |   704
47      5 |   704
48      6 |   704
49      7 |  1216
50      8 |   704
51      9 |   704
52     10 |   704
53     11 |   704
54     12 |   704
55     13 |   704
56     14 |   704
57     15 |   704
58     16 |   704
59     17 |   704
60     18 |   704
61     19 |  3648
62 (20 rows)
63
64 postgres=# SELECT * FROM pg_freespace('foo', 7);
65  pg_freespace
66 --------------
67          1216
68 (1 row)
69
70 F.27.3. Author #
71
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>