From d6df2c9a7c8e432aeacf884ebc883bc9d1f494bb Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 2 Feb 2016 17:15:14 -0600 Subject: [PATCH] Add Get The Size of A Database as a postgres til --- README.md | 1 + postgres/get-the-size-of-a-database.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 postgres/get-the-size-of-a-database.md diff --git a/README.md b/README.md index 922c3a9..31f2f2a 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ _319 TILs and counting..._ - [Fizzbuzz With Common Table Expressions](postgres/fizzbuzz-with-common-table-expressions.md) - [Generate A UUID](postgres/generate-a-uuid.md) - [Generate Series Of Numbers](postgres/generate-series-of-numbers.md) +- [Get The Size Of A Database](postgres/get-the-size-of-a-database.md) - [Getting A Slice Of An Array](postgres/getting-a-slice-of-an-array.md) - [Insert Just The Defaults](postgres/insert-just-the-defaults.md) - [Integers In Postgres](postgres/integers-in-postgres.md) diff --git a/postgres/get-the-size-of-a-database.md b/postgres/get-the-size-of-a-database.md new file mode 100644 index 0000000..897c73c --- /dev/null +++ b/postgres/get-the-size-of-a-database.md @@ -0,0 +1,16 @@ +# Get The Size Of A Database + +If you have connect access to a database, you can use the +`pg_database_size()` function to get the size of a database in bytes. + +```sql +> select pg_database_size('hr_hotels'); + pg_database_size +------------------ + 8249516 +``` + +Just give it the name of the database and it will tell you how much disk +space that database is taking up. + +Checkout [the Postgres docs](http://www.postgresql.org/docs/current/static/functions-admin.html) for more details.