Skip to content

audit: EXPLAIN visualizer #411

Closed
Closed

Description

@EVWorth

Status: filed
Drives: docs/audits/explain.md

Findings

Critical (P0/P1)

Backlog (P2/P3)

  • F10 [P2] [perf] ExplainTable renders all 12 columns always — wide tables overflow horizontally without scroll on smaller viewports
  • F11 [P2] [doc-drift] ARCHITECTURE §5.2 explain_query Tauri command promised but unimplemented
  • F12 [P2] [test] ExplainPanel.test.tsx doesn't test buildTree or parseExplainRows edge cases
  • F13 [P3] [bug] ExplainPanel doesn't handle EXPLAIN ANALYZE FORMAT=JSON output — renders as raw text with red highlighting
  • F14 [P3] [perf] ExplainTable and ExplainTreeView re-render all rows on viewMode change
  • F15 [P3] [convention] TYPE_RANK defines rank for "NULL" (= 7) but the legend filters it out — unused field (went away with the F8 cleanup)
  • F16 [P3] [arch] ExplainPanel.tsx is 558 LOC with 9+ sub-components in one file

Good (👍)

  • Three complementary views: Table / Tree / ANALYZE
  • parseExplainRows lowercases column names defensively
  • Access-type color legend in toolbar (worst → best)
  • Extra column highlights with 5 distinct keywords
  • RowsBar visualises row-estimate scale
  • KeyHighlight matches used key against possible_keys
  • Reads from useResultStore (clean Zustand integration)
  • 20+ tests cover rendering, colors, highlights, view modes
  • Graceful fallback for unknown access types
  • MariaDB detection for ANALYZE

Doc drift

  • DESIGN_REQUIREMENTS FR-2.2.5 ("cost annotations") not delivered (needs FORMAT=JSON — F6)
  • DESIGN_REQUIREMENTS FR-10.2.2 partially delivered (colors + tree + cost ❌)
  • ARCHITECTURE §3.2 trait signature has no format param
  • ARCHITECTURE §5.2 explain_query command unimplemented — F11
  • TESTING_STRATEGY has one e2e for EXPLAIN but no integration tests for parsing

Status — 2026-08-28

F1–F5 and F7–F9 are fixed and merged: #512 (safety), #515 (rendering + test infra), #514 (polish). F6 (#424) is deliberately left open — it is a feature rather than a fix, and it is what would deliver the FR-2.2.5 cost annotations tracked as doc-drift in #459.

Three things found during the work that the audit did not have:

  • F5's premise was wrong. A UNION's inner SELECTs do not both have id=1; MySQL numbers them 1 and 2 and adds a UNION RESULT row naming its members as <union1,2>. The tree is now built from those explicit references. Test cases are transcribed from real server output.
  • MariaDB's ANALYZE returned nothing at all. The executor decided "does this return rows?" by matching a verb, and ANALYZE was not in the list, so the rows were accumulated and then discarded. F4's wall-of-text report was a symptom above this. WITH ... SELECT was losing its rows the same way, which affected every query path. Fixed in fix(explain): read the plan the server actually returns #515.
  • A write hidden behind a CTE still ran under ANALYZE. WITH doomed AS (...) DELETE FROM t is valid MySQL 8; the first fix for F1 read only the leading keyword, saw WITH, and let it execute. Caught in review before merge and fixed in fix(explain): stop EXPLAIN ANALYZE running writes, and make timeouts real #512, which now reads the verb a statement actually acts on.

This backlog (F10–F14, F16) is still open.

Activity

  1. added
    audit
    area/explain
    on Jul 31, 2026
  2. EVWorth commented on Sep 12, 2026

    @EVWorth
    OwnerAuthor

    EXPLAIN visualizer is clear.

    #412–#423, #425–#427 closed earlier: the ANALYZE-executes-writes problem, MariaDB's tabular ANALYZE shape, the per-render reparsing, the missing cancel affordance
    #424 no FORMAT=JSON or FORMAT=TREE done in #657

    What #657 added

    A Format picker that re-plans the last statement as the tabular plan, the optimiser's JSON cost model, or MySQL's iterator tree. JSON renders as a collapsible tree with the cost and row keys picked out — in a plan for a real query query_cost is four levels down, and pretty-printed text buries it.

    The combinations the servers do not have are resolved in Rust rather than left to fail, since an error where a plan should be is a worse answer than the plan you can have: MariaDB has no FORMAT=TREE (error 1791) and gets the tabular plan; MySQL before 8.3 cannot combine ANALYZE with JSON (error 1235) and gets the plan without timings; MariaDB's ANALYZE FORMAT=JSON does carry them. Every row of that was run against MySQL 8.0.46 and MariaDB 11.8 before being written down.

    And one thing the audit could not have known

    Running this suite against MariaDB for the first time found a bug that is not about EXPLAIN at all: a timed-out statement never gave its connection back, so pool_max timeouts exhausted the pool, after which query_timeout_secs silently stopped working and disconnect hung for ever. MySQL happened to recover, which is why every test in the tree missed it. Filed as #658.

    That is the argument for running the integration suites against both servers rather than one; MAS_TEST_PORT=13308 now does that for the files touched so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/explainaudit

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions