tpaw Docs

Query Editor

Write, execute, and manage SQL queries in tpaw using the Monaco-based editor with PostgreSQL autocomplete.

The Query Editor is a Monaco-based SQL editor with PostgreSQL-aware syntax highlighting, schema-driven autocomplete, multi-statement execution, EXPLAIN visualization, and integrated saved queries. Press Cmd+T to open a new editor tab from anywhere in the app.

Running queries

ShortcutAction
Cmd+EnterExecute the current statement (cursor position determines which statement runs)
Cmd+Shift+EnterExecute all statements in the editor
Cmd+IFormat SQL (auto-format entire file or selection)
Cmd+/Toggle line comment (--)

Single-statement execution

Cmd+Enter runs the statement under the cursor. tpaw determines statement boundaries by parsing the SQL, so you can have multiple statements in one editor and run them one at a time by placing the cursor inside the one you want.

Multi-statement execution

Cmd+Shift+Enter runs all statements sequentially. Each result appears in a collapsible block showing:

  • Statement number and primary keyword (SELECT, INSERT, etc.)
  • Row count and execution time
  • Full result table (expandable)

If any statement fails, execution stops at that statement. All previous results are preserved alongside the error block.

Autocomplete

The editor provides autocomplete for:

  • Table and view names from the connected schema
  • Column names (appears after . or inside WHERE, SELECT)
  • PostgreSQL reserved keywords
  • Saved variable names (${...})

Reserved-word handling: Tables with reserved-word names (like user, order, group) are schema-qualified and double-quoted in autocomplete suggestions — e.g., typing "user" inserts public."user" to avoid parser errors.

Autocomplete is scoped to the active connection's schema. Switching connections updates the completion provider automatically.

Query history

Every executed query is recorded in history. To browse history, click the History button in the toolbar. The history panel shows:

  • Date-grouped timeline (Today, Yesterday, This Week, etc.)
  • Execution time badges with color coding (green < 100ms, yellow < 1s, red > 1s)
  • Success/error icons with inline error messages for failed queries
  • Open in Editor action to reload any historical query

EXPLAIN visualizer

Click Explain in the toolbar (or type EXPLAIN before your query) to run EXPLAIN (FORMAT JSON) and visualize the query plan:

  • Interactive plan tree with cost-colored nodes
  • Each node shows: Node Type, Estimated Cost, Row Estimate, Actual Time
  • Summary bar with Planning Time and Execution Time

Query formatting

Press Cmd+I to auto-format the SQL in the editor (or select a region first to format only that selection). Formatting normalizes whitespace and keyword casing.

What's in this section

  • Mutation Mode — Confirmation dialog for destructive queries
  • Visual EXPLAIN — Interactive plan tree for analyzing query performance

On this page