Files
supabase/apps/studio/components/interfaces/QueryPerformance/QueryPerformance.constants.ts
T
kemal.earthandJoshen Lim 1bb9453b0c feat(studio): update query performance table ui (#38523)
* feat: tidy up query perf column headers

* feat: update col widths and which ones are sortable

This gives a reasonable column width to all cols as well as adds an option for us to filter out which columns we dont want to make the table sortable by.

* feat: column order and word wrapping for query

* feat: column data text align for numbers

* fix: pointer event was preventing index advisor icon popover

* feat: use code block instead of editor

Swapped Editor out for Code block as its less expensive and modified it to add pgsql syntax highlighting

* fix: small truncation issue

* chore: remove unused sort function

* fix: sort menu closing on first click

Sort menu of a column no longer disappears on first click

* feat: move sorting and ordering over to nuqs

This removes the usage of Next Router params and uses Nuqs instead for managing the QP table sorting and ordering.

* feat: add clear sorting button to filter bar

* chore: remove unused files

* fix: add highlighting for selected sort

* Nit update sort

* nit: smol styling update for direction

* feat: inian feedback on time based numbers

* fix: return number instead of string for total time

We were returning a string for total time percentage which meant the sorting was a little bit off

* Shift roles to nuqs

* chore: clean up

* fix: smaller viewport filter bar

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-09-10 17:40:25 +01:00

43 lines
2.4 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: 500 },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: 100 },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 150 },
{ id: 'prop_total_time', name: 'Time consumed', description: undefined, minWidth: 150 },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: 150 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: 120 },
],
[QUERY_PERFORMANCE_REPORT_TYPES.MOST_FREQUENT]: [
{ id: 'query', name: 'Query', description: undefined, minWidth: 500 },
{ id: 'avg_rows', name: 'Avg. Rows', description: undefined, minWidth: 100 },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: 100 },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 150 },
{ id: 'max_time', name: 'Max time', description: undefined, minWidth: 150 },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: 150 },
{ id: 'min_time', name: 'Min time', description: undefined, minWidth: 150 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: 120 },
],
[QUERY_PERFORMANCE_REPORT_TYPES.SLOWEST_EXECUTION]: [
{ id: 'query', name: 'Query', description: undefined, minWidth: 500 },
{ id: 'avg_rows', name: 'Avg. Rows', description: undefined, minWidth: 100 },
{ id: 'calls', name: 'Calls', description: undefined, minWidth: 100 },
{ id: 'total_time', name: 'Total time', description: 'latency', minWidth: 150 },
{ id: 'max_time', name: 'Max time', description: undefined, minWidth: 150 },
{ id: 'mean_time', name: 'Mean time', description: undefined, minWidth: 150 },
{ id: 'min_time', name: 'Min time', description: undefined, minWidth: 150 },
{ id: 'rolname', name: 'Role', description: undefined, minWidth: 120 },
],
} as const