Repository navigation
[v3-3-test] Reuse the explicit dag_run join on the previous-TI lookup (#72811) - #72944
Merged
Merged
Conversation
…#72811) * Reuse the explicit dag_run join on the previous-TI lookup The previous-TI query in ``get_previous_task_instance`` explicitly joins ``dag_run`` for the ``ORDER BY dag_run.logical_date`` and asked for a second ``joinedload(TI.dag_run)`` for hydration. ``TaskInstance.dag_run`` is already ``lazy="joined"`` on the mapper, so the eager-load actually attached a parallel ``JOIN dag_run AS dag_run_1`` next to the explicit join. Both joins pull the same rows over the same FK pair. Switch to ``contains_eager(TI.dag_run)`` so the eager-load reuses the explicit join instead of adding a second one, and add a regression that fails when the compiled SQL references ``dag_run`` more than once in the FROM clause. * Drop unused load_only import * Assert the eager-load claim by watching for stray dag_run SELECTs * Swap the stray-select capture for a request-level query count (cherry picked from commit d076a57) Co-authored-by: Pierre Jeambrun <[email protected]>
1 task done
vatsrahul1001
marked this pull request as ready for review
September 11, 2026 10:59
vatsrahul1001
requested review from
amoghrajesh,
ashb and
kaxil
as code owners
September 11, 2026 10:59
amoghrajesh
approved these changes
Sep 11, 2026
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.
The previous-TI query in
get_previous_task_instanceexplicitly joinsdag_runfor theORDER BY dag_run.logical_dateand asked for a secondjoinedload(TI.dag_run)for hydration.TaskInstance.dag_runis alreadylazy="joined"on the mapper, so the eager-load actually attached a parallelJOIN dag_run AS dag_run_1next to the explicit join. Both joins pull thesame rows over the same FK pair.
Switch to
contains_eager(TI.dag_run)so the eager-load reuses the explicitjoin instead of adding a second one, and add a regression that fails when the
compiled SQL references
dag_runmore than once in the FROM clause.Drop unused load_only import
Assert the eager-load claim by watching for stray dag_run SELECTs
Swap the stray-select capture for a request-level query count
(cherry picked from commit d076a57)
Co-authored-by: Pierre Jeambrun [email protected]