? src/backend/utils/adt/dbsize.c Index: doc/src/sgml/func.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/func.sgml,v retrieving revision 1.260 diff -c -r1.260 func.sgml *** doc/src/sgml/func.sgml 26 Jun 2005 22:05:35 -0000 1.260 --- doc/src/sgml/func.sgml 27 Jun 2005 14:41:53 -0000 *************** *** 9021,9029 **** processes on the server with ps. - - pg_start_backup - pg_stop_backup --- 9021,9026 ---- *************** *** 9090,9095 **** --- 9087,9179 ---- 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 total disk space of the tablespace with the specified OID + + + + pg_tablespace_size(name) + + int8 + Calculates total disk space of the tablespace with the specified name + + + + pg_database_size(oid) + + int8 + Calculates total disk space of the database with the specified OID + + + + pg_database_size(name) + + int8 + Calculates total disk space of the database with the specified name + + + + pg_relation_size(oid) + + int8 + Calculates total disk space of the relation with the specified OID + + + + pg_relation_size(text) + + int8 + Calculates total disk space of the relation with the specified name. The name may be prefixed with a schema name if required + + + + pg_size_pretty(size_int8) + + text + Formats the size in 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. To calculate the total disk space usage of a table including all + its indexes and toast tables, each component should be added together. + + + 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. + + Index: src/backend/utils/adt/Makefile =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/Makefile,v retrieving revision 1.57 diff -c -r1.57 Makefile *** src/backend/utils/adt/Makefile 1 Apr 2004 21:28:45 -0000 1.57 --- src/backend/utils/adt/Makefile 27 Jun 2005 10:29:49 -0000 *************** *** 24,30 **** tid.o timestamp.o varbit.o varchar.o varlena.o version.o xid.o \ network.o mac.o inet_net_ntop.o inet_net_pton.o \ ri_triggers.o pg_lzcompress.o pg_locale.o formatting.o \ ! ascii.o quote.o pgstatfuncs.o encode.o like.o: like.c like_match.c --- 24,30 ---- tid.o timestamp.o varbit.o varchar.o varlena.o version.o xid.o \ network.o mac.o inet_net_ntop.o inet_net_pton.o \ ri_triggers.o pg_lzcompress.o pg_locale.o formatting.o \ ! ascii.o quote.o pgstatfuncs.o encode.o dbsize.o like.o: like.c like_match.c Index: src/include/catalog/pg_proc.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/catalog/pg_proc.h,v retrieving revision 1.371 diff -c -r1.371 pg_proc.h *** src/include/catalog/pg_proc.h 26 Jun 2005 03:04:01 -0000 1.371 --- src/include/catalog/pg_proc.h 27 Jun 2005 14:16:21 -0000 *************** *** 3031,3036 **** --- 3031,3052 ---- DESCR("Finish taking an online backup"); + DATA(insert OID = 1248 ( pg_tablespace_size PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_tablespace_size_oid - _null_ )); + DESCR("Calculate total disk space usage for tablespace"); + DATA(insert OID = 1250 ( pg_tablespace_size PGNSP PGUID 12 f f t f v 1 20 "19" _null_ _null_ _null_ pg_tablespace_size_name - _null_ )); + DESCR("Calculate total disk space usage for tablespace"); + DATA(insert OID = 1269 ( pg_database_size PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_database_size_oid - _null_ )); + DESCR("Calculate total disk space usage for database"); + DATA(insert OID = 1295 ( pg_database_size PGNSP PGUID 12 f f t f v 1 20 "19" _null_ _null_ _null_ pg_database_size_name - _null_ )); + DESCR("Calculate total disk space usage for database"); + DATA(insert OID = 2168 ( pg_relation_size PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_relation_size_oid - _null_ )); + DESCR("Calculate total disk space usage for relation"); + DATA(insert OID = 2285 ( pg_relation_size PGNSP PGUID 12 f f t f v 1 20 "25" _null_ _null_ _null_ pg_relation_size_name - _null_ )); + DESCR("Calculate total disk space usage for relation"); + DATA(insert OID = 2286 ( pg_size_pretty PGNSP PGUID 12 f f t f v 1 25 "20" _null_ _null_ _null_ pg_size_pretty - _null_ )); + DESCR("Convert a long int to a human readable text using size units"); + + /* Aggregates (moved here from pg_aggregate for 7.3) */ DATA(insert OID = 2100 ( avg PGNSP PGUID 12 t f f f i 1 1700 "20" _null_ _null_ _null_ aggregate_dummy - _null_ )); Index: src/include/utils/builtins.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/utils/builtins.h,v retrieving revision 1.258 diff -c -r1.258 builtins.h *** src/include/utils/builtins.h 17 Jun 2005 22:32:50 -0000 1.258 --- src/include/utils/builtins.h 27 Jun 2005 12:13:08 -0000 *************** *** 357,362 **** --- 357,371 ---- extern Datum float84gt(PG_FUNCTION_ARGS); extern Datum float84ge(PG_FUNCTION_ARGS); + /* dbsize.c */ + extern Datum pg_tablespace_size_oid(PG_FUNCTION_ARGS); + extern Datum pg_tablespace_size_name(PG_FUNCTION_ARGS); + extern Datum pg_database_size_oid(PG_FUNCTION_ARGS); + extern Datum pg_database_size_name(PG_FUNCTION_ARGS); + extern Datum pg_relation_size_oid(PG_FUNCTION_ARGS); + extern Datum pg_relation_size_name(PG_FUNCTION_ARGS); + extern Datum pg_size_pretty(PG_FUNCTION_ARGS); + /* misc.c */ extern Datum nullvalue(PG_FUNCTION_ARGS); extern Datum nonnullvalue(PG_FUNCTION_ARGS);