From 706a308806a066017c63024c454bb02953c9822c Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 3 Oct 2008 07:33:10 +0000 Subject: Add relation fork support to pg_relation_size() function. You can now pass name of a fork ('main' or 'fsm', at the moment) to pg_relation_size() to get the size of a specific fork. Defaults to 'main', if none given. While we're at it, modify pg_relation_size to take a regclass as argument, instead of separate variants taking oid and name. This change is transparent to typical use where the table name is passed as a string literal, like pg_relation_size('table'), but will break queries like pg_relation_size(namecol), where namecol is of type name. text-type input still works, and using a non-schema-qualified table name is not very reliable anyway, so this is unlikely to break anyone's queries in practice. --- doc/src/sgml/func.sgml | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 05f0aabddd0..31ef6dc864d 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,4 +1,4 @@ - + Functions and Operators @@ -12417,7 +12417,7 @@ postgres=# select * from pg_xlogfile_name_offset(pg_stop_backup()); - pg_column_size(any) + pg_column_size(any) int Number of bytes used to store a particular value (possibly compressed) @@ -12437,19 +12437,22 @@ postgres=# select * from pg_xlogfile_name_offset(pg_stop_backup()); - pg_relation_size(oid) + pg_relation_size(relation regclass, fork text) bigint - Disk space used by the table or index with the specified OID + + Disk space used by the specified fork, 'main' or + 'fsm', of a table or index with the specified OID + or name. The table name can be qualified with a schema name + - pg_relation_size(text) + pg_relation_size(relation regclass) bigint - Disk space used by the table or index with the specified name. - The table name can be qualified with a schema name + Shorthand for pg_relation_size(..., 'main') @@ -12475,21 +12478,11 @@ postgres=# select * from pg_xlogfile_name_offset(pg_stop_backup()); - pg_total_relation_size(oid) - - bigint - - Total disk space used by the table with the specified OID, - including indexes and toasted data - - - - - pg_total_relation_size(text) + pg_total_relation_size(regclass) bigint - Total disk space used by the table with the specified name, + Total disk space used by the table with the specified OID or name, including indexes and toasted data. The table name can be qualified with a schema name @@ -12511,7 +12504,12 @@ postgres=# select * from pg_xlogfile_name_offset(pg_stop_backup()); pg_relation_size accepts the OID or name of a table, index or - toast table, and returns the size in bytes. + toast table, and returns the size in bytes. Specifying + 'main' or leaving out the second argument returns the + size of the main data fork of the relation. Specifying + 'fsm' returns the size of the + Free Space Map (see ) associated with the + relation. -- cgit v1.2.3