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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to