Getting the database and database object size
Managing disk space and assigning table spaces to tables as well as databases requires knowledge about the size of the database and database objects. When performing a logical restore, one could get information about the progress by comparing the original database size and the one which is being restored. Finally, the database object size often gives information about bloats.
Getting ready
Getting the database size is an important administration task because it allows the administrator to put migration plans and handle common maintenance issues, such as out-of-space and bloat issues.
How to do it…
To get the database size, one can get the oid
database from the pg_database
table and run the Linux command, du -h /data_directory/base/oid
, where data_directory
is the database cluster folder specified in the postgresql.conf
configuration file. In this regard, a quick look at the PostgreSQL cluster folders is quite useful. For example, to determine the...