Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5E8D4200B13 for ; Wed, 15 Jun 2016 20:38:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5D4B6160A19; Wed, 15 Jun 2016 18:38:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7C81F160A57 for ; Wed, 15 Jun 2016 20:38:13 +0200 (CEST) Received: (qmail 68217 invoked by uid 500); 15 Jun 2016 18:38:12 -0000 Mailing-List: contact commits-help@airflow.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airflow.incubator.apache.org Delivered-To: mailing list commits@airflow.incubator.apache.org Received: (qmail 68208 invoked by uid 99); 15 Jun 2016 18:38:12 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jun 2016 18:38:12 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 4B155C2336 for ; Wed, 15 Jun 2016 18:38:12 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.446 X-Spam-Level: X-Spam-Status: No, score=-5.446 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id mFIfWYEz9hO7 for ; Wed, 15 Jun 2016 18:38:11 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id 7400D5F1F7 for ; Wed, 15 Jun 2016 18:38:10 +0000 (UTC) Received: (qmail 65629 invoked by uid 99); 15 Jun 2016 18:38:09 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jun 2016 18:38:09 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 8355A2C1F64 for ; Wed, 15 Jun 2016 18:38:09 +0000 (UTC) Date: Wed, 15 Jun 2016 18:38:09 +0000 (UTC) From: "Neil Hanlon (JIRA)" To: commits@airflow.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AIRFLOW-246) dag_stats endpoint has a terrible query MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 15 Jun 2016 18:38:14 -0000 [ https://issues.apache.org/jira/browse/AIRFLOW-246?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Neil Hanlon updated AIRFLOW-246: -------------------------------- Description: Hitting this endpoint creates a series of queries on the database which take over 20 seconds to run, causing the page to not load for that entire time. Luckily the main page (which includes this under "Recent Statuses") loads this synchronously, but still... waiting almost half a minute (at times more) to see the statuses for dags is really not fun. We have less than a million rows in the task_instance table--so it's not even a problem with that. Here's a query profile for the query: https://gist.github.com/NeilHanlon/613f12724e802bc51c23fca7d46d28bf We've done some optimizations on the database, but to no avail. The query: {code:sql} SELECT task_instance.dag_id AS task_instance_dag_id, task_instance.state AS task_instance_state, count(task_instance.task_id) AS count_1 FROM task_instance LEFT OUTER JOIN (SELECT dag_run.dag_id AS dag_id, dag_run.execution_date AS execution_date FROM dag_run WHERE dag_run.state = 'running') AS running_dag_run ON running_dag_run.dag_id = task_instance.dag_id AND running_dag_run.execution_date = task_instance.execution_date LEFT OUTER JOIN (SELECT dag_run.dag_id AS dag_id, max(dag_run.execution_date) AS execution_date FROM dag_run GROUP BY dag_run.dag_id) AS last_dag_run ON last_dag_run.dag_id = task_instance.dag_id AND last_dag_run.execution_date = task_instance.execution_date WHERE task_instance.task_id IN ... AND (running_dag_run.dag_id IS NOT NULL OR last_dag_run.dag_id IS NOT NULL) GROUP BY task_instance.dag_id, task_instance.state; {code} was: Hitting this endpoint creates a series of queries on the database which take over 20 seconds to run, causing the page to not load for that entire time. Luckily the main page (which includes this under "Recent Statuses") loads this synchronously, but still... waiting almost half a minute (at times more) to see the statuses for dags is really not fun. We have less than a million rows in the task_instance table--so it's not even a problem with that. Here's a query profile for the query: https://gist.github.com/NeilHanlon/613f12724e802bc51c23fca7d46d28bf We've done some optimizations on the database, but to no avail. The query: [pre] SELECT task_instance.dag_id AS task_instance_dag_id, task_instance.state AS task_instance_state, count(task_instance.task_id) AS count_1 FROM task_instance LEFT OUTER JOIN (SELECT dag_run.dag_id AS dag_id, dag_run.execution_date AS execution_date FROM dag_run WHERE dag_run.state = 'running') AS running_dag_run ON running_dag_run.dag_id = task_instance.dag_id AND running_dag_run.execution_date = task_instance.execution_date LEFT OUTER JOIN (SELECT dag_run.dag_id AS dag_id, max(dag_run.execution_date) AS execution_date FROM dag_run GROUP BY dag_run.dag_id) AS last_dag_run ON last_dag_run.dag_id = task_instance.dag_id AND last_dag_run.execution_date = task_instance.execution_date WHERE task_instance.task_id IN ... AND (running_dag_run.dag_id IS NOT NULL OR last_dag_run.dag_id IS NOT NULL) GROUP BY task_instance.dag_id, task_instance.state; [/pre] > dag_stats endpoint has a terrible query > --------------------------------------- > > Key: AIRFLOW-246 > URL: https://issues.apache.org/jira/browse/AIRFLOW-246 > Project: Apache Airflow > Issue Type: Bug > Components: webserver > Affects Versions: Airflow 1.7.1 > Environment: MySQL Backend through sqlalchemy > Reporter: Neil Hanlon > > Hitting this endpoint creates a series of queries on the database which take over 20 seconds to run, causing the page to not load for that entire time. Luckily the main page (which includes this under "Recent Statuses") loads this synchronously, but still... waiting almost half a minute (at times more) to see the statuses for dags is really not fun. > We have less than a million rows in the task_instance table--so it's not even a problem with that. > Here's a query profile for the query: > https://gist.github.com/NeilHanlon/613f12724e802bc51c23fca7d46d28bf > We've done some optimizations on the database, but to no avail. > The query: > {code:sql} > SELECT task_instance.dag_id AS task_instance_dag_id, task_instance.state AS task_instance_state, count(task_instance.task_id) AS count_1 FROM task_instance LEFT OUTER JOIN (SELECT dag_run.dag_id AS dag_id, dag_run.execution_date AS execution_date FROM dag_run WHERE dag_run.state = 'running') AS running_dag_run ON running_dag_run.dag_id = task_instance.dag_id AND running_dag_run.execution_date = task_instance.execution_date LEFT OUTER JOIN (SELECT dag_run.dag_id AS dag_id, max(dag_run.execution_date) AS execution_date FROM dag_run GROUP BY dag_run.dag_id) AS last_dag_run ON last_dag_run.dag_id = task_instance.dag_id AND last_dag_run.execution_date = task_instance.execution_date WHERE task_instance.task_id IN ... AND (running_dag_run.dag_id IS NOT NULL OR last_dag_run.dag_id IS NOT NULL) GROUP BY task_instance.dag_id, task_instance.state; > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)