superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Avoid expensive select_star on dashboard bootstrap data (#5424)
Date Wed, 18 Jul 2018 22:54:50 GMT
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 <maximebeauchemin@gmail.com>
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(


Mime
View raw message