This is an automated email from the ASF dual-hosted git repository.

vincbeck pushed a commit to branch v2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v2-10-test by this push:
     new 893261043c Use `selectinload` in trigger (#40487) (#42351)
893261043c is described below

commit 893261043c063a9adc2c7e35d83ad5b9b829adef
Author: Vincent <[email protected]>
AuthorDate: Thu Sep 19 10:23:43 2024 -0700

    Use `selectinload` in trigger (#40487) (#42351)
    
    (cherry picked from commit 46b41e332f2d32962c0e3c14c1e5b8d052dfc359)
    
    Co-authored-by: Joseph Ang <[email protected]>
---
 airflow/models/trigger.py  | 6 +++---
 docs/spelling_wordlist.txt | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/airflow/models/trigger.py b/airflow/models/trigger.py
index 8c4dee7ebc..43d9c515f0 100644
--- a/airflow/models/trigger.py
+++ b/airflow/models/trigger.py
@@ -21,7 +21,7 @@ from traceback import format_exception
 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
@@ -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,
@@ -152,7 +152,7 @@ class Trigger(Base):
             select(cls)
             .where(cls.id.in_(ids))
             .options(
-                joinedload(cls.task_instance)
+                selectinload(cls.task_instance)
                 .joinedload(TaskInstance.trigger)
                 .joinedload(Trigger.triggerer_job)
             )
diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt
index 29d5f6d58a..1ca4c8dc45 100644
--- a/docs/spelling_wordlist.txt
+++ b/docs/spelling_wordlist.txt
@@ -1439,6 +1439,7 @@ Seedlist
 seedlist
 seekable
 segmentGranularity
+selectin
 Sendgrid
 sendgrid
 sentimentMax

Reply via email to