Skip to content

[P1][bug] EXPLAIN doesn't support EXPLAIN FORMAT=JSON or EXPLAIN FORMAT=TREE — only classic tabular format #424

Closed

Description

@EVWorth

Context

EXPLAIN in SQLPilot only supports the classic tabular format.

Problem

MySQL 5.6+ supports EXPLAIN FORMAT=JSON (returns nested JSON cost analysis — query_block.cost_info.query_cost, table_name.access_type, etc.) and MySQL 8.0.16+ supports EXPLAIN FORMAT=TREE (returns the iterator tree, which is what EXPLAIN ANALYZE actually outputs). The current code assumes classic tabular format. ARCHITECTURE §3.2 mentions "EXPLAIN [ANALYZE]" but doesn't explicitly mention FORMAT, though the trait signature is explain(connection_id, sql, analyze: bool) — no format param. Adding FORMAT=JSON support would surface real cost analysis (q_block, cost_info) which is far more useful than the tabular approximation.

Files

  • src/components/explain/ExplainPanel.tsx (no format detection)
  • src/stores/resultStore.ts:103-117 (no format param)

Repro

  1. EXPLAIN FORMAT=JSON SELECT * FROM users LIMIT 1
  2. EXPLAIN panel renders as text with red highlighting that doesn't match

Expected

A user can select "EXPLAIN FORMAT=JSON" from the toolbar and see the JSON cost breakdown with query_cost: 0.35, table_name.access_type: "ref", etc.

Proposed fix

(1) Add format: 'classic' | 'json' | 'tree' param to executeExplain and executeExplainAnalyze. (2) Render JSON with collapsible key-value tree. (3) Render TREE as the current AnalyzeView text. (4) Add a toolbar dropdown "Format: Classic / JSON / Tree" matching MySQL's syntax. Scope: M.

Acceptance

A user can select "EXPLAIN FORMAT=JSON" from the toolbar and see the JSON cost breakdown.

Needs human verify

yes

Doc drift

partial — ARCHITECTURE §3.2 trait signature has analyze: bool but no format

Activity

  1. added
    audit
    severity/p1
    kind/bug
    area/explain
    on Jul 31, 2026
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/explainauditkind/bugseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions