Files
supabase/apps/studio/components/interfaces/QueryPerformance/QueryPerformance.constants.ts
T
Taishi 97b631fff7 Add SQL syntax highlighting to Query Performance page (#38386)
* Add CodeBlock for SQL query display to add syntax highlight

* use monaco editor for better highlighting

* create `SqlMonacoBlock` component for SQL in detail panel

* add mean_time to most_time_comsuming queries

* make outline transparent

* Add keyboard navigation for query performance grid

* Stop default RDG behavior on arrow key navigation

* Update column minWidth values to remove horizontal scrollbar

* Load SqlMonacoBlock and Editor client-side only

- following a pattern in `SQLEditor.tsx`
2025-09-05 00:20:05 +00:00

43 lines
2.5 KiB
TypeScript

export enum QUERY_PERFORMANCE_REPORT_TYPES {
MOST_TIME_CONSUMING = 'most_time_consuming',
MOST_FREQUENT = 'most_frequent',
SLOWEST_EXECUTION = 'slowest_execution',
}
export const QUERY_PERFORMANCE_PRESET_MAP = {
[QUERY_PERFORMANCE_REPORT_TYPES.MOST_TIME_CONSUMING]: 'mostTimeConsuming',
[QUERY_PERFORMANCE_REPORT_TYPES.MOST_FREQUENT]: 'mostFrequentlyInvoked',
[QUERY_PERFORMANCE_REPORT_TYPES.SLOWEST_EXECUTION]: 'slowestExecutionTime',
} as const
export const QUERY_PERFORMANCE_REPORTS = {
[QUERY_PERFORMANCE_REPORT_TYPES.MOST_TIME_CONSUMING]: [
{ id: 'query', name: 'Query', description: undefined, minWidth: 600 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: undefined },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: 60 },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 150 },
{ id: 'prop_total_time', name: 'Time consumed', description: undefined, minWidth: 110 },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: 80 },
],
[QUERY_PERFORMANCE_REPORT_TYPES.MOST_FREQUENT]: [
{ id: 'query', name: 'Query', description: undefined, minWidth: 600 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: undefined },
{ id: 'avg_rows', name: 'Avg. Rows', description: undefined, minWidth: undefined },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: undefined },
{ id: 'max_time', name: 'Max time', description: undefined, minWidth: undefined },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: undefined },
{ id: 'min_time', name: 'Min time', description: undefined, minWidth: undefined },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 180 },
],
[QUERY_PERFORMANCE_REPORT_TYPES.SLOWEST_EXECUTION]: [
{ id: 'query', name: 'Query', description: undefined, minWidth: 600 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: undefined },
{ id: 'avg_rows', name: 'Avg. Rows', description: undefined, minWidth: undefined },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: undefined },
{ id: 'max_time', name: 'Max time', description: undefined, minWidth: undefined },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: undefined },
{ id: 'min_time', name: 'Min time', description: undefined, minWidth: undefined },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 180 },
],
} as const