Skip to content

Comments

perf(explore): reuse chart query data in Results tab#38165

Open
kimsehwan96 wants to merge 2 commits intoapache:masterfrom
kimsehwan96:fix/explore-results-pane-duplicate-query
Open

perf(explore): reuse chart query data in Results tab#38165
kimsehwan96 wants to merge 2 commits intoapache:masterfrom
kimsehwan96:fix/explore-results-pane-duplicate-query

Conversation

@kimsehwan96
Copy link
Contributor

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

SUMMARY

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'. WhenqueryFormData 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 ExploreChartPanelDataTablesPaneuseResultsPane
  • 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

스크린샷 2026-02-21 오후 12 44 59

AS-IS duplicated query was submitted to trino

스크린샷 2026-02-21 오후 9 23 49

TO-BE only one query was submitted to trino and the result will be used in chart and result panels.

TESTING INSTRUCTIONS

Build it locally and creating environment with docker-compose and tested it.

ADDITIONAL INFORMATION

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 apache#38152
@dosubot
Copy link

dosubot bot commented Feb 22, 2026

Related Documentation

Checked 0 published document(s) in 2 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 22, 2026

Code Review Agent Run #eda19d

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset-frontend/src/explore/components/DataTablesPane/types.ts - 1
    • Interface contract violation · Line 55-55
      The queriesResponse prop is added to ResultsPaneProps but ResultsPaneOnDashboard doesn't destructure or use it, which could ignore the prop if passed. To maintain interface consistency, the component should accept and forward this optional prop.
  • superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx - 1
    • Type mismatch in data assignment · Line 88-88
      Assigning result.data (DataRecord[]) to QueryResultInterface.data (expected Record[][]) creates a type mismatch. While runtime works due to the cast, this reduces type safety. Consider updating the interface type since downstream usage treats data as an array of records.
Review Details
  • Files reviewed - 4 · Commit Range: fdb69a1..fdb69a1
    • superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx
    • superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx
    • superset-frontend/src/explore/components/DataTablesPane/types.ts
    • superset-frontend/src/explore/components/ExploreChartPanel/index.tsx
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added the explore:performance Related to performance of Explore label Feb 22, 2026
Address review feedback: destructure and forward the queriesResponse
prop to useResultsPane for interface contract consistency.
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 22, 2026

Code Review Agent Run #3cbfd9

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: fdb69a1..9cb4a46
    • superset-frontend/src/explore/components/DataTablesPane/DataTablesPane.tsx
    • superset-frontend/src/explore/components/DataTablesPane/components/ResultsPaneOnDashboard.tsx
    • superset-frontend/src/explore/components/DataTablesPane/components/useResultsPane.tsx
    • superset-frontend/src/explore/components/DataTablesPane/types.ts
    • superset-frontend/src/explore/components/ExploreChartPanel/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

explore:performance Related to performance of Explore size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Charts tabs update chart execute same query simultaneously when results tab opened

2 participants