Postgres tip of the day – show size of all databases

Here is a handy little query to show the size of all the databases on a particular postgres server:

SELECT pg_database.datname,  
  pg_size_pretty(pg_database_size(pg_database.datname)) AS size  
FROM pg_database;  
  
   datname    |  size  
--------------+---------  
 template1    | 6369 kB  
 template0    | 6361 kB  
 postgres     | 6589 kB  
 foo          | 55 MB  
 bar          | 5129 MB  
 foobar       | 85 GB  
(6 rows)  

Join 165 other subscribers

archives

  • 2024 (10)
  • 2023 (8)
  • 2022 (15)
  • 2021 (19)
  • 2020 (1)
  • 2019 (1)
  • 2018 (2)
  • 2017 (1)
  • 2016 (2)
  • 2015 (5)
  • 2014 (5)
  • 2013 (2)
  • 2011 (7)
  • 2010 (10)
  • 2009 (50)
  • 2008 (28)
  • 2007 (31)
  • 2006 (8)

Category