perf: add index on task_instance.dag_version_id #60886
Open
+1,676
−1,621
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add index
ti_dag_version_idontask_instance.dag_version_idcolumn to improve query performance.The
dag_version_idcolumn was added in migration0047_3_0_0_add_dag_versioning.pybut no index was created, causing full table scans when filtering or joining on this column. This affects:/ui/dags/{dag_id}/grid/...) filtering task instances bydag_version_idtask_instancewithdag_versionNote on MySQL: The downgrade skips dropping the index on MySQL because MySQL requires an index on FK columns. Since
dag_version_idhas a FK constraint, MySQL will keep using the index for the FK.closes #60883
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines
🤖 Drafted with Claude Code