kgabryje opened a new pull request, #37895:
URL: https://github.com/apache/superset/pull/37895
### SUMMARY
GET /api/v1/chart/ with thumbnail_url in columns takes ~15s vs <1s without
it. The root cause is an N+1 query problem: for each chart, thumbnail_url →
digest → get_chart_digest() accesses chart.datasource, which is a computed
property that fires a fresh
db.session.query(...).filter_by(id=...).one_or_none() every time. With 200
charts, that's 200+ individual DB queries.
The Slice model already has a table relationship with lazy="subquery" that
bulk-loads datasources in a single subquery when Slices are queried, so we
should use that instead.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
1. Load a Superset instance with 100+ charts
2. Call GET /api/v1/chart/?q=(columns:!(thumbnail_url)) and observe response
time - you could simply do that by going to Dashboard edit mode and unselecting
"Show only my charts"
3. Verify thumbnail URLs are still returned correctly
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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]