mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Context We previously added a "Related resources" section in Cmd+K if you're on the Table Editor with a table opened, this included resources pertaining to the table such as policies, triggers, and functions. We're adding indexes as well in this PR - thinking that might also be appropriate to have in this context <img width="500" alt="image" src="https://github.com/user-attachments/assets/5cd383ff-6617-49ba-bdb8-6f65d8fd0680" /> ## Performance Benchmarked with Claude against the stress catalog (`PG_META_STRESS_TABLES=12000`), with master and this branch timed in the same run on the same database, median of 9. | Table | master | This PR | Worst of 9 | |---|---|---|---| | Hub table — 8 indexes, policy, many FK triggers | 1.6 ms | 2.3 ms | 2.8 ms | | Policy + user trigger | 1.0 ms | 1.3 ms | 2.0 ms | | Mid-chain table | 1.1 ms | 1.5 ms | 1.7 ms | | Deliberately over-indexed table — 20 indexes | 0.8 ms | 2.0 ms | 4.6 ms | | Table that doesn't exist | 1.1 ms | 1.5 ms | 4.5 ms |
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
type EntityLocation = { id: number; schema: string }
|
|
|
|
function getDatabaseEditRoute({
|
|
projectRef,
|
|
page,
|
|
schema,
|
|
edit,
|
|
}: {
|
|
projectRef: string
|
|
page: string
|
|
schema: string
|
|
edit: string | number
|
|
}): `/${string}` {
|
|
const params = `schema=${encodeURIComponent(schema)}&edit=${encodeURIComponent(String(edit))}`
|
|
return `/project/${projectRef}/database/${page}?${params}`
|
|
}
|
|
|
|
export function getTableEditorRoute(projectRef: string, table: EntityLocation): `/${string}` {
|
|
return `/project/${projectRef}/editor/${table.id}?schema=${encodeURIComponent(table.schema)}`
|
|
}
|
|
|
|
export function getPolicyEditorRoute(projectRef: string, policy: EntityLocation): `/${string}` {
|
|
return getDatabaseEditRoute({
|
|
projectRef,
|
|
page: 'policies',
|
|
schema: policy.schema,
|
|
edit: policy.id,
|
|
})
|
|
}
|
|
|
|
export function getTriggerEditorRoute(projectRef: string, trigger: EntityLocation): `/${string}` {
|
|
return getDatabaseEditRoute({
|
|
projectRef,
|
|
page: 'triggers/data',
|
|
schema: trigger.schema,
|
|
edit: trigger.id,
|
|
})
|
|
}
|
|
|
|
export function getFunctionEditorRoute(projectRef: string, fn: EntityLocation): `/${string}` {
|
|
return getDatabaseEditRoute({ projectRef, page: 'functions', schema: fn.schema, edit: fn.id })
|
|
}
|
|
|
|
export function getIndexEditorRoute(
|
|
projectRef: string,
|
|
index: { name: string; schema: string }
|
|
): `/${string}` {
|
|
return getDatabaseEditRoute({
|
|
projectRef,
|
|
page: 'indexes',
|
|
schema: index.schema,
|
|
edit: index.name,
|
|
})
|
|
}
|