diff --git a/README.md b/README.md index 87f68ba..8f2fe2b 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/). -_408 TILs and counting..._ +_409 TILs and counting..._ --- @@ -200,6 +200,7 @@ _408 TILs and counting..._ - [Generate Series Of Numbers](postgres/generate-series-of-numbers.md) - [Get The Size Of A Database](postgres/get-the-size-of-a-database.md) - [Get The Size Of A Table](postgres/get-the-size-of-a-table.md) +- [Get The Size Of An Index](postgres/get-the-size-of-an-index.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-an-index.md b/postgres/get-the-size-of-an-index.md new file mode 100644 index 0000000..b596116 --- /dev/null +++ b/postgres/get-the-size-of-an-index.md @@ -0,0 +1,23 @@ +# Get The Size Of An Index + +Want to get an idea of how much disk space that additional index is taking +up? You can query for it with the same methods discussed in [Get The Size Of +A Table](get-the-size-of-a-table.md) and [Pretty Print Data +Sizes](pretty-print-data-sizes.md). + +For instance, if I have a table with a `users_pkey` index and a +`users_unique_lower_email_idx` index, I can check the sizes like so: + +```sql +> select pg_size_pretty(pg_relation_size('users_pkey')); + pg_size_pretty +---------------- + 240 kB + +> select pg_size_pretty(pg_relation_size('users_unique_lower_email_idx')); + pg_size_pretty +---------------- + 704 kB +``` + +[source](https://www.niwi.nz/2013/02/17/postgresql-database-table-indexes-size/)