Postgresql find total disk space used by a database

pylover picture pylover · Jan 15, 2013 · Viewed 36.5k times · Source

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?

Answer

Robert Harvey picture Robert Harvey · Jan 15, 2013
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/