# `AshWorkflow.Transformers.AddIndexes`
[🔗](https://github.com/team-alembic/ash_workflow/blob/v0.12.0/lib/ash_workflow/transformers/add_indexes.ex#L1)

Adds the composite indexes that the generated Oban triggers need, for
resources using `AshPostgres.DataLayer`.

Every generated trigger filters on `state`, and every timeout trigger also
filters on its `field`. `ago/2` compiles to a bind parameter rather than a
per-row function call, so a timeout's `where` reaches Postgres as
`state = $1 AND state_entered_at <= $2` — an ordinary composite range scan.
Without an index that is a sequential scan on every poll, for every timeout.

Indexes are named `ash_workflow_<table>_<fields>_index` so they are
recognisable in migrations as belonging to this extension, and are only added
when no existing `custom_indexes` entry already covers the same fields —
a user-declared index always wins.

Resources on other data layers are untouched; see
`AshWorkflow.Info.recommended_indexes/1` for the same information as data.

Opt out per resource with `workflow do generate_indexes? false end`.

# `after?`

# `after_compile?`

# `before?`

# `transform`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
