1- <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.496 2010/01/15 09:18:58 heikki Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.497 2010/01/19 05:50:18 tgl Exp $ -->
22
33 <chapter id="functions">
44 <title>Functions and Operators</title>
@@ -13173,12 +13173,12 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1317313173 </entry>
1317413174 <entry><type>text</type></entry>
1317513175 <entry>Get last transaction log location received and synced to disk during
13176- streaming recovery. If streaming recovery is still in progress
13177- this will increase monotonically. If streaming recovery has completed
13178- then this value will remain static at the value of the last WAL record
13179- received and synced to disk during that recovery. When the server has
13180- been started without a streaming recovery then the return value will be
13181- InvalidXLogRecPtr (0/0).
13176+ streaming recovery. If streaming recovery is still in progress
13177+ this will increase monotonically. If streaming recovery has completed
13178+ then this value will remain static at the value of the last WAL record
13179+ received and synced to disk during that recovery. When the server has
13180+ been started without a streaming recovery then the return value will be
13181+ InvalidXLogRecPtr (0/0).
1318213182 </entry>
1318313183 </row>
1318413184 <row>
@@ -13187,11 +13187,11 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1318713187 </entry>
1318813188 <entry><type>text</type></entry>
1318913189 <entry>Get last transaction log location replayed during recovery.
13190- If recovery is still in progress this will increase monotonically.
13191- If recovery has completed then this value will remain static at
13192- the value of the last WAL record applied during that recovery.
13193- When the server has been started normally without a recovery
13194- then the return value will be InvalidXLogRecPtr (0/0).
13190+ If recovery is still in progress this will increase monotonically.
13191+ If recovery has completed then this value will remain static at
13192+ the value of the last WAL record applied during that recovery.
13193+ When the server has been started normally without a recovery
13194+ then the return value will be InvalidXLogRecPtr (0/0).
1319513195 </entry>
1319613196 </row>
1319713197 </tbody>
@@ -13207,19 +13207,25 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1320713207 <primary>pg_column_size</primary>
1320813208 </indexterm>
1320913209 <indexterm>
13210- <primary>pg_database_size </primary>
13210+ <primary>pg_total_relation_size </primary>
1321113211 </indexterm>
1321213212 <indexterm>
13213- <primary>pg_relation_size </primary>
13213+ <primary>pg_table_size </primary>
1321413214 </indexterm>
1321513215 <indexterm>
13216- <primary>pg_size_pretty</primary>
13216+ <primary>pg_indexes_size</primary>
13217+ </indexterm>
13218+ <indexterm>
13219+ <primary>pg_database_size</primary>
1321713220 </indexterm>
1321813221 <indexterm>
1321913222 <primary>pg_tablespace_size</primary>
1322013223 </indexterm>
1322113224 <indexterm>
13222- <primary>pg_total_relation_size</primary>
13225+ <primary>pg_relation_size</primary>
13226+ </indexterm>
13227+ <indexterm>
13228+ <primary>pg_size_pretty</primary>
1322313229 </indexterm>
1322413230
1322513231 <table id="functions-admin-dbsize">
@@ -13238,44 +13244,48 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1323813244 </row>
1323913245 <row>
1324013246 <entry>
13241- <literal><function>pg_database_size </function>(<type>oid </type>)</literal>
13247+ <literal><function>pg_total_relation_size </function>(<type>regclass </type>)</literal>
1324213248 </entry>
1324313249 <entry><type>bigint</type></entry>
13244- <entry>Disk space used by the database with the specified OID</entry>
13250+ <entry>
13251+ Total disk space used by the table with the specified OID or name,
13252+ including all indexes and <acronym>TOAST</> data
13253+ </entry>
1324513254 </row>
1324613255 <row>
1324713256 <entry>
13248- <literal><function>pg_database_size </function>(<type>name </type>)</literal>
13257+ <literal><function>pg_table_size </function>(<type>regclass </type>)</literal>
1324913258 </entry>
1325013259 <entry><type>bigint</type></entry>
13251- <entry>Disk space used by the database with the specified name</entry>
13260+ <entry>
13261+ Disk space used by the table with the specified OID or name,
13262+ excluding indexes (but including TOAST, free space map, and visibility
13263+ map)
13264+ </entry>
1325213265 </row>
1325313266 <row>
1325413267 <entry>
13255- <literal><function>pg_relation_size </function>(<parameter>relation</parameter> < type>regclass</type>, <parameter>fork</parameter> <type>text </type>)</literal>
13268+ <literal><function>pg_indexes_size </function>(<type>regclass</type>)</literal>
1325613269 </entry>
1325713270 <entry><type>bigint</type></entry>
1325813271 <entry>
13259- Disk space used by the specified fork (<literal>'main'</literal>,
13260- <literal>'fsm'</literal> or <literal>'vm'</>)
13261- of the table or index with the specified OID or name
13272+ Total disk space used by indexes attached to the table with the
13273+ specified OID or name
1326213274 </entry>
1326313275 </row>
1326413276 <row>
1326513277 <entry>
13266- <literal><function>pg_relation_size </function>(<parameter>relation</parameter> < type>regclass </type>)</literal>
13278+ <literal><function>pg_database_size </function>(<type>oid </type>)</literal>
1326713279 </entry>
1326813280 <entry><type>bigint</type></entry>
13269- <entry>
13270- Shorthand for <literal>pg_relation_size(..., 'main')</literal>
13271- </entry>
13281+ <entry>Disk space used by the database with the specified OID</entry>
1327213282 </row>
1327313283 <row>
1327413284 <entry>
13275- <literal><function>pg_size_pretty </function>(<type>bigint </type>)</literal>
13285+ <literal><function>pg_database_size </function>(<type>name </type>)</literal>
1327613286 </entry>
13277- <entry><type>text </type></entry>
13278- <entry>Converts a size in bytes into a human-readable format with size units </entry>
13287+ <entry><type>bigint </type></entry>
13288+ <entry>Disk space used by the database with the specified name </entry>
1327913289 </row>
1328013290 <row>
1328113291 <entry>
@@ -13293,14 +13303,31 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1329313303 </row>
1329413304 <row>
1329513305 <entry>
13296- <literal><function>pg_total_relation_size </function>(<type>regclass</type>)</literal>
13306+ <literal><function>pg_relation_size </function>(<parameter>relation</parameter> < type>regclass</type>, <parameter>fork</parameter> <type>text </type>)</literal>
1329713307 </entry>
1329813308 <entry><type>bigint</type></entry>
1329913309 <entry>
13300- Total disk space used by the table with the specified OID or name,
13301- including indexes and <acronym>TOAST</> data
13310+ Disk space used by the specified fork (<literal>'main'</literal>,
13311+ <literal>'fsm'</literal> or <literal>'vm'</>)
13312+ of the table or index with the specified OID or name
1330213313 </entry>
1330313314 </row>
13315+ <row>
13316+ <entry>
13317+ <literal><function>pg_relation_size</function>(<parameter>relation</parameter> <type>regclass</type>)</literal>
13318+ </entry>
13319+ <entry><type>bigint</type></entry>
13320+ <entry>
13321+ Shorthand for <literal>pg_relation_size(..., 'main')</literal>
13322+ </entry>
13323+ </row>
13324+ <row>
13325+ <entry>
13326+ <literal><function>pg_size_pretty</function>(<type>bigint</type>)</literal>
13327+ </entry>
13328+ <entry><type>text</type></entry>
13329+ <entry>Converts a size in bytes into a human-readable format with size units</entry>
13330+ </row>
1330413331 </tbody>
1330513332 </tgroup>
1330613333 </table>
@@ -13310,6 +13337,26 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1331013337 data value.
1331113338 </para>
1331213339
13340+ <para>
13341+ <function>pg_total_relation_size</> accepts the OID or name of a
13342+ table or toast table, and returns the total on-disk space used for
13343+ that table, including all associated indexes. This function is
13344+ equivalent to <function>pg_table_size</function>
13345+ <literal>+</> <function>pg_indexes_size</function>.
13346+ </para>
13347+
13348+ <para>
13349+ <function>pg_table_size</> accepts the OID or name of a table and
13350+ returns the disk space needed for that table, exclusive of indexes.
13351+ (TOAST space, free space map, and visibility map are included.)
13352+ </para>
13353+
13354+ <para>
13355+ <function>pg_indexes_size</> accepts the OID or name of a table and
13356+ returns the total disk space used by all the indexes attached to that
13357+ table.
13358+ </para>
13359+
1331313360 <para>
1331413361 <function>pg_database_size</function> and <function>pg_tablespace_size</>
1331513362 accept the OID or name of a database or tablespace, and return the total
@@ -13318,14 +13365,17 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1331813365
1331913366 <para>
1332013367 <function>pg_relation_size</> accepts the OID or name of a table, index or
13321- toast table, and returns the size in bytes. Specifying
13368+ toast table, and returns the on-disk size in bytes. Specifying
1332213369 <literal>'main'</literal> or leaving out the second argument returns the
1332313370 size of the main data fork of the relation. Specifying
1332413371 <literal>'fsm'</literal> returns the size of the
1332513372 Free Space Map (see <xref linkend="storage-fsm">) associated with the
1332613373 relation. Specifying <literal>'vm'</literal> returns the size of the
1332713374 Visibility Map (see <xref linkend="storage-vm">) associated with the
13328- relation.
13375+ relation. Note that this function shows the size of only one fork;
13376+ for most purposes it is more convenient to use the higher-level
13377+ functions <function>pg_total_relation_size</> or
13378+ <function>pg_table_size</>.
1332913379 </para>
1333013380
1333113381 <para>
@@ -13334,12 +13384,6 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
1333413384 appropriate.
1333513385 </para>
1333613386
13337- <para>
13338- <function>pg_total_relation_size</> accepts the OID or name of a
13339- table or toast table, and returns the size in bytes of the data
13340- and all associated indexes and toast tables.
13341- </para>
13342-
1334313387 <para>
1334413388 The functions shown in <xref
1334513389 linkend="functions-admin-genfile"> provide native access to
0 commit comments