Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Chore/allow index advisor for postgrest queries (#27364)

Terry Sutton6fa71c6c8e48
diff --git a/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceGrid.tsx b/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceGrid.tsx
index 87bea407407..32f68a9de90 100644
--- a/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceGrid.tsx
+++ b/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceGrid.tsx
@@ -92,7 +92,8 @@ export const QueryPerformanceGrid = ({ queryPerformanceQuery }: QueryPerformance
const selectedQuery =
selectedRow !== undefined ? queryPerformanceQuery.data?.[selectedRow]?.['query'] : undefined
- const showIndexSuggestions = (selectedQuery ?? '').trim().toLowerCase().startsWith('select')
+ const query = (selectedQuery ?? '').trim().toLowerCase()
+ const showIndexSuggestions = query.startsWith('select') || query.startsWith('with pgrst_source')
const onSortChange = (column: string) => {
let updatedSort = undefined
diff --git a/apps/studio/data/database/retrieve-index-advisor-result-query.ts b/apps/studio/data/database/retrieve-index-advisor-result-query.ts
index 9dae39adb96..e822cf2a860 100644
--- a/apps/studio/data/database/retrieve-index-advisor-result-query.ts
+++ b/apps/studio/data/database/retrieve-index-advisor-result-query.ts
@@ -50,10 +50,11 @@ export const useGetIndexAdvisorResult = <TData = GetIndexAdvisorResultData>(
{
retry: false,
enabled:
- enabled &&
- typeof projectRef !== 'undefined' &&
- typeof query !== 'undefined' &&
- (query.startsWith('select') || query.startsWith('SELECT')),
+ (enabled &&
+ typeof projectRef !== 'undefined' &&
+ typeof query !== 'undefined' &&
+ (query.startsWith('select') || query.startsWith('SELECT'))) ||
+ query.trim().toLowerCase().startsWith('with pgrst_source'),
...options,
}
)
diff --git a/apps/studio/data/database/retrieve-index-from-select-query.ts b/apps/studio/data/database/retrieve-index-from-select-query.ts
index 050b0aedd25..06d80dddebc 100644
--- a/apps/studio/data/database/retrieve-index-from-select-query.ts
+++ b/apps/studio/data/database/retrieve-index-from-select-query.ts
@@ -109,10 +109,11 @@ export const useGetIndexesFromSelectQuery = <TData = GetInvolvedIndexesFromSelec
{
retry: false,
enabled:
- enabled &&
- typeof projectRef !== 'undefined' &&
- typeof query !== 'undefined' &&
- (query.startsWith('select') || query.startsWith('SELECT')),
+ (enabled &&
+ typeof projectRef !== 'undefined' &&
+ typeof query !== 'undefined' &&
+ (query.startsWith('select') || query.startsWith('SELECT'))) ||
+ query.trim().toLowerCase().startsWith('with pgrst_source'),
...options,
}
)