Reduce task group query work in Execution API#68423
Open
steveahnahn wants to merge 2 commits into
Open
Conversation
kaxil
reviewed
Jun 13, 2026
cf68661 to
3375b66
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reduce task-group query work in the Execution API.
The task-instance count and state endpoints now resolve task-group task IDs from the serialized Dag and apply those IDs to the task-instance query before executing it. This avoids loading task-instance rows just to build another filter, and avoids the
/statestask-group path fetching Dag-wide task instances before replacing that result with the group rows.Why:
/execution/task-instances/states?task_group_id=...executed one broadtask_instanceSELECT and one group-scopedtask_instanceSELECT./execution/task-instances/count?task_group_id=...loaded group task-instance rows before executing the count query.What changed:
/states, preserving the union of explicittask_idsand task-group tasks.task_instanceSELECT.Evidence:
breeze run pytest airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py::TestGetCount::test_get_count_with_task_group airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py::TestGetTaskStates::test_get_task_states_group_id_basic -qAssertionError: assert 2 == 1.breeze run pytest airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py::TestGetCount::test_get_count_with_task_group airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py::TestGetTaskStates::test_get_task_states_group_id_basic -q2 passedWas generative AI tooling used to co-author this PR?
Generated-by: Codex (GPT-5) following the guidelines