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

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


The following commit(s) were added to refs/heads/v1-10-test by this push:
     new 1e91572  Remove redundant count query in BaseOperator.clear() (#9362)
1e91572 is described below

commit 1e91572886a65d81d2c2c3cacf0f92f6eed14063
Author: Kaxil Naik <[email protected]>
AuthorDate: Thu Jun 18 01:47:16 2020 +0100

    Remove redundant count query in BaseOperator.clear() (#9362)
    
    We already fetch the results using `qry.all()` so running `qry.count()` is 
just redundant.
    
    (cherry picked from commit 8c9a7b2b0069425c7bb9eff4d25313f436e78307)
---
 airflow/models/baseoperator.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py
index 0f76770..b61c980 100644
--- a/airflow/models/baseoperator.py
+++ b/airflow/models/baseoperator.py
@@ -874,14 +874,11 @@ class BaseOperator(LoggingMixin):
             tasks += [
                 t.task_id for t in self.get_flat_relatives(upstream=False)]
 
-        qry = qry.filter(TI.task_id.in_(tasks))
-
-        count = qry.count()
-
-        clear_task_instances(qry.all(), session, dag=self.dag)
-
+        qry = qry.filter(TaskInstance.task_id.in_(tasks))
+        results = qry.all()
+        count = len(results)
+        clear_task_instances(results, session, dag=self.dag)
         session.commit()
-
         return count
 
     @provide_session

Reply via email to