From 358a897fa1d7ff49c350f2cb7a0372c0f67dfb88 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 29 Jul 2005 14:47:04 +0000 Subject: Move dbsize functions into the backend. New functions: pg_tablespace_size pg_database_size pg_relation_size pg_complete_relation_size pg_size_pretty Remove /contrib/dbsize. Dave Page --- doc/src/sgml/diskusage.sgml | 23 +++++---- doc/src/sgml/func.sgml | 111 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 121 insertions(+), 13 deletions(-) (limited to 'doc/src') 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 @@ @@ -31,11 +31,16 @@ $PostgreSQL: pgsql/doc/src/sgml/diskusage.sgml,v 1.14 2005/01/10 00:04:38 tgl Ex - You can monitor disk space from three places: from - psql using VACUUM information, from - psql using the tools in contrib/dbsize, and from - the command line using the tools in contrib/oid2name. Using - psql on a recently vacuumed or analyzed database, + You can monitor disk space from three ways: using + SQL functions listed in , + using VACUUM information, and from the command line + using the tools in 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. + + + + Using psql on a recently vacuumed or analyzed database, you can issue queries to see the disk usage of any table: SELECT relfilenode, relpages FROM pg_class WHERE relname = 'customer'; @@ -101,12 +106,6 @@ SELECT relname, relpages FROM pg_class ORDER BY relpages DESC; - - contrib/dbsize loads functions into your database that allow - you to find the size of a table or database from inside - psql without the need for VACUUM or ANALYZE. - - You can also use contrib/oid2name to show disk usage. See README.oid2name in that directory for examples. It includes a script that 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 @@ @@ -9161,6 +9161,115 @@ SELECT set_config('log_statement_stats', 'off', false); For details about proper usage of these functions, see . + + + The functions shown in calculate the actual disk space + usage of database objects. + + + + Database Object Size Functions + + + Name Return Type Description + + + + + + + pg_tablespace_size(oid) + + int8 + Calculates the total disk space used by the tablespace with the specified OID + + + + pg_tablespace_size(name) + + int8 + Calculates the total disk space used by the tablespace with the specified name + + + + pg_database_size(oid) + + int8 + Calculates the total disk space used by the database with the specified OID + + + + pg_database_size(name) + + int8 + Calculates the total disk space used by the database with the specified name + + + + pg_relation_size(oid) + + int8 + Calculates the disk space used by the table or index with the specified OID + + + + pg_relation_size(text) + + int8 + 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 + + + + pg_complete_relation_size(oid) + + int8 + Calculates the total disk space used by the table with the specified OID, + including indexes and toasted data + + + + pg_complete_relation_size(text) + + int8 + 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 + + + + pg_size_pretty(int8) + + text + Formats the size value (in bytes) into a human readable format with size units + + + +
+ + + pg_tablespace_size and pg_database_size accept an + oid or name of a tablespace or database, and return the disk space usage of the specified object. + + + + pg_relation_size + + + pg_relation_size accepts the oid or name of a table, index or + toast table, and returns the size in bytes. + + + 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. + + + 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. + +
-- cgit v1.2.3