kimsehwan96 opened a new pull request, #38165: URL: https://github.com/apache/superset/pull/38165
The Results tab in DataTablesPane independently fires a separate API request with resultType='results', which produces identical SQL to the chart's resultType='full' request on the backend. This doubles database load on every chart execution when the Results tab is open. - Reset isRequest.results to false during chart loading to prevent race condition where both requests fire simultaneously - Pass chart.queriesResponse from Redux through to useResultsPane - Reuse chart data directly when available (v1 API), falling back to API call for legacy charts Closes #38152 <!--- Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/ Example: fix(dashboard): load charts correctly --> ### SUMMARY <!--- Describe the change below, including rationale and design decisions --> The Results tab in the Explore view's DataTablesPane fires an independent API request (`resultType='results'`) every time a chart query runs. On the backend, `_get_results()` is a pure pass-through to `_get_full()` — both produce **identical SQL**. This means every chart execution with the Results tab open sends two duplicate database queries simultaneously. **Root cause (two issues):** 1. **Race condition in `DataTablesPane`**: `isRequest.results` is not reset to `false` when `chartStatus` transitions to `'loading'`. When`queryFormData` changes during chart loading, `useResultsPane`'s effect fires immediately — sending the Results request at the same time as the chart request. 2. **Redundant API call in `useResultsPane`**: The hook always fetches data via a separate network request, even though identical data is already available in Redux (`chart.queriesResponse`) after the chart query completes. **Fix:** - Reset `isRequest.results` to `false` when `chartStatus === 'loading'` to prevent the race condition - Pass `chart.queriesResponse` from Redux through `ExploreChartPanel` → `DataTablesPane` → `useResultsPane` - When `queriesResponse` contains v1 API data (has `colnames` field), reuse it directly — skipping the separate API call entirely - Legacy charts without typed `queriesResponse` fall back to the existing API call **Result:** One database query instead of two per chart execution. Results tab data appears instantly from Redux without a network round-trip. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> <img width="2548" height="1277" alt="스크린샷 2026-02-21 오후 12 44 59" src="https://github.com/user-attachments/assets/2261fdfb-3a02-4b2b-8cfb-ffdad035735d" /> AS-IS duplicated query was submitted to trino <img width="2426" height="1285" alt="스크린샷 2026-02-21 오후 9 23 49" src="https://github.com/user-attachments/assets/1d4ca034-0d74-41a9-8ff2-6cb3044e993f" /> TO-BE only one query was submitted to trino and the result will be used in chart and result panels. ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> Build it locally and creating environment with docker-compose and tested it. ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [x] Has associated issue: https://github.com/apache/superset/issues/38152 - [ ] Required feature flags: - [ ] Changes UI : No changes in 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]
