import { AlertCircle, CheckCircle } from 'lucide-react' import { AccordionTrigger } from '@ui/components/shadcn/ui/accordion' import { useParams } from 'common' import { AccordionContent_Shadcn_, AccordionItem_Shadcn_, Accordion_Shadcn_ } from 'ui' import { PRESET_CONFIG } from '../Reports/Reports.constants' import { Presets } from '../Reports/Reports.types' import { queriesFactory } from '../Reports/Reports.utils' interface IndexEfficiencyNoticeProps { isLoading: boolean } // [Joshen] Currently not used, might be deprecated - just double checking first export const IndexEfficiencyNotice = ({ isLoading }: IndexEfficiencyNoticeProps) => { const { ref: projectRef } = useParams() const config = PRESET_CONFIG[Presets.QUERY_PERFORMANCE] const hooks = queriesFactory(config.queries, projectRef ?? 'default') const queryHitRate = hooks.queryHitRate() const indexHitRate = queryHitRate.data?.[0]?.ratio const tableHitRate = queryHitRate.data?.[1]?.ratio const showIndexWarning = indexHitRate && tableHitRate && (indexHitRate <= 0.99 || tableHitRate <= 0.99) const checkAlert = const warnAlert = const dangerAlert = return ( Index Efficiency {showIndexWarning ? warnAlert : checkAlert} {!isLoading && queryHitRate && ( Index Hit Rate {indexHitRate >= 0.99 ? checkAlert : indexHitRate >= 0.95 ? warnAlert : dangerAlert} {queryHitRate?.data && (queryHitRate?.data[0]?.ratio * 100).toFixed(2)} % {queryHitRate?.data![1]?.name == 'table hit rate' && 'Table Hit Rate'} {tableHitRate >= 0.99 ? checkAlert : tableHitRate >= 0.95 ? warnAlert : dangerAlert} {queryHitRate?.data && (queryHitRate?.data[1]?.ratio * 100).toFixed(2)} % For best performance, ensure that the cache hit rate ratios above 99%. {' '} Consider upgrading to an instance with more memory if the ratios dip below 95%. )} ) }
Index Hit Rate
For best performance, ensure that the cache hit rate ratios above 99%. {' '} Consider upgrading to an instance with more memory if the ratios dip below 95%.