Skip to content

perf: add index on task_instance.dag_version_id - #60886

Closed
sortega wants to merge 3 commits into
apache:mainfrom
DataDog:sortega/add-index-ti-dag-version-id
Closed

sortega wants to merge 3 commits into
apache:mainfrom
DataDog:sortega/add-index-ti-dag-version-id

Conversation

@sortega

@sortega sortega commented Jan 21, 2026 •

Copy link
Copy Markdown
Contributor

Add index ti_dag_version_id on task_instance.dag_version_id column to improve query performance.

The dag_version_id column was added in migration 0047_3_0_0_add_dag_versioning.py but no index was created, causing full table scans when filtering or joining on this column. This affects:

  • UI grid endpoint (/ui/dags/{dag_id}/grid/...) filtering task instances by dag_version_id
  • Any query joining task_instance with dag_version

Note on MySQL: The downgrade skips dropping the index on MySQL because MySQL requires an index on FK columns. Since dag_version_id has a FK constraint, MySQL will keep using the index for the FK.

closes #60883


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code following the guidelines


🤖 Drafted with Claude Code

Add index ti_dag_version_id on task_instance.dag_version_id column
to improve query performance. The column was added in migration 0047
but no index was created, causing full table scans when filtering
by dag_version_id.

closes apache#60883
@sortega
sortega force-pushed the sortega/add-index-ti-dag-version-id branch from db30951 to 55c9004 Compare January 22, 2026 11:09
@sortega
sortega force-pushed the sortega/add-index-ti-dag-version-id branch from 55c9004 to ebb317d Compare January 22, 2026 13:15
@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Mar 9, 2026
@github-actions github-actions Bot closed this Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:db-migrations PRs with DB migration kind:documentation stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid full table scan on /structure/{dag_id}

1 participant