Query History
functionalSearch the local execution log, keep pinned snippets, and send any statement back to the editor.
A browser over the local execution log, split into Pinned and
Recent. Each row shows a one-line SQL preview (or the pin's name, if
you gave it one) with its server, database, when it ran, whether it succeeded, how long
it took, how many times it has run, and rows affected. The search box takes plain text
or structured filters - server:prod db:sales outcome:failed min:1s - plus
after:/before: dates, max:, and tag:.
- Open in New Tab scripts the full statement back to the editor for review; Run re-runs it in one step, a deliberate exception to the review pause, since it is SQL you already ran.
- Pins are saved queries - a pinned entry gains inline name, description, and tag editors, survives retention pruning, and can be exported and imported as JSON or written into the SQL Library as
.sqlfiles. - Analyze with AI hands the entry, or the last five visible ones - to the AI panel, and entries that stored rollback SQL offer Copy rollback SQL.


The history lives in a local file, like the rest of your SQLly setup, it is yours to keep, search, and back up. The list pages through the log in chunks, and the footer counts what retention has pruned.
Opening it
Right-click any database and choose Tools › Query History..., or run Query History from the command palette. Either way you get the whole log across every connection, newest first, with the search box focused so you can start typing straight away. Use ↑ and ↓ to move through the list and, or a double-click, to open the selected statement in a new tab.
Finding last week's failing report query
- Type
db:reporting outcome:failed after:2026-09-28. Filters combine, so every one must match. - Add a word from the query, such as
invoice. Plain words match anywhere in the SQL, server, database, tags, name, or description. - Select the entry and press Open in New Tab to fix it, or Pin to keep it around.
| Filter | Matches |
|---|---|
server: (or connection:) | Server name containing the text. |
db: (or database:) | Database name containing the text. |
outcome: (or status:) | succeeded, failed, or cancelled. |
after: / before: | Runs on or after / on or before a date written YYYY-MM-DD. |
min: / max: | Duration bounds: 500ms, 1s, 2.5s, or a plain number of milliseconds. |
tag: | Pins with a tag containing the text. |
Text matching ignores case. A token with an unknown prefix is treated as ordinary search text.
What each row tells you
Under the preview, a meta line lists the server and database, a relative time (just now, 5m ago, 3h ago, 2d ago, then the date), the outcome, the duration, ×N when the same statement ran more than once, and rows affected. Statements that came from the AI or from a tool are marked ai or tool; a recent entry that is also pinned says pinned; pinned rows show their #tags and description.
Actions
| Button | What it does |
|---|---|
| Open in New Tab | Opens the full statement in a new query tab and closes the browser. |
| Run | Opens it in a new tab and runs it immediately on the active connection - not necessarily the server recorded in the entry. Parameters, safety checks, and mutation review still apply. |
| Pin / Unpin | Moves the entry into or out of the Pinned section. |
| Analyze with AI | Sends the entry's SQL, target, timing, and outcome to the AI panel as a prompt. |
| Analyze last 5 visible with AI | The same for the first five Recent rows under the current filter. |
| Copy rollback SQL | Copies the rollback statement stored with the entry. Saved grid edits are logged with one. |
| Export Pins… | Saves all pins to a JSON file (query-pins.json by default). |
| Export Pins to Library | Writes each pin as a .sql file in the SQL Library's Pinned folder; duplicate names get a (2)-style suffix. |
| Import Pins… | Merges pins from an exported JSON file, skipping ones you already have. |
Retention
Cleanup runs each time Query History opens. Two settings under Settings › Editor › Query History, in the Execution History Browser section, control it: Retain executions for days (default 90; 0 keeps everything) and Maximum execution entries (default 10,000). Pinned statements are stored separately and are never removed by retention.