Skip to content

Commit

Permalink
Speed up all CRUD list views (#2747)
Browse files Browse the repository at this point in the history
Load times on list view pages like Slices, Dashboards, Tables and Database
have grown to be terrible over time.

After a bit of digging, I found that the not specifying `search_columns`
in ModelViews actually means "all columns" and that for each filter,
FAB goes and fetches a list of all values to prepopulate the
filter dropdowns. That means that the list of tables would fetch all
slices and all users upfront which is horrible. Worse, database list
view would fetch all queries with is insane.

This picks a subset of columns for search/filters and changes the
default to show only 100 elements per page instead of 500
  • Loading branch information
mistercrunch committed May 11, 2017
1 parent d5e9d5d commit e558444
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
6 changes: 5 additions & 1 deletion superset/connectors/druid/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class DruidClusterModelView(SupersetModelView, DeleteMixin): # noqa
]
edit_columns = add_columns
list_columns = ['cluster_name', 'metadata_last_refreshed']
search_columns = ('cluster_name',)
label_columns = {
'cluster_name': _("Cluster"),
'coordinator_host': _("Coordinator Host"),
Expand Down Expand Up @@ -150,7 +151,7 @@ class DruidDatasourceModelView(SupersetModelView, DeleteMixin): # noqa
datamodel = SQLAInterface(models.DruidDatasource)
list_widget = ListWidgetWithCheckboxes
list_columns = [
'datasource_link', 'cluster', 'changed_by_', 'changed_on_', 'offset']
'datasource_link', 'cluster', 'changed_by_', 'modified']
order_columns = [
'datasource_link', 'changed_on_', 'offset']
related_views = [DruidColumnInlineView, DruidMetricInlineView]
Expand All @@ -159,6 +160,9 @@ class DruidDatasourceModelView(SupersetModelView, DeleteMixin): # noqa
'is_hidden',
'filter_select_enabled', 'fetch_values_from',
'default_endpoint', 'offset', 'cache_timeout']
search_columns = (
'datasource_name', 'cluster', 'description', 'owner'
)
add_columns = edit_columns
show_columns = add_columns + ['perm']
page_size = 500
Expand Down
5 changes: 4 additions & 1 deletion superset/connectors/sqla/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class TableModelView(SupersetModelView, DeleteMixin): # noqa
datamodel = SQLAInterface(models.SqlaTable)
list_columns = [
'link', 'database',
'changed_by_', 'changed_on_']
'changed_by_', 'modified']
order_columns = [
'link', 'database', 'changed_on_']
add_columns = ['database', 'schema', 'table_name']
Expand All @@ -149,6 +149,9 @@ class TableModelView(SupersetModelView, DeleteMixin): # noqa
show_columns = edit_columns + ['perm']
related_views = [TableColumnInlineView, SqlMetricInlineView]
base_order = ('changed_on', 'desc')
search_columns = (
'database', 'schema', 'table_name', 'owner',
)
description_columns = {
'slices': _(
"The list of slices associated with this table. By "
Expand Down
2 changes: 1 addition & 1 deletion superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def accessible_by_user(self, database, datasource_names, schema=None):


class SupersetModelView(ModelView):
page_size = 500
page_size = 100


class ListWidgetWithCheckboxes(ListWidget):
Expand Down
8 changes: 7 additions & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ class DatabaseView(SupersetModelView, DeleteMixin): # noqa
'database_name', 'sqlalchemy_uri', 'cache_timeout', 'extra',
'expose_in_sqllab', 'allow_run_sync', 'allow_run_async',
'allow_ctas', 'allow_dml', 'force_ctas_schema']
search_exclude_columns = ('password',)
search_exclude_columns = (
'password', 'tables', 'created_by', 'changed_by', 'queries',
'saved_queries', )
edit_columns = add_columns
show_columns = [
'tables',
Expand Down Expand Up @@ -317,6 +319,9 @@ class SliceModelView(SupersetModelView, DeleteMixin): # noqa
label_columns = {
'datasource_link': 'Datasource',
}
search_columns = (
'slice_name', 'description', 'viz_type', 'owners',
)
list_columns = [
'slice_link', 'viz_type', 'datasource_link', 'creator', 'modified']
edit_columns = [
Expand Down Expand Up @@ -405,6 +410,7 @@ class DashboardModelView(SupersetModelView, DeleteMixin): # noqa
'dashboard_title', 'slug', 'slices', 'owners', 'position_json', 'css',
'json_metadata']
show_columns = edit_columns + ['table_names']
search_columns = ('dashboard_title', 'slug', 'owners')
add_columns = edit_columns
base_order = ('changed_on', 'desc')
description_columns = {
Expand Down
1 change: 1 addition & 0 deletions superset/views/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class SavedQueryView(SupersetModelView, DeleteMixin):
show_columns = [
'id', 'label', 'user', 'database',
'description', 'sql', 'pop_tab_link']
search_columns = ('label', 'user', 'database', 'schema', 'changed_on')
add_columns = ['label', 'database', 'description', 'sql']
edit_columns = add_columns
base_order = ('changed_on', 'desc')
Expand Down

0 comments on commit e558444

Please sign in to comment.