Skip to content

Commit

Permalink
Use selectinload in trigger (apache#40487) (apache#42351)
Browse files Browse the repository at this point in the history
(cherry picked from commit 46b41e3)

Co-authored-by: Joseph Ang <[email protected]>
  • Loading branch information
vincbeck and josephangbc authored Sep 19, 2024
1 parent 26f7365 commit 8932610
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions airflow/models/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typing import TYPE_CHECKING, Any, Iterable

from sqlalchemy import Column, Integer, String, Text, delete, func, or_, select, update
from sqlalchemy.orm import joinedload, relationship
from sqlalchemy.orm import relationship, selectinload
from sqlalchemy.sql.functions import coalesce

from airflow.api_internal.internal_api_call import internal_api_call
Expand Down Expand Up @@ -75,7 +75,7 @@ class Trigger(Base):
uselist=False,
)

task_instance = relationship("TaskInstance", back_populates="trigger", lazy="joined", uselist=False)
task_instance = relationship("TaskInstance", back_populates="trigger", lazy="selectin", uselist=False)

def __init__(
self,
Expand Down Expand Up @@ -152,7 +152,7 @@ def bulk_fetch(cls, ids: Iterable[int], session: Session = NEW_SESSION) -> dict[
select(cls)
.where(cls.id.in_(ids))
.options(
joinedload(cls.task_instance)
selectinload(cls.task_instance)
.joinedload(TaskInstance.trigger)
.joinedload(Trigger.triggerer_job)
)
Expand Down
1 change: 1 addition & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,7 @@ Seedlist
seedlist
seekable
segmentGranularity
selectin
Sendgrid
sendgrid
sentimentMax
Expand Down

0 comments on commit 8932610

Please sign in to comment.