You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][bug] buildTree groups EXPLAIN rows by id and treats all same-id rows as siblings — UNION queries produce wrong nesting #423
ExplainPanel's tree-view reconstructs a tree from tabular EXPLAIN rows.
Problem
src/components/explain/ExplainPanel.tsx:282-315 (buildTree) groups rows by id and treats all same-id rows as siblings. MySQL EXPLAIN for a UNION produces rows with same id but in different tree positions. For SELECT 1 UNION SELECT 2 EXPLAIN, both inner SELECTs have id=1; both render as flat top-level nodes (wrong). For a subquery (SELECT * FROM a) sub EXPLAIN, the outer SELECT and inner SELECT have different ids (e.g., 1 and 2), so the inner becomes a child of outer — correct for this case. The UNION case is the broken one. ARCHITECTURE §3.2 doesn't explicitly require correct UNION tree representation, but the tree view is the "visual" feature promised by FR-10.2.2.
Tree view shows 2 flat nodes — they should nest under a UNION parent
Expected
SELECT 1 UNION SELECT 2 renders as a single root node with 2 leaf children. SELECT * FROM (SELECT * FROM a) sub renders as a parent (a) and child (subquery).
Proposed fix
Build a proper parent-child tree from id and the table column: a row's parent is the previous row whose id is strictly less than this row's id (standard MySQL EXPLAIN convention). Or use EXPLAIN FORMAT=TREE (MySQL 8.0.16+) and parse that — it's a proper tree. Scope: M.
Acceptance
SELECT 1 UNION SELECT 2 renders as a single root node with 2 leaf children. SELECT * FROM (SELECT * FROM a) sub renders as a parent (a) and child (subquery). The user can visually trace which table the optimiser touched first.
Activity
fix(explain): read the plan MySQL actually returns
fix(explain): read the plan MySQL actually returns
fix(explain): read the plan the server actually returns (#515)