diff --git a/apps/studio/components/interfaces/QueryPerformance/QueryCosts.tsx b/apps/studio/components/interfaces/QueryPerformance/QueryCosts.tsx index 7c92044d09d..197ab6ea489 100644 --- a/apps/studio/components/interfaces/QueryPerformance/QueryCosts.tsx +++ b/apps/studio/components/interfaces/QueryPerformance/QueryCosts.tsx @@ -24,17 +24,29 @@ export const QueryCosts = ({

Currently:

-

{currentCost.toFixed(2)}

+

+ {typeof currentCost === 'number' && !isNaN(currentCost) && isFinite(currentCost) + ? currentCost.toFixed(2) + : 'N/A'} +

- {improvedCost && ( -
-

With index:

-
-

{improvedCost.toFixed(2)}

- {improvement &&

↓ {improvement.toFixed(1)}%

} + {improvedCost && + typeof improvedCost === 'number' && + !isNaN(improvedCost) && + isFinite(improvedCost) && ( +
+

With index:

+
+

{improvedCost.toFixed(2)}

+ {improvement && + typeof improvement === 'number' && + !isNaN(improvement) && + isFinite(improvement) && ( +

↓ {improvement.toFixed(1)}%

+ )} +
-
- )} + )}
diff --git a/apps/studio/components/interfaces/QueryPerformance/QueryDetail.tsx b/apps/studio/components/interfaces/QueryPerformance/QueryDetail.tsx index 2daa81f7149..d22830df4dd 100644 --- a/apps/studio/components/interfaces/QueryPerformance/QueryDetail.tsx +++ b/apps/studio/components/interfaces/QueryPerformance/QueryDetail.tsx @@ -76,10 +76,17 @@ export const QueryDetail = ({ {report .filter((x) => x.id !== 'query') .map((x) => { + const rawValue = selectedRow?.[x.id] const isTime = x.name.includes('time') + const formattedValue = isTime - ? `${selectedRow?.[x.id].toFixed(2)}ms` - : String(selectedRow?.[x.id]) + ? typeof rawValue === 'number' && !isNaN(rawValue) && isFinite(rawValue) + ? `${rawValue.toFixed(2)}ms` + : 'N/A' + : rawValue != null + ? String(rawValue) + : 'N/A' + return (

{x.name}

diff --git a/apps/studio/components/interfaces/QueryPerformance/QueryPanel.tsx b/apps/studio/components/interfaces/QueryPerformance/QueryPanel.tsx index 9852385a20b..4cee87a3ece 100644 --- a/apps/studio/components/interfaces/QueryPerformance/QueryPanel.tsx +++ b/apps/studio/components/interfaces/QueryPerformance/QueryPanel.tsx @@ -69,7 +69,7 @@ export const QueryPanelScoreSection = ({ ) : ( )} - {before !== 0 && ( + {typeof before === 'number' && before !== 0 && !isNaN(before) && isFinite(before) && (

{formattedValue}

- {isTime &&

{(value / 1000).toFixed(2)}s

} + {isTime && typeof value === 'number' && !isNaN(value) && isFinite(value) && ( +

{(value / 1000).toFixed(2)}s

+ )}
) },