summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/pgfreespacemap.html
blob: 72483cc6d387f9d5a0ecc759d0fa4a4b3a257dd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.29. pg_freespacemap</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="pgcrypto.html" title="F.28. pgcrypto" /><link rel="next" href="pgprewarm.html" title="F.30. pg_prewarm" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.29. pg_freespacemap</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgcrypto.html" title="F.28. pgcrypto">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="pgprewarm.html" title="F.30. pg_prewarm">Next</a></td></tr></table><hr /></div><div class="sect1" id="PGFREESPACEMAP"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.29. pg_freespacemap</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="pgfreespacemap.html#id-1.11.7.38.5">F.29.1. Functions</a></span></dt><dt><span class="sect2"><a href="pgfreespacemap.html#id-1.11.7.38.6">F.29.2. Sample Output</a></span></dt><dt><span class="sect2"><a href="pgfreespacemap.html#id-1.11.7.38.7">F.29.3. Author</a></span></dt></dl></div><a id="id-1.11.7.38.2" class="indexterm"></a><p>
  The <code class="filename">pg_freespacemap</code> module provides a means for examining the
  <a class="link" href="storage-fsm.html" title="73.3. Free Space Map">free space map</a> (<acronym class="acronym">FSM</acronym>).
  It provides a function called <code class="function">pg_freespace</code>, or two
  overloaded functions, to be precise. The functions show the value recorded in
  the free space map for a given page, or for all pages in the relation.
 </p><p>
  By default use is restricted to superusers and roles with privileges of the
  <code class="literal">pg_stat_scan_tables</code> role. Access may be granted to others
  using <code class="command">GRANT</code>.
 </p><div class="sect2" id="id-1.11.7.38.5"><div class="titlepage"><div><div><h3 class="title">F.29.1. Functions</h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">
     <code class="function">pg_freespace(rel regclass IN, blkno bigint IN) returns int2</code>
     <a id="id-1.11.7.38.5.2.1.1.2" class="indexterm"></a>
    </span></dt><dd><p>
      Returns the amount of free space on the page of the relation, specified
      by <code class="literal">blkno</code>, according to the <acronym class="acronym">FSM</acronym>.
     </p></dd><dt><span class="term">
     <code class="function">pg_freespace(rel regclass IN, blkno OUT bigint, avail OUT int2)</code>
    </span></dt><dd><p>
      Displays the amount of free space on each page of the relation,
      according to the <acronym class="acronym">FSM</acronym>. A set of
      <code class="literal">(blkno bigint, avail int2)</code>
      tuples is returned, one tuple for each page in the relation.
     </p></dd></dl></div><p>
   The values stored in the free space map are not exact. They're rounded
   to precision of 1/256th of <code class="symbol">BLCKSZ</code> (32 bytes with default <code class="symbol">BLCKSZ</code>), and
   they're not kept fully up-to-date as tuples are inserted and updated.
  </p><p>
   For indexes, what is tracked is entirely-unused pages, rather than free
   space within pages.  Therefore, the values are not meaningful, just
   whether a page is full or empty.
  </p></div><div class="sect2" id="id-1.11.7.38.6"><div class="titlepage"><div><div><h3 class="title">F.29.2. Sample Output</h3></div></div></div><pre class="screen">
postgres=# SELECT * FROM pg_freespace('foo');
 blkno | avail
-------+-------
     0 |     0
     1 |     0
     2 |     0
     3 |    32
     4 |   704
     5 |   704
     6 |   704
     7 |  1216
     8 |   704
     9 |   704
    10 |   704
    11 |   704
    12 |   704
    13 |   704
    14 |   704
    15 |   704
    16 |   704
    17 |   704
    18 |   704
    19 |  3648
(20 rows)

postgres=# SELECT * FROM pg_freespace('foo', 7);
 pg_freespace
--------------
         1216
(1 row)
</pre></div><div class="sect2" id="id-1.11.7.38.7"><div class="titlepage"><div><div><h3 class="title">F.29.3. Author</h3></div></div></div><p>
   Original version by Mark Kirkwood <code class="email">&lt;<a class="email" href="mailto:markir@paradise.net.nz">markir@paradise.net.nz</a>&gt;</code>.
   Rewritten in version 8.4 to suit new <acronym class="acronym">FSM</acronym> implementation
   by Heikki Linnakangas <code class="email">&lt;<a class="email" href="mailto:heikki@enterprisedb.com">heikki@enterprisedb.com</a>&gt;</code>
  </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pgcrypto.html" title="F.28. pgcrypto">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pgprewarm.html" title="F.30. pg_prewarm">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.28. pgcrypto </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.5 Documentation">Home</a></td><td width="40%" align="right" valign="top"> F.30. pg_prewarm</td></tr></table></div></body></html>