Skip to content

Commit

Permalink
Remove redundant count query in BaseOperator.clear() (apache#9362)
Browse files Browse the repository at this point in the history
We already fetch the results using `qry.all()` so running `qry.count()` is just redundant.
  • Loading branch information
kaxil committed Jun 27, 2020
1 parent 7f47150 commit 8e3aa80
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions airflow/models/baseoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,13 +1027,10 @@ def clear(self,
t.task_id for t in self.get_flat_relatives(upstream=False)]

qry = qry.filter(TaskInstance.task_id.in_(tasks))

count = qry.count()

clear_task_instances(qry.all(), session, dag=self.dag)

results = qry.all()
count = len(results)
clear_task_instances(results, session, dag=self.dag)
session.commit()

return count

@provide_session
Expand Down

0 comments on commit 8e3aa80

Please sign in to comment.