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 (