1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Add List Database Objects With Disk Usage as a postgres til

This commit is contained in:
jbranchaud
2016-05-06 11:44:19 -05:00
parent 121c721d13
commit 2293db2648
2 changed files with 27 additions and 1 deletions

View File

@@ -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)

View File

@@ -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 |
```