Files
supabase/apps/studio/components/interfaces/QueryPerformance/IndexImprovementText.tsx
Jonathan Summers-Muir 2815dac7e0 Feat/index suggestions inline (#35107)
* init

* hovercard

* adds button to install index advisor

* hover card now now insert indexes

* update

* moved hook

* align alert dialog to design syste,

* Update index-advisor.utils.ts

* shows all index statements now

* Update query-performance.tsx

* Some refactors

* Clean up

* Fix

* One last nit refactor

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-05-07 19:09:58 +08:00

29 lines
824 B
TypeScript

import { HTMLAttributes } from 'react'
import { cn } from 'ui'
import { calculateImprovement } from './index-advisor.utils'
interface IndexImprovementTextProps extends HTMLAttributes<HTMLParagraphElement> {
indexStatements: string[]
totalCostBefore: number
totalCostAfter: number
}
export const IndexImprovementText = ({
indexStatements,
totalCostBefore,
totalCostAfter,
className,
...props
}: IndexImprovementTextProps) => {
const improvement = calculateImprovement(totalCostBefore, totalCostAfter)
return (
<p className={cn('text-sm text-foreground-light', className)} {...props}>
Query's performance can be improved by{' '}
<span className="text-brand">{improvement.toFixed(2)}%</span> by creating this{' '}
{indexStatements.length > 1 ? 'indexes' : 'index'}:
</p>
)
}