perf(explore): reuse chart query data in Results tab#38165
perf(explore): reuse chart query data in Results tab#38165kimsehwan96 wants to merge 2 commits intoapache:masterfrom
Conversation
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
Code Review Agent Run #eda19dActionable Suggestions - 0Additional Suggestions - 2
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Address review feedback: destructure and forward the queriesResponse prop to useResultsPane for interface contract consistency.
Code Review Agent Run #3cbfd9Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
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.
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):
Race condition in
DataTablesPane:isRequest.resultsis not reset tofalsewhenchartStatustransitions to'loading'. WhenqueryFormDatachanges during chart loading,useResultsPane's effect fires immediately — sending the Results request at the same time as the chart request.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:
isRequest.resultstofalsewhenchartStatus === 'loading'to prevent the race conditionchart.queriesResponsefrom Redux throughExploreChartPanel→DataTablesPane→useResultsPanequeriesResponsecontains v1 API data (hascolnamesfield), reuse it directly — skipping the separate API call entirelyqueriesResponsefall back to the existing API callResult: 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
AS-IS duplicated query was submitted to trino
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