From commits-return-1220-archive-asf-public=cust-asf.ponee.io@superset.incubator.apache.org Thu Jul 19 00:54:52 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3BB0518067A for ; Thu, 19 Jul 2018 00:54:52 +0200 (CEST) Received: (qmail 92255 invoked by uid 500); 18 Jul 2018 22:54:51 -0000 Mailing-List: contact commits-help@superset.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.incubator.apache.org Delivered-To: mailing list commits@superset.incubator.apache.org Received: (qmail 92246 invoked by uid 99); 18 Jul 2018 22:54:51 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jul 2018 22:54:51 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id A278B81ED5; Wed, 18 Jul 2018 22:54:50 +0000 (UTC) Date: Wed, 18 Jul 2018 22:54:50 +0000 To: "commits@superset.apache.org" Subject: [incubator-superset] branch master updated: Avoid expensive select_star on dashboard bootstrap data (#5424) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <153195449044.15135.665192614581736562@gitbox.apache.org> From: maximebeauchemin@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-superset X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: b0b04b319b79e299fc150837870755c2e0a51a1b X-Git-Newrev: 5be0e69d1b848dd7ea13f3adc883146484e9ba6a X-Git-Rev: 5be0e69d1b848dd7ea13f3adc883146484e9ba6a X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. maximebeauchemin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git The following commit(s) were added to refs/heads/master by this push: new 5be0e69 Avoid expensive select_star on dashboard bootstrap data (#5424) 5be0e69 is described below commit 5be0e69d1b848dd7ea13f3adc883146484e9ba6a Author: Maxime Beauchemin AuthorDate: Wed Jul 18 15:54:47 2018 -0700 Avoid expensive select_star on dashboard bootstrap data (#5424) The dashboard page bootstrap data currently attempts to generate the `SELECT` statement with column name details for each table represented in the dash. This means it calls the database(s) and waits for column details prior to returning any HTML. This makes the default select_star property generate a simple `SELECT *` with no column details instead, which doesn't require interogating the DBs. --- superset/connectors/sqla/models.py | 5 ++++- superset/data/__init__.py | 2 +- superset/models/core.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py index 205df32..3c5b18e 100644 --- a/superset/connectors/sqla/models.py +++ b/superset/connectors/sqla/models.py @@ -371,7 +371,10 @@ class SqlaTable(Model, BaseDatasource): @property def select_star(self): - return self.database.select_star(self.name, show_cols=True) + # show_cols and latest_partition set to false to avoid + # the expensive cost of inspecting the DB + return self.database.select_star( + self.name, show_cols=False, latest_partition=False) def get_col(self, col_name): columns = self.columns diff --git a/superset/data/__init__.py b/superset/data/__init__.py index 49df42b..5334269 100644 --- a/superset/data/__init__.py +++ b/superset/data/__init__.py @@ -17,7 +17,7 @@ from sqlalchemy import BigInteger, Date, DateTime, Float, String, Text import geohash import polyline -from superset import app, db, security_manager, utils +from superset import app, db, utils from superset.connectors.connector_registry import ConnectorRegistry from superset.connectors.sqla.models import TableColumn from superset.models import core as models diff --git a/superset/models/core.py b/superset/models/core.py index 8c77814..13021e7 100644 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -775,7 +775,7 @@ class Database(Model, AuditMixinNullable, ImportMixin): def select_star( self, table_name, schema=None, limit=100, show_cols=False, - indent=True, latest_partition=True, cols=None): + indent=True, latest_partition=False, cols=None): """Generates a ``select *`` statement in the proper dialect""" eng = self.get_sqla_engine(schema=schema) return self.db_engine_spec.select_star(