Skip to content

Commit d6df2c9

Browse files
committed
Add Get The Size of A Database as a postgres til
1 parent 07c7b53 commit d6df2c9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ _319 TILs and counting..._
151151
- [Fizzbuzz With Common Table Expressions](postgres/fizzbuzz-with-common-table-expressions.md)
152152
- [Generate A UUID](postgres/generate-a-uuid.md)
153153
- [Generate Series Of Numbers](postgres/generate-series-of-numbers.md)
154+
- [Get The Size Of A Database](postgres/get-the-size-of-a-database.md)
154155
- [Getting A Slice Of An Array](postgres/getting-a-slice-of-an-array.md)
155156
- [Insert Just The Defaults](postgres/insert-just-the-defaults.md)
156157
- [Integers In Postgres](postgres/integers-in-postgres.md)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Get The Size Of A Database
2+
3+
If you have connect access to a database, you can use the
4+
`pg_database_size()` function to get the size of a database in bytes.
5+
6+
```sql
7+
> select pg_database_size('hr_hotels');
8+
pg_database_size
9+
------------------
10+
8249516
11+
```
12+
13+
Just give it the name of the database and it will tell you how much disk
14+
space that database is taking up.
15+
16+
Checkout [the Postgres docs](http://www.postgresql.org/docs/current/static/functions-admin.html) for more details.

0 commit comments

Comments
 (0)