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

Add Creating Indexes With Ecto as an elixir til

This commit is contained in:
jbranchaud
2016-12-31 15:52:52 -06:00
parent c5942e2a68
commit 7935729c6e
2 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
# Creating Indexes With Ecto
Using indexes in the right places within relational databases is a great way
to speed up queries and ensure data integrity.
To add a basic index in an Ecto migration, use `Ecto.Migration.index\2`:
```elixir
create index(:users, [:email])
```
Creating a composite index doesn't require jumping through any hoops; just
put the relevant column names in the list:
```elixir
create index(:posts, [:user_id, :title])
```
See `h Ecto.Migration.index` for more details.