Skip to content

[P1][perf] parseExplainRows is invoked 3 times per render — once in ExplainTable, once in ExplainTreeView, once for maxRows #425

Closed

Description

@EVWorth

Context

ExplainPanel parses QueryResult rows into ExplainRow typed objects for rendering.

Problem

src/components/explain/ExplainPanel.tsx:155, 281, 384 — parseExplainRows(result) runs result.rows.map((row) => ...) and builds ExplainRow[] 3 times for the same result. With 100 rows this is 30k row iterations + 300 colNames.indexOf calls per render.

Files

  • src/components/explain/ExplainPanel.tsx:155, 281, 384

Repro

React DevTools Profiler shows 3x row-iteration cost per render of ExplainPanel.

Expected

With 100 EXPLAIN rows, a single render does ≤ 100 row iterations (not 300).

Proposed fix

Lift parseExplainRows(result) to ExplainPanel and pass the rows down as a prop. Or const rows = useMemo(() => parseExplainRows(result), [result]); at the top level, share with both views. Scope: S.

Acceptance

With 100 EXPLAIN rows, a single render does ≤ 100 row iterations (not 300). React DevTools Profiler confirms.

Needs human verify

no

Doc drift

no

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/perfseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions