You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/07/14 18:03:03 UTC

[GitHub] [superset] villebro commented on a change in pull request #15648: perf: Refactor Dashboard.datasets_trimmed_for_slices et al.

villebro commented on a change in pull request #15648:
URL: https://github.com/apache/superset/pull/15648#discussion_r669837659



##########
File path: superset/models/dashboard.py
##########
@@ -171,8 +172,21 @@ def url(self) -> str:
 
     @property
     def datasources(self) -> Set[BaseDatasource]:
-        # pylint: disable=using-constant-test
-        return {slc.datasource for slc in self.slices if slc.datasource}

Review comment:
       @john-bodley yes, that sounds like a perfect solution 👍  It would be nice if we had a mechanism that could somehow automatically surface these types of perf issues (=hitting the metadata db multiple times for the same object). @kgabryje successfully used a React library called [WDYR - Why Did You Render](https://www.npmjs.com/package/@welldone-software/why-did-you-render) that warns about potentially avoidable React rerenders - It'd be great to have something similar for SqlAlchemy ORM. Alternatively we could build a wrapper around `db.session.query().filter()` that caches on both the class passed to `query() and the kwargs passed to `filter()`.

##########
File path: superset/models/dashboard.py
##########
@@ -171,8 +172,21 @@ def url(self) -> str:
 
     @property
     def datasources(self) -> Set[BaseDatasource]:
-        # pylint: disable=using-constant-test
-        return {slc.datasource for slc in self.slices if slc.datasource}

Review comment:
       @john-bodley yes, that sounds like a perfect solution 👍  It would be nice if we had a mechanism that could somehow automatically surface these types of perf issues (=hitting the metadata db multiple times for the same object). @kgabryje successfully used a React library called [WDYR - Why Did You Render](https://www.npmjs.com/package/@welldone-software/why-did-you-render) that warns about potentially avoidable React rerenders - It'd be great to have something similar for SqlAlchemy ORM. Alternatively we could build a wrapper around `db.session.query().filter()` that caches on both the class passed to `query()` and the kwargs passed to `filter()`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org