SIGN IN SIGN UP

Optimize Indexes (#656)

Optimize `workflow_status` table indexes to reduce the cost of
maintaining indexes at scale.

- Indexes on `parent_workflow_id`, `forked_from`, and `deduplication_id`
are made partial on those fields not being NULL so they're not
maintained when not needed.
- The index on `executor_id` is dropped as
https://github.com/dbos-inc/dbos-transact-py/pull/644 eliminates the
need for it.
- The index on the `status` field is split into two partial indexes: one
on `PENDING` workflows for use in recovery; the other on failed
workflows (`ERROR`, `CANCELLED`, `MAX_RECOVERY_ATTEMPTS_EXCEEDED`) for
rapid troubleshooting. This reduces the number of times the index is
updated during a typical workflow lifetime
(`ENQUEUED`->`PENDING`->`SUCCESS`).
- The index on `queue_name` and `status` used by the main dequeue query
is optimized to index on `("queue_name", "status", "priority",
"created_at")`, the exact predicates and sort order of the dequeue
query. It is now partial on `ENQUEUED` or `PENDING` workflows as only
the dequeue query needs it.
- A new partial index is created for rate-limited queues to quickly find
recent queries in that queue. That index is only maintained for
rate-limited queues (using a new `rate_limited` field).
- All migrations use `CREATE INDEX CONCURRENTLY` for safety when running
against production workloads.
P
Peter Kraft committed
91799bbb49bef16676c247e245178aef48826733
Parent: 986d82a
Committed by GitHub <noreply@github.com> on 5/4/2026, 5:10:27 PM