aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/diskusage.sgml23
-rw-r--r--doc/src/sgml/func.sgml111
2 files changed, 121 insertions, 13 deletions
diff --git a/doc/src/sgml/diskusage.sgml b/doc/src/sgml/diskusage.sgml
index 385fd93ef11..634b9ab6988 100644
--- a/doc/src/sgml/diskusage.sgml
+++ b/doc/src/sgml/diskusage.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/diskusage.sgml,v 1.14 2005/01/10 00:04:38 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/diskusage.sgml,v 1.15 2005/07/29 14:46:56 momjian Exp $
-->
<chapter id="diskusage">
@@ -31,11 +31,16 @@ $PostgreSQL: pgsql/doc/src/sgml/diskusage.sgml,v 1.14 2005/01/10 00:04:38 tgl Ex
</para>
<para>
- You can monitor disk space from three places: from
- <application>psql</> using <command>VACUUM</> information, from
- <application>psql</> using the tools in <filename>contrib/dbsize</>, and from
- the command line using the tools in <filename>contrib/oid2name</>. Using
- <application>psql</> on a recently vacuumed or analyzed database,
+ You can monitor disk space from three ways: using
+ SQL functions listed in <xref linkend="functions-admin-dbsize">,
+ using <command>VACUUM</> information, and from the command line
+ using the tools in <filename>contrib/oid2name</>. The SQL functions
+ are the easiest to use and report information about tables, tables with
+ indexes and long value storage (TOAST), databases, and tablespaces.
+ </para>
+
+ <para>
+ Using <application>psql</> on a recently vacuumed or analyzed database,
you can issue queries to see the disk usage of any table:
<programlisting>
SELECT relfilenode, relpages FROM pg_class WHERE relname = 'customer';
@@ -102,12 +107,6 @@ SELECT relname, relpages FROM pg_class ORDER BY relpages DESC;
</para>
<para>
- <filename>contrib/dbsize</> loads functions into your database that allow
- you to find the size of a table or database from inside
- <application>psql</> without the need for <command>VACUUM</> or <command>ANALYZE</>.
- </para>
-
- <para>
You can also use <filename>contrib/oid2name</> to show disk usage. See
<filename>README.oid2name</> in that directory for examples. It includes a script that
shows disk usage for each database.
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 0fdcb1d0df1..5c6092e4245 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.272 2005/07/26 16:38:25 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.273 2005/07/29 14:46:56 momjian Exp $
PostgreSQL documentation
-->
@@ -9161,6 +9161,115 @@ SELECT set_config('log_statement_stats', 'off', false);
For details about proper usage of these functions, see
<xref linkend="backup-online">.
</para>
+
+ <para>
+ The functions shown in <xref
+ linkend="functions-admin-dbsize"> calculate the actual disk space
+ usage of database objects.
+ </para>
+
+ <table id="functions-admin-dbsize">
+ <title>Database Object Size Functions</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>
+ <literal><function>pg_tablespace_size</function>(<parameter>oid</parameter>)</literal>
+ </entry>
+ <entry><type>int8</type></entry>
+ <entry>Calculates the total disk space used by the tablespace with the specified OID</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_tablespace_size</function>(<parameter>name</parameter>)</literal>
+ </entry>
+ <entry><type>int8</type></entry>
+ <entry>Calculates the total disk space used by the tablespace with the specified name</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_database_size</function>(<parameter>oid</parameter>)</literal>
+ </entry>
+ <entry><type>int8</type></entry>
+ <entry>Calculates the total disk space used by the database with the specified OID</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_database_size</function>(<parameter>name</parameter>)</literal>
+ </entry>
+ <entry><type>int8</type></entry>
+ <entry>Calculates the total disk space used by the database with the specified name</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_relation_size</function>(<parameter>oid</parameter>)</literal>
+ </entry>
+ <entry><type>int8</type></entry>
+ <entry>Calculates the disk space used by the table or index with the specified OID</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_relation_size</function>(<parameter>text</parameter>)</literal>
+ </entry>
+ <entry><type>int8</type></entry>
+ <entry>Calculates the disk space used by the index or table with the specified name.
+ The name may be prefixed with a schema name if required</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_complete_relation_size</function>(<parameter>oid</parameter>)</literal>
+ </entry>
+ <entry><type>int8</type></entry>
+ <entry>Calculates the total disk space used by the table with the specified OID,
+ including indexes and toasted data</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_complete_relation_size</function>(<parameter>text</parameter>)</literal>
+ </entry>
+ <entry><type>int8</type></entry>
+ <entry>Calculates the total disk space used by the table with the specified name,
+ including indexes and toasted data. The name may be prefixed with a schema name if
+ required</entry>
+ </row>
+ <row>
+ <entry>
+ <literal><function>pg_size_pretty</function>(<parameter>int8</parameter>)</literal>
+ </entry>
+ <entry><type>text</type></entry>
+ <entry>Formats the size value (in bytes) into a human readable format with size units </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ <function>pg_tablespace_size</> and <function>pg_database_size</> accept an
+ oid or name of a tablespace or database, and return the disk space usage of the specified object.
+ </para>
+
+ <indexterm zone="functions-admin">
+ <primary>pg_relation_size</primary>
+ </indexterm>
+ <para>
+ <function>pg_relation_size</> accepts the oid or name of a table, index or
+ toast table, and returns the size in bytes.
+ </para>
+ <para>
+ <function>pg_complete_relation_size</> accepts the oid or name of a table or
+ toast table, and returns the size in bytes of the data and all associated
+ indexes and toast tables.
+ </para>
+ <para>
+ <function>pg_size_pretty</> can be used to format the size of the
+ database objects in a human readable way, using kB, MB, GB or TB as appropriate.
+ </para>
+
</sect1>
</chapter>