aminghadersohi opened a new pull request, #38129: URL: https://github.com/apache/superset/pull/38129
## Summary - Add eager loading (SQLAlchemy `subqueryload`/`joinedload`) to all MCP `get_info` tools to prevent N+1 query patterns that cause timeouts on large datasets, dashboards with many charts, etc. - Add a generic `query_options` parameter to `BaseDAO.find_by_id()` and `ModelGetInfoCore` so any tool can specify eager loading options ## Problem The MCP `get_dataset_info`, `get_chart_info`, and `get_dashboard_info` tools use `BaseDAO.find_by_id()` which loads the model with lazy relationships. When the serializer subsequently accesses collection relationships (columns, metrics, owners, tags, slices, roles), each triggers a separate SQL query. For a dataset with 200+ columns or a dashboard with 30+ charts, this creates hundreds of queries and can exceed the per-tool timeout (30s). ## Changes ### `superset/daos/base.py` - Add optional `query_options` parameter to `_find_by_column()` and `find_by_id()` to accept SQLAlchemy loading strategies (backwards-compatible, defaults to `None`) ### `superset/mcp_service/mcp_core.py` - Add `query_options` parameter to `ModelGetInfoCore.__init__()`, propagated through all `_find_object()` code paths (ID, UUID, slug, fallback) ### `superset/mcp_service/dataset/tool/get_dataset_info.py` - Eager load `columns` (subqueryload), `metrics` (subqueryload), and `database` (joinedload) — the three relationships accessed by `serialize_dataset_object()` ### `superset/mcp_service/chart/tool/get_chart_info.py` - Eager load `owners` and `tags` (subqueryload) — accessed by `serialize_chart_object()` ### `superset/mcp_service/dashboard/tool/get_dashboard_info.py` - Eager load `slices`, `owners`, `tags`, `roles` (subqueryload) - Nested eager loading: `slices.owners` and `slices.tags` since `dashboard_serializer` calls `serialize_chart_object()` for each chart ## Test plan - [ ] Existing MCP dataset/chart/dashboard unit tests pass - [ ] `get_dataset_info` on a dataset with 200+ columns completes within timeout - [ ] `get_dashboard_info` on a dashboard with 30+ charts completes within timeout - [ ] `get_chart_info` returns correct owners and tags - [ ] Tools still work with UUID and slug identifiers (not just numeric IDs) -- 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]
