1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00
Files
til/elixir/creating-indexes-with-ecto.md
2016-12-31 15:57:30 -06:00

20 lines
471 B
Markdown

# Creating Indexes With Ecto
Using indexes in the right places within relational databases is a great way
to speed up queries.
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.