KQ-2078 · QUERY/STAGES

Query Stages

A database query call shown as the stages it runs through, in the order the database runs them: as each finishes its clause lights, its bar narrows from the previous stage's width to its own on springs.snap and its row counter falls on snap, so the stack of bars reads as a funnel, while the running clause carries a sweeping underline and the result table unfolds beneath on springs.glide with its rows in a cascade once the last clause is done. Slow stages show their time and note, an empty result names the clause that removed the last rows, and a syntax error outlines its clause and underlines the token. Tab moves between the clauses and the table, and Enter on a clause opens the rows as they stood after it.

KQ-2078 · QUERY/STAGES

Coldbrook ops · which items are short in the North warehouses

run_querycoldbrook-stockStage 1 of 6
  1. Rows after FROM
    skuwarehouse_idon_handreorder_point
    CB-0731N-049220
    CB-2040S-116440
    CB-1182N-02112180

    and 48,207 more rows at this stage

  2. Rows after JOIN
    skuw.namew.regionon_hand
    CB-0731Harrow Yardnorth9
    CB-2040Kestrel Docksouth64
    CB-1182Millbrooknorth112

    and 48,207 more rows at this stage

  3. Rows after WHERE
    skuw.nameon_handreorder_point
    CB-0731Harrow Yard9220
    CB-1182Millbrook112180
    CB-2207Harrow Yard30200

    and 1,323 more rows at this stage

  4. 214 rows after GROUP BY. Rows at this stage aren’t kept; Explain shows the plan.

  5. 214 rows after SELECT. Rows at this stage aren’t kept; Explain shows the plan.

  6. 8 rows after ORDER BY. Rows at this stage aren’t kept; Explain shows the plan.

Result · 8 rows · 142 ms
Query result
skuitemshortfall
CB-0731Cold brew concentrate 1 L1,240
CB-1182Oat milk 1 L980
CB-2207Compostable lids 12 oz860
CB-0415Paper cups 12 oz720
CB-3310Filter papers, size 4540
CB-1406House blend beans 1 kg410
CB-2981Vanilla syrup 750 ml260
CB-0920Cardamom buns, frozen190

running · stage 1 · coldbrook stock

Install

One command — the source lands in your repo. Or copy it from the Code tab.

$ pnpm dlx shadcn@latest add @kinetiq/query-stages

Props

stageStyle
"funnel" | "bars" | "rail"
default "funnel"
Bars centred so the stack reads as a funnel, bars from the left like a chart, or a rail of stage nodes that fills as the query runs.
counterStyle
"roll" | "tally" | "share"
default "roll"
Rolling digit columns, a number that tallies down, or the share of the source rows with the count beneath.
accent
string
default "var(--accent-bright)"
Lit keywords, bars, the running underline and the table rule — any CSS colour.
source
{ tool: string; database: string }
default { tool: "run_query", database: "coldbrook-stock" }
The tool that ran the query and the database it ran on.
statement
string
default defaultQueryStatement
The statement as written; Copy writes it to the clipboard and Copy and Explain hand it over.
stages
QueryStage[]
default defaultQueryStages
The clauses in run order: id, clause (from, join, where, group, having, select, order, limit), text, rows left, ms, note and a sample of rows.
columns
QueryColumn[]
default defaultQueryColumns
The result's columns: key, label, align, width, and hideNarrow to drop one on a phone.
rows
QueryRow[]
default defaultQueryRows
The result rows.
status
"loading" | "running" | "done" | "error"
default "done"
Where the call is. Rendered done, the view arrives finished with no travel.
completed
number
default stages.length
How many stages have finished while running; the next one is lit as running.
error
QueryStagesError | null
default null
A syntax error with status "error": the stage id, the message, the token to underline and the line.
slowMs
number
default 1000
A stage slower than this is marked slow and shows its note, in ms.
onRerun
() => void
default —
Re-run in the header.
onOpenResult
(rows: QueryRow[]) => void
default —
Open in the result's header, with every row.
onCopyQuery
(statement: string) => void
default —
Copy in the header, with the statement.
onExplain
(statement: string) => void
default —
Explain in the header, with the statement.
onInspectStage
(stage: QueryStage) => void
default —
Enter or a click opened a finished stage's rows.
format
(n: number) => string
default en-US grouping
Formats every row count and number cell.
tableRows
number
default 4
Result rows visible before the table scrolls inside its own region.
label
string
default "<tool> on <database>"
The view's accessible name.
className
string
default —
Classes for the outer surface.