You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by bo...@apache.org on 2018/02/08 20:47:12 UTC

incubator-airflow git commit: [AIRFLOW-2078] Improve task_stats and dag_stats performance

Repository: incubator-airflow
Updated Branches:
  refs/heads/master 77b32a441 -> 4e8fdb50a


[AIRFLOW-2078] Improve task_stats and dag_stats performance

Closes #3013 from ori-moisis/master


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/4e8fdb50
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/4e8fdb50
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/4e8fdb50

Branch: refs/heads/master
Commit: 4e8fdb50a21560296f07fb767a97aed41e0f5f06
Parents: 77b32a4
Author: Ori Moisis <om...@magicleap.com>
Authored: Thu Feb 8 21:45:44 2018 +0100
Committer: Bolke de Bruin <bo...@xs4all.nl>
Committed: Thu Feb 8 21:46:52 2018 +0100

----------------------------------------------------------------------
 airflow/www/views.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/4e8fdb50/airflow/www/views.py
----------------------------------------------------------------------
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 252241a..89641e9 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -504,7 +504,9 @@ class Airflow(BaseView):
     def dag_stats(self, session=None):
         ds = models.DagStat
 
-        ds.update()
+        ds.update(
+            dag_ids=[dag.dag_id for dag in dagbag.dags.values() if not dag.is_subdag]
+        )
 
         qry = (
             session.query(ds.dag_id, ds.state, ds.count)
@@ -546,6 +548,7 @@ class Airflow(BaseView):
                 .join(Dag, Dag.dag_id == DagRun.dag_id)
                 .filter(DagRun.state != State.RUNNING)
                 .filter(Dag.is_active == True)
+                .filter(Dag.is_subdag == False)
                 .group_by(DagRun.dag_id)
                 .subquery('last_dag_run')
         )
@@ -554,6 +557,7 @@ class Airflow(BaseView):
                 .join(Dag, Dag.dag_id == DagRun.dag_id)
                 .filter(DagRun.state == State.RUNNING)
                 .filter(Dag.is_active == True)
+                .filter(Dag.is_subdag == False)
                 .subquery('running_dag_run')
         )