From 2293db26488d67fd6957f2015027bfb8bf9bed4c Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 6 May 2016 11:44:19 -0500 Subject: [PATCH] Add List Database Objects With Disk Usage as a postgres til --- README.md | 3 ++- .../list-database-objects-with-disk-usage.md | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 postgres/list-database-objects-with-disk-usage.md diff --git a/README.md b/README.md index 8f2fe2b..e69195b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_409 TILs and counting..._ +_410 TILs and counting..._ --- @@ -213,6 +213,7 @@ _409 TILs and counting..._ - [List All Versions Of A Function](postgres/list-all-versions-of-a-function.md) - [List Available Schemas](postgres/list-available-schemas.md) - [List Connections To A Database](postgres/list-connections-to-a-database.md) +- [List Database Objects With Disk Usage](postgres/list-database-objects-with-disk-usage.md) - [List Database Users](postgres/list-database-users.md) - [List Various Kinds Of Objects](postgres/list-various-kinds-of-objects.md) - [Lower Is Faster Than ilike](postgres/lower-is-faster-than-ilike.md) diff --git a/postgres/list-database-objects-with-disk-usage.md b/postgres/list-database-objects-with-disk-usage.md new file mode 100644 index 0000000..4611252 --- /dev/null +++ b/postgres/list-database-objects-with-disk-usage.md @@ -0,0 +1,25 @@ +# List Database Objects With Disk Usage + +I'll often times use `\d` or `\dt` to check out the tables in my database. +This shows the schema, object name, object type (e.g. `table`), and owner +for each. + +By adding the `+` to that meta-command, I can also see the disk usage for +each database object. + +Here is an example of look at all tables in a database with the additional +`Size` (or disk usage) information: + +```sql +> \dt+ + List of relations + Schema | Name | Type | Owner | Size | Description +--------+--------------------+-------+------------+------------+------------- + public | amount_types | table | jbranchaud | 16 kB | + public | ingredient_amounts | table | jbranchaud | 8192 bytes | + public | ingredient_types | table | jbranchaud | 16 kB | + public | ingredients | table | jbranchaud | 48 kB | + public | recipes | table | jbranchaud | 16 kB | + public | schema_migrations | table | jbranchaud | 16 kB | + public | users | table | jbranchaud | 16 kB | +```