Help › Run queries
Run a query on several connections
Run one statement on many connections or tenant databases at once and read every answer in one grid, with a Connection column and each connection's status.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
Run one statement on many saved connections at once, or on many databases of one server, and read the answers in one grid. Each row says which connection it came from. Use it to ask every tenant the same question, or to check whether staging is the same as production.
Choose the connections
- Put the cursor in the statement, or select it. One statement runs; select only it when the tab holds several.
- Choose Run on Several… in the bar above the editor, or .
- In Run on Several Connections, tick the connections to run on.
The list shows your saved connections by folder:
- Choose a whole folder with its own checkbox; tick it again to leave them all. Choose All Shown ticks every connection the filters show, and Clear leaves them all.
- Narrow the list with the Environment and Folder filters above it. A connection you chose stays chosen when a filter hides it; the count under the list says so.
- Pick databases of one server (a database per tenant): open a connection with the arrow beside it, or with → on macOS or Right on Windows and Linux, to list its databases, and tick the ones to run on. Listing them connects it.
- Production connections are marked in red in the list, and the line under it names every Production connection you chose.
Only connections that speak the tab's SQL dialect are offered. Tick Every engine to offer the others too; when the chosen ones speak different dialects, the picker says that the statement may fail on some of them.
Choose Run on 3 Connections (the number is how many you chose) or press ↩ on macOS or Enter on Windows and Linux. ⎋ on macOS or Esc on Windows and Linux closes the picker without running. The keys of the list: ↑ on macOS or Up on Windows and Linux and ↓ on macOS or Down on Windows and Linux move, Space ticks, → on macOS or Right on Windows and Linux and ← on macOS or Left on Windows and Linux show and hide a connection's databases.
The picker remembers what this tab ran on, and starts with it next time. runs the statement at the cursor on them without opening the picker.
The question before it runs
Before anything runs, Querlyn checks the statement for each connection, as it does before a run in one tab, and asks once for the whole set when one of them needs it:
- what needs confirmation on which connections (a
DELETEwithoutWHERE, a schema change that makes others wait), by each connection's own confirmation settings; - every Production connection of the set, by name;
- a statement that changes data asks whenever the set has a Production connection, even where one run in one tab would not;
- connections that commit by hand (Production does, by default): there the change waits in an open transaction until you choose Commit All or Roll Back All (see Commit or roll back what waits).
Cancel runs nothing on any connection.
Warning: Each connection runs the statement on its own. A connection that commits as it runs keeps its change even when the statement fails on another; only the changes that wait for Commit All can still be undone everywhere.
A statement that may change data is refused on the whole set, before anything runs, when one of the connections is read-only. Leave that connection out, or turn Read-only off for it.
Read the results
Above the grid, one line per connection says where it stands: waiting, running, how many rows and how long, not committed when its change waits for you, cancelled, or what went wrong and when (while connecting, while opening its session, while running, while committing). A connection that cannot connect, fails or times out does not stop the others. Each one has its own Cancel; Cancel All, or ⌘. on macOS or Ctrl+. on Windows and Linux, stops every one of them. Closing the tab cancels them too.
The rows of every connection are in one result:
- The first column, Connection, names where each row came from. When you chose databases of a server, a Database column follows.
- Columns are matched by name, ignoring case, so
IDfrom one engine andidfrom another are one column. - A column some connections do not have reads missing in their rows,
apart from a
NULLthe server sent. - A column with different types on different connections (a boolean on one, a number on another) is shown as text, and a line above the grid says so. Numbers of different kinds stay numbers; decimals stay exact.
- Rows come in as each connection sends them. Sort by Connection to keep each connection's rows together.
Sorting, filtering, copying, charts and exporting the rows loaded work as for any result (see Work with results). So does copying the rows into the scratch to query them further, Connection column included (see Query your results and join across connections); such a table names its connections and cannot be refreshed from them. Some things do not work, and say so: editing cells (open a connection's rows in its own tab), following foreign keys, sorting every row on the server, and exporting by running the statement again.
Four connections run at a time; the next one starts as one ends. Each reads its rows up to its share of the result's memory budget; a line above the grid names a connection whose rows were cut there. Only the first result of each connection is shown.
Commit or roll back what waits
On a connection that commits by hand, a statement that changes data leaves its transaction open when it succeeds. Its line above the grid says how many rows it changed and not committed, and nothing is committed there until you choose one of these, above the grid:
- Commit All commits the change on every connection where it waits. It is red when one of them is Production.
- Roll Back All undoes it on all of them.
They are in the command palette too, as and . While the tab has no transaction of its own, the keys of the tab's Commit and Roll Back, ⇧⌘K on macOS or Ctrl+Shift+K on Windows and Linux and ⇧⌘⌫ on macOS or Ctrl+Shift+Backspace on Windows and Linux, do the same.
Until you choose:
- The tab shows its transactions as open, like any open transaction: its tab is marked, and the status bar says on how many connections. They keep their locks, so lock awareness tells you when other sessions wait for them, and reminds you when they stay open too long.
- Nothing else runs in the tab. Choose first.
- Closing the tab, quitting, or disconnecting one of their connections asks first, as for any open transaction: commit them all, roll them all back, or cancel.
- A connection that is lost meanwhile reads Rolled back: the server ended its transaction, so nothing of its change was kept.
After Commit All, each line says committed, or Failed while committing with the reason, and a line above the grid names the connections where the change was not committed. A commit that fails does not undo the others. When you were closing the tab or quitting, nothing closes if a commit failed, so you can see where.
Compare two connections
When a run on two connections has ended and both returned rows, (Compare by Key above the grid) pairs their rows by one column, the key: the column the grid's cursor is in, or the first one after Connection.
- The rows are sorted by the key, so each pair sits together.
- A row whose pair holds other values is tinted, and so is each cell that
differs. Numbers compare by value:
9.50is9.5. - A row whose key only one connection has is tinted in another color.
- Rows whose key repeats on one connection are not paired, and are counted apart.
- A line above the grid counts them: the same, different, and only on each side.
Columns only one connection has, and masked columns, are not compared. Choose it again to stop comparing.
What each connection keeps
Each connection runs on a session of its own, with its own lock and statement timeouts, and closes the session when it ends: when its statement ends, or, where its change waited, after Commit All or Roll Back All. Its query history records the statement as that connection keeps history: on Production, by default, without its text (see Search the query history). The statement console lists what was sent to each one.
Columns you marked sensitive are masked in the merged grid when any of
the connections masks them (see Screen-share mode).
In screen-share mode the Database column shows each database's
placeholder, such as Database 2, as the connection tree does, on screen
and in copies and exports.
Help for Querlyn 0.1.0. All help topics