diff --git a/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceGrid.tsx b/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceGrid.tsx index ee5b1acd2bd..b96cbb44dab 100644 --- a/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceGrid.tsx +++ b/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceGrid.tsx @@ -438,6 +438,25 @@ export const QueryPerformanceGrid = ({ } }, [handleKeyDown]) + const isSelectQuery = (query: string | undefined): boolean => { + if (!query) return false + const formattedQuery = query.trim().toLowerCase() + return ( + formattedQuery.startsWith('select') || + formattedQuery.startsWith('with pgrst_source') || + formattedQuery.startsWith('with pgrst_payload') + ) + } + + useEffect(() => { + if (selectedRow !== undefined && view === 'suggestion') { + const query = reportData[selectedRow]?.query + if (!isSelectQuery(query)) { + setView('details') + } + } + }, [selectedRow, view, reportData]) + return (
@@ -477,14 +496,12 @@ export const QueryPerformanceGrid = ({ event.stopPropagation() if (typeof idx === 'number' && idx >= 0) { - // If onCurrentSelectQuery is provided, use the chart selection logic if (onCurrentSelectQuery) { const query = reportData[idx]?.query if (query) { onCurrentSelectQuery(query) } } else { - // Otherwise, open the detail panel setSelectedRow(idx) const hasRecommendations = hasIndexRecommendations( reportData[idx]?.index_advisor_result, @@ -553,12 +570,14 @@ export const QueryPerformanceGrid = ({ > Query details - - Indexes - + {selectedRow !== undefined && isSelectQuery(reportData[selectedRow]?.query) && ( + + Indexes + + )}
@@ -571,12 +590,14 @@ export const QueryPerformanceGrid = ({ /> )} - - {selectedRow !== undefined && } - + {selectedRow !== undefined && isSelectQuery(reportData[selectedRow]?.query) && ( + + + + )}