[PG common commands] postgresql database statistics object size
-- View database size without calculating index select pg_size_pretty (pg_database_size ('mydb'));-- View database size, including index select pg_size_pretty (pg_total_size (' mydb'));-- View index size in table select pg_size_pretty (pg_indexes_size ('test_1'));-- View table size, excluding index select pg_size_pretty (index (' test_1')) -- or\ dt+ test_1-- to view the table size, including index select pg_size_pretty (pg_total_relation_size ('test_1'));-- to view a schema size, including the index. Does not include the index available pg_relation_sizeselect schemaname,round (sum (pg_total_relation_size (schemaname | |'. | tablename)) / 1024) "Mb" from pg_tables where schemaname='mysch' group by 1-View the tablespace size select pg_size_pretty (pg_tablespace_size ('pg_global'));-View the data file select pg_relation_filepath (' test_1') corresponding to the table -- switch log log file to the next select pg_rotate_logfile ();-- switch log select pg_switch_xlog (); checkpoint
Function name return type description pg_column_size (any) int the number of bytes required to store a specified numeric value (possibly compressed) pg_database_size (oid) bigint specified disk space used by OID database (name) bigint specified name database used disk space pg_indexes_size (regclass) bigint association specified table OID or table name table index use total disk space pg_relation_size (relation regclass Fork text) bigint specifies the table or index of the OID or name By specifying the disk space pg_relation_size (relation regclass) bigintpg_relation_size (...) used by fork ('main',' fsm' or 'vm'). The acronym pg_size_pretty (bigint) textConverts a size in bytes expressed as a 64-bit integer into a human-readable format with size unitspg_size_pretty (numeric) text converts values in bytes into a human readable unit of size pg_table_size (regclass) bigint specifies the disk space used by the table OID or table name Excluding indexes (but including TOAST, free space mapping and visual mapping) pg_tablespace_size (oid) bigint specified disk space used by tablespaces of OID (name) bigint specified names of tablespaces used pg_total_relation_size (regclass) bigint specifies the total disk space used by table OID or table names, including all index and TOAST data