AshWorkflow.Transformers.AddIndexes (AshWorkflow v0.6.0)

Copy Markdown View Source

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.

Summary

Functions

after?(arg1)

Callback implementation for Spark.Dsl.Transformer.after?/1.

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(_)

Callback implementation for Spark.Dsl.Transformer.before?/1.

transform(dsl)

Callback implementation for Spark.Dsl.Transformer.transform/1.