SQL Editor
Each query tab has a CodeMirror 6 editor tuned for the ElyraSQL dialect.
Writing and running
- Syntax highlighting and schema-aware autocomplete (keywords, tables and columns from the active database's cached schema).
- ⌘/Ctrl + Enter (or Run) runs the selection if you have one,
otherwise the statement at the cursor — so a file of fifteen queries
can be run one at a time without selecting anything. The cursor right
after a
;, or on the blank line below, counts as that statement. Statements are found exactly as a run splits them: quotes, comments andDELIMITERblocks included. - ⌘/Ctrl + Shift + Enter (or Run all) runs every statement in the editor.
- Multiple statements produce multiple result sets, each with timing, row count and affected rows.
- ⌘/Ctrl + / toggles line comments.
Try run: change, look, then decide
Try run (next to Run all; Pro) opens a transaction on its own connection
and keeps it open. Run an UPDATE or DELETE as usual, then SELECT from
the table: you see it as it now is, from inside the transaction, while
everyone else still sees it as it was. Then:
- Commit keeps it. On a production connection this asks again — the commit is the real write.
- Roll back throws it away.
- Doing nothing throws it away too: the bar counts down, and after one minute the sandbox rolls itself back, so a forgotten transaction cannot hold row locks against staging or production. +1 min extends it, up to ten minutes ahead. Closing the tab, disconnecting or quitting rolls back as well.
A sandbox runs SELECT, INSERT, REPLACE, UPDATE, DELETE, EXPLAIN,
DESCRIBE and SHOW. DDL (ALTER, CREATE, DROP, TRUNCATE), SET,
LOCK, CALL and COMMIT/ROLLBACK typed into the editor are refused: on
MySQL-family servers each of those commits the open transaction on the spot,
and a sandbox that quietly kept everything would be worse than none. A
statement that fails leaves the sandbox open with what came before it; a
deadlock, Stop, or a statement timeout rolls it back, and the message says
so. Statements run in a sandbox appear in History marked ⎌.
ClickHouse has no transactions, so it has no Try run.
Parameters
Write :name where a value changes from one run to the next, and a field for
it appears above the editor:
SELECT * FROM orders
WHERE customer_id = :customer
AND placed_at >= :since
AND status IN (:statuses)
Each parameter has a kind beside its field:
| Kind | Goes into the SQL as | Example value |
|---|---|---|
| text | a quoted string, escaped for the engine | 2024-05-01 → '2024-05-01' |
| number | the number itself — refused unless it is plainly one | 42 |
| NULL | NULL |
— |
| list | comma-separated values for IN (…): numbers if all are, strings otherwise |
paid, shipped → 'paid', 'shipped' |
The kind follows what you type — a number becomes number — until you
pick one. Values are filled in when the query runs (⌘↵, also from a
parameter field) and for Explain. The confirmation, the row count and the
history all show the SQL as it ran, and the tab keeps the :name version, as
does Save. A parameter with no value, or a number that is not one,
stops the run and names it.
Only a : directly followed by a name counts, and never inside a string or a
comment. MySQL's @x := 1, :: casts, ClickHouse's own {name:Type}
parameters and a:b are left alone. Compare and saved checks run the SQL
as written, so give them literal values.
Warnings as you type
While you write, the editor underlines what is almost always a mistake, and says why on hover:
| Underlined | Why |
|---|---|
UPDATE or DELETE with no WHERE |
It changes or removes every row in the table |
JOIN with no ON or USING, or tables listed with commas and no WHERE |
Every row is paired with every row. Write CROSS JOIN if that is meant |
= NULL, <> NULL |
Never true. Use IS NULL / IS NOT NULL |
| A table or column the database does not have | With the nearest name it does have: did you mean email? |
| SQL this engine is known to reject | ElyraSQL: GROUPING SETS, CUBE, CUME_DIST(), PERCENT_RANK(). SQLite: WITH ROLLUP. ClickHouse: a plain UPDATE |
It stays quiet about anything it cannot be sure of. A statement it cannot
read is left alone, because the engine may well accept it. A column is checked
only against tables whose columns are all known. Nothing from a subquery or
another database is checked, and nothing in GROUP BY, HAVING or ORDER BY,
where a name may be a select alias. The schema is read from the database at most
every 30 seconds, and nothing is run.
Turn it off under Settings → General → Check SQL as you type.
When a query fails
The server's own message is always shown. With Error help switched on (⌘/Ctrl + , → Error help), the app also works out what kind of failure it was and offers the matching next step — the columns of the table for an unknown column, user administration for a missing privilege, the timeout setting for a statement that ran too long, Try again for something that might just have been bad timing.
The one worth knowing about is "this engine does not implement that". The SQL is valid elsewhere, nothing in the message says to rewrite it, and it is easy to lose ten minutes hunting a typo that is not there. That case gets its own hint and a shortcut to the assistant.
The hint sits beside the error, never instead of it, and appears only when the classification was confident. When the cause is genuinely ambiguous the app stays quiet rather than suggesting the wrong thing.
What is sent
The error message and the name of the engine. Nothing else — not your statement, not your schema, not a row. Every engine names the offending column or table in the message itself, which is what makes that enough.
It goes to TypeSafe, whose Jev model returns a category rather than prose — which is why the app can turn the answer into a button. You need your own TypeSafe key; it is stored in the OS keychain alongside your database passwords. Without a key the feature is simply off and errors display as they always did.
Compare runs: pin and diff
Watching what changes in the database while you work on something else —
run a SELECT, press a button in the app you are building, run it again —
is what 📌 Pin is for.
- Run the query and press 📌 Pin under the result. That result becomes the baseline for this tab.
- Do whatever you are testing, then run the query again.
- The grid now shows what changed: new rows in green, rows that are gone
in red, and changed cells as
before → after. Only differences hides rows that are the same; ▦ Result shows the plain result.
Matching rows. Rows are paired by a key column — a column called id if
there is one that is unique in both results, or any other unique column you
pick under Match rows by. Without a key, whole rows are compared: a row
whose values changed then shows as one removed and one added, because nothing
says it was the same row.
What it will not claim. A result stops at 2,000 rows. If the current one
was cut short, a pinned row missing from it may just be further down, so it is
shown as uncertain rather than removed; the same goes for a "new" row when
the pinned result was cut short. Add a WHERE or an ORDER BY to keep both
under the limit. A column only one result has is listed, not compared.
The pin lives in the tab until you Unpin or Re-pin, and is not saved when the app closes.
Compare a query with its rewrite
When you rewrite a slow query, by hand or with the assistant's Optimize, Compare… in the editor bar answers both questions that matter: is it faster, and does it still return the same rows? The assistant's SQL blocks have ⇄ compare for the same thing, against the query in the open tab.
Put the original in Before and the rewrite in After, choose how many runs, and press ▶ Compare:
- Same rows? This comes first, in green or red. The two results are compared
as sets of rows, in full up to 100,000 rows. A different order is mentioned
separately, because it only matters with an
ORDER BY. A rewrite that is ten times faster and drops a row is flagged as different, not as a win. - Time. Each query runs once to warm up, uncounted. Then they take turns, so a cache warming up mid-way does not favour either. You see the median and the range. If a single run takes seconds, each is timed once.
- Plan. What the engine says it will do. On ElyraSQL, MySQL and MariaDB that is the access per table (full scan, or which index) and the row estimate where the engine gives a real one; MySQL adds the optimiser's cost. On SQLite it is whether each table is scanned or searched, and on ClickHouse the plan as text. ElyraSQL reports no row estimate for scans, so none is shown. The plans as printed are under The plans as the engine printed them.
Both queries must be reads, and both run in a read-only transaction that is rolled back, so a comparison never changes data. It runs on the connection and database the tab was opened on.
Query plan (EXPLAIN)
Explain shows the plan of the statement at the cursor (or the selection) as a tree, in place of the result. Each step shows the rows the server expects and its cost, with a bar for its share of the whole. Steps worth a look are flagged in red:
| flag | means |
|---|---|
| full scan | every row of the table is read |
| sort | rows are sorted after reading, not read in order from an index |
| temp table | a temporary table is built (GROUP BY, DISTINCT, a derived table) |
| no join index | a join has no index to look the rows up by |
| auto index | SQLite builds an index for this query alone, every time it runs |
Analyze runs the query and shows what each step really took: rows per loop, loops and time. Where the estimate and reality are more than tenfold apart, the figure turns amber, which usually means stale table statistics. Analyze is offered for reads only and always runs them in a read-only transaction. Explain without Analyze shows a write's plan without running it.
What each server gives:
| server | Explain | Analyze |
|---|---|---|
| MySQL 8 | the tree (FORMAT=TREE) with costs and estimates |
time and rows per step (EXPLAIN ANALYZE) |
| MariaDB | the JSON plan as a tree | time and rows per step (ANALYZE FORMAT=JSON) |
| SQLite | EXPLAIN QUERY PLAN as a tree |
the whole query timed |
| ClickHouse | EXPLAIN indexes = 1; reading every granule is flagged |
the whole query timed |
| ElyraSQL | the first table's access only, no estimates | the whole query timed |
Raw shows the plan as the server printed it.
Indexes that would help
For each table the plan reads in full or sorts, Explain reads the query's conditions on it and suggests an index. Equality columns come first, then one range column or the sort columns. A B-tree index can only use them in that order. The suggestion lists the indexes the table already has. If one of them already starts with the suggested columns, you get a note instead of a suggestion: the server chose a scan anyway, which is usual on a small table or when most rows match.
Open in editor puts the CREATE INDEX in a new tab. Nothing is created
until you run it there, and running it goes through the usual confirmation on
production. Explain again afterwards to see whether the server uses the index.
The advisor reads a single SELECT, UPDATE or DELETE, not a UNION. It
suggests nothing for ClickHouse, which reads by its sorting key and skip
indexes rather than B-tree indexes. ElyraSQL's plan does not say whether a
secondary index is used, so there the advisor works from the query and the
existing indexes alone; use Compare… to time the query before and after.
Formatting
Format prettifies the current SQL (MySQL dialect, upper-case keywords).
History
Every execution is recorded locally (status, rows, elapsed, timestamp). Open History from the toolbar or ⌘/Ctrl + Y, search past queries, and click one to reopen it in a new tab.
Saved queries
Press ⌘/Ctrl + S to save the current query with a name and optional folder.
Since 0.8.5 they are in the sidebar as well as the command palette. A query saved while a database is selected is listed under that database, as a Queries group beside its Tables and Views; one saved without a database sits in the Saved queries section below the objects. Nothing appears in both places. Deleting one asks first.
Before 0.8.5 the palette was the only way to reach a saved query, and every query was listed for every database regardless of where it was written.
Checks: queries that should return nothing
Many saved queries are health checks: orders without a valid customer, invoices whose total is not the sum of their lines, accounts still active after they expired. Write one to return the rows that break the rule, and mark it as a check — tick A check when saving, or click check? beside it in the Saved queries list.
-- Orders without a customer
SELECT o.* FROM orders o
LEFT JOIN customers c ON c.id = o.customer_id
WHERE c.id IS NULL
A database's checks are listed in its Queries group with a run checks button (also in the command palette: Run checks on …). They run one after another, read-only, and each shows ✓ when it returns no rows, ⚠ N with how many rows break it (up to 10, then 10+), or ✕ when it could not run. Click a check to open it and see the rows. A check that is not a plain read is refused, not run.
Agents can run the same checks through the MCP server's run_checks tool — see
Agents.
Tabs
- ⌘/Ctrl + T — new query tab.
- ⌘/Ctrl + W — close the active tab.
- Query tabs and table (browse) tabs coexist in the same tab bar.
Tabs come back after a restart
The open tabs are saved to the local store (meta.db) a moment after every
change, and reopened at launch — after a crash, a quit, or an update, which
saves them just before it relaunches. SQL you never saved is kept with them.
What comes back:
- Query tabs: the SQL, its title and
:nameparameter values, and the connection and database it last ran on. - Table tabs: the table, its connection, and its filters and sort.
- Cross-connection queries and query comparisons: their sources and SQL.
- ER diagrams drawn from pasted SQL: the SQL and where the tables were dragged to.
What does not: results and pinned results (run again), an open Try run (its transaction ended with the app), grid edits not yet applied, and ER diagrams or query builders opened on a connection — they open again in a click.
Nothing reconnects by itself. A restored tab names its connection with a Connect button, and a table tab loads once that connection is open. A tab on a connection deleted since is not restored; neither is an agent's proposal whose connection is gone. SQL longer than two million characters (a pasted dump) keeps its tab but not its text, and the editor says so.
Free edition
Free runs read-only: SELECT/SHOW/EXPLAIN work; writes and DDL require
Pro.