Skip to content

Commit 4a965cf

Browse files
authored
Fix error research execution plan (#214)
* Add query explanation diagram components * Enhance query explanation diagram: improve table block styling and remove debug log
1 parent bb6be3e commit 4a965cf

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/components/gui/query-explanation-diagram/buildQueryExplanationFlow.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ export function buildQueryExplanationFlow(item: ExplanationMysql) {
150150
},
151151
animated: true,
152152
});
153+
154+
return getLayoutedExplanationElements(nodes, edges, "RL");
153155
}
154156

155157
if (!table && nested_reverse.length > 0) {

src/components/gui/query-explanation-diagram/node-type/nested-loop.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { BaseHandle } from "@/components/base-handle";
44
import { ExplainNodeProps, formatCost } from "../buildQueryExplanationFlow";
55

66
export function NestedLoop(props: ExplainNodeProps) {
7-
console.log(props.data)
87
return (
98
<Tooltip>
109
<TooltipTrigger asChild>

src/components/gui/query-explanation-diagram/node-type/table-block.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ import { Position } from "@xyflow/react";
44
import { ExplainNodeProps, formatCost } from "../buildQueryExplanationFlow";
55

66
export function TableBlock(props: ExplainNodeProps) {
7+
let bgColor = 'bg-emerald-700';
8+
let label = 'Unique Key Lookup';
9+
10+
if (props.data.access_type === 'ALL') {
11+
bgColor = 'bg-rose-700';
12+
label = 'Full Table Scan'
13+
}
14+
15+
if (props.data.access_type === 'range') {
16+
bgColor = 'bg-yellow-700';
17+
label = 'Index Range Scan';
18+
}
19+
20+
if (props.data.access_type === 'ref') {
21+
label = 'Non-Unique Key Lookup'
22+
}
23+
724
return (
825
<Tooltip>
926
<TooltipTrigger asChild>
@@ -18,8 +35,8 @@ export function TableBlock(props: ExplainNodeProps) {
1835
<div><small>{formatCost(Number(props.data.cost_info.read_cost) + Number(props.data.cost_info.eval_cost))}</small></div>
1936
<div><small>{formatCost(Number(props.data.rows_examined_per_scan))} rows</small></div>
2037
</div>
21-
<div className={`p-2 text-white text-[9pt] border-b rounded-md text-center ${props.data.access_type === 'ALL' ? 'bg-rose-700' : 'bg-emerald-700'}`}>
22-
<small>{props.data.access_type === 'ALL' ? 'Full Table Scan' : props.data.access_type === 'eq_ref' ? 'Unique Key Lookup' : 'Non-Unique Key Lookup'}</small>
38+
<div className={`p-2 text-white text-[9pt] border-b rounded-md text-center ${bgColor}`}>
39+
<small>{label}</small>
2340
</div>
2441
<div className="flex flex-col justify-center text-[8pt] items-center">
2542
<div>

0 commit comments

Comments
 (0)