Search code examples
databasepostgresqldiskspace

Postgresql find total disk space used by a database


I have more than 50 databases hosted in my postgresql server. I need to move some of them on another host, to free-up some disk space,but how can I measure the disk-space used by each database on my volume?

Is there any function exists to get the information that I want?


Solution

  • SELECT pg_database_size('geekdb')
    

    or

    SELECT pg_size_pretty(pg_database_size('geekdb'))
    

    http://www.thegeekstuff.com/2009/05/15-advanced-postgresql-commands-with-examples/