import { Loader2 } from 'lucide-react' import { AiIconAnimation, Button, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui' import type { ClassifiedQuery } from '../QueryInsightsHealth/QueryInsightsHealth.types' import { ISSUE_DOT_COLORS, ISSUE_ICONS } from './QueryInsightsTable.constants' import { formatDuration, getColumnName, getTableName } from './QueryInsightsTable.utils' interface QueryInsightsTableRowProps { item: ClassifiedQuery onRowClick?: () => void onGoToLogs?: () => void onCreateIndex?: () => void onExplain?: () => void onAiSuggestedFix?: () => void isExplainLoading?: boolean } export const QueryInsightsTableRow = ({ item, onRowClick, onGoToLogs, onCreateIndex, onExplain, onAiSuggestedFix, isExplainLoading, }: QueryInsightsTableRowProps) => { const IssueIcon = item.issueType ? ISSUE_ICONS[item.issueType] : null return (
{item.issueType && IssueIcon && (
)}

{item.queryType ?? '–'} {getTableName(item.query) && ( <> {' '} in {getTableName(item.query)} )} {getColumnName(item.query) && ( <> , {getColumnName(item.query)} )}

{item.hint}

= 1000 && 'text-destructive-600' )} > {formatDuration(item.mean_time)} avg
Average execution time per call. High mean time means individual runs are slow — directly felt by users.
{item.prop_total_time.toFixed(1)}% of db
Percentage of total database execution time. Fixing high-impact queries has the biggest overall effect on your database.
{item.calls.toLocaleString()} calls
Number of times this query ran in the selected time window.
{(item.issueType === 'index' || item.issueType === 'slow') && ( )} {item.issueType === 'index' && ( )} {(item.issueType === 'error' || item.issueType === 'slow') && ( )}
) }