DB workbench
Workbench
The DB Engine’s chat surface. Lives at /db.
Asking a question
- Pick a connection from the rail (only granted ones appear).
- Type a question in plain English: “average days-in-A/R by payer in Q1 2026”.
- Pollen8:
- Embeds your question.
- Retrieves the top-K most-relevant tables from the connection’s introspected schema.
- Asks the planner LLM to write SQL that answers the question using only those tables.
- Validates the SQL through sqlglot — SELECT-only, no dangerous statements, row-cap injected, scope predicates AND’d in.
- Runs EXPLAIN preflight to estimate cost; blocks queries that would scan billions of rows.
- Executes via the driver. Statement timeout 30s.
- Surface shows: the SQL, the result table, and a chart spec inferred from the answer shape.
Three result views
- Table — the rows as returned.
- Chart — auto-picked from the data shape (line if there’s a time axis, bar if there’s a category column + a metric, donut for simple breakdowns, scatter for two metrics).
- SQL — the generated SQL. Editable — tweak and re-run.
Edit the SQL
Click into the SQL panel → the generated SQL becomes editable. Hit run → goes through the same validator + EXPLAIN preflight as the planner-generated path. You can’t sneak past the validator by hand-editing.
History
Every workbench query persists to a per-user history drawer. Click any prior question to re-open it with the SQL + chart spec.
Send to BI
Click Send to BI on any result to materialize it as a widget on a BI dashboard. The widget carries the connection id + the SQL + the chart spec; refreshing the widget re-runs the SQL.
Common patterns
- Time-series: “Daily new patients last 90 days” → line chart.
- Breakdown: “Encounters by provider this quarter” → bar.
- Cohort: “Patients with A1c > 9 in last visit” → table you can send to BI as a watchlist.
- Ratio: “First-pass rate by payer” → bar + KPI tile if you also Send to BI.
When NL→SQL fails
The planner returns “I couldn’t write SQL for that” when:
- The question is too vague (“how are we doing?”).
- The relevant tables aren’t introspected — re-introspect the schema.
- The question is structurally outside DB scope (cross-connection JOINs, write operations).
Re-phrase or switch the connection.