> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-feat-sql-code-folding.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Query History

> Every executed query is saved to a local SQLite database with full-text search

Every query you run is saved automatically, whether it succeeded or failed. History persists across sessions and is searchable.

Open the drawer with `Cmd+Y` or **View** > **Show Query History**. There is also a **History** toolbar button, which you add through **View** > **Customize Toolbar**.

<Frame caption="Query history drawer: entry list on the left, details on the right">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-feat-sql-code-folding/VLUDsoMaXL0TA-5F/images/query-history.png?fit=max&auto=format&n=VLUDsoMaXL0TA-5F&q=85&s=595a8ef2b6ea37f5bbc153512d38e5fd" alt="Query history drawer" width="1560" height="960" data-path="images/query-history.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-feat-sql-code-folding/VLUDsoMaXL0TA-5F/images/query-history-dark.png?fit=max&auto=format&n=VLUDsoMaXL0TA-5F&q=85&s=28be9040d23c6a417699178489e6ab36" alt="Query history drawer" width="1560" height="960" data-path="images/query-history-dark.png" />
</Frame>

## The Drawer

The drawer opens under the editor and you can drag its divider to resize it. It remembers its height, its filters, and whether it was open, per connection.

Entries are grouped by day, newest first, under **Today**, **Yesterday**, or the date. Each row shows whether the query succeeded, the query text, the database, the time it ran, and how long it took. A query that ran in under a millisecond shows `<1 ms`; a step whose duration was never measured shows `–` rather than `0 ms`.

The right pane shows the selected query with syntax highlighting for the database it actually ran against, plus its connection, database and schema, timestamp, duration, row count, source, and the error message for failed queries.

Recent queries also appear in [Open Quickly](/features/open-quickly). For a summary of what this history adds up to, rather than a list of it, see [Query Insights](/features/query-insights).

## Scope

History is scoped to the connection you are looking at. Switch the first popup to **All Connections** to search across every connection you have; rows then show which connection each query came from, so you can tell two databases named `app` apart.

Loading a query that belongs to another connection opens it in a new tab in that connection's own window, rather than running it against the connection in front of you. **Run in New Tab** is dimmed for those entries, because only the connection that recorded a query can run it. Load it there and run it from that window.

## Filtering

| Control | What it does                                             |
| ------- | -------------------------------------------------------- |
| Scope   | This connection, or all connections                      |
| Source  | Which parts of the app a query came from                 |
| Date    | Last hour, today, last 7 days, last 4 weeks, all time    |
| Outcome | Any, succeeded, or failed                                |
| Search  | Full-text search across query text, matching as you type |

Search matches partial words, so typing `cust` finds `customers`. Several words all have to match, but they do not have to be next to each other: `select customers` finds `SELECT id, name FROM customers`.

## Pausing

The pause button stops recording new queries on this Mac. Nothing is recorded from any source while it is paused, including row edits, structure changes, imports and AI clients, and the drawer says so until you resume. Pausing is local to the Mac you press it on, and it survives relaunch.

### Sources

TablePro runs SQL on your behalf in several places, and the **Source** menu decides which of those you see. It defaults to **My Queries**, which is the SQL you wrote yourself.

| Source            | What it covers                                                             |
| ----------------- | -------------------------------------------------------------------------- |
| Editor            | Queries you ran from a query tab                                           |
| Explain           | EXPLAIN runs                                                               |
| Table Browsing    | The SELECTs the app generates when you open a table, page, sort, or filter |
| Row Edits         | The INSERT, UPDATE and DELETE statements produced by saving grid edits     |
| Structure Changes | DDL from the structure editor, triggers, and user management               |
| Imports           | Import runs                                                                |
| AI and MCP        | Queries run by an AI assistant or an MCP client                            |

Turn on **Table Browsing** to see exactly what the app sent while you clicked around a table. Turn on **Structure Changes** to review what altered a schema and when.

## Working With Entries

| Action               | How                                                                                                  |
| -------------------- | ---------------------------------------------------------------------------------------------------- |
| Load into the editor | Select an entry and click **Load in Editor**, or press `Return`                                      |
| Run it again         | **Run in New Tab**, or right-click > **Run in New Tab**. It opens a new tab and runs the query there |
| Copy the query       | `Cmd+C`, the **Copy** button, or right-click > **Copy Query**                                        |
| Save as favorite     | Right-click > **Save as Favorite…** (see [Favorites](/features/favorites))                           |
| Delete one entry     | `Delete` key or right-click > **Delete**                                                             |
| Load older entries   | **Load More** at the bottom of the list                                                              |

Click a row to select it and the details appear beside it; the keyboard stays in the list, so arrow keys keep moving through entries. Loading a query into the editor is a separate, deliberate step: press `Return` with the list focused, double-click the row, or click **Load in Editor**.

**Run in New Tab** sends the query to the server, so an entry that writes (INSERT, UPDATE, DELETE, or a schema change) asks for confirmation first, whatever the connection's [safe mode](/features/safe-mode) is set to. Reads run straight away. An entry that uses [query parameters](/features/query-parameters) opens the parameter panel instead of running, because parameter values are never recorded.

## Clearing History

The trash button clears exactly what the drawer is showing, including whatever the filters are hiding. Scoped to one connection it leaves every other connection alone; with a date range selected it only clears that range; and with the default **My Queries** source it leaves table browsing, row edits, imports and AI queries in place. It asks first, and the confirmation says which of those two it is about to do. There is no undo.

**Settings > Data > Query History > Clear History...** clears everything, for every connection.

## Storage and Retention

History lives in `~/Library/Application Support/TablePro/query_history.db`, a local SQLite database with a full-text index.

Configure retention in **Settings > Data > Query History**:

| Setting          | Default | Options                                                          |
| ---------------- | ------- | ---------------------------------------------------------------- |
| Maximum entries  | 10,000  | 100 to 10,000, or Unlimited                                      |
| Keep entries for | 90 days | 7 days to 1 year, or Forever                                     |
| Auto cleanup     | On      | Applies the two limits above. Turn it off and nothing is pruned. |

Deleting a connection deletes its query history with it.

Query parameter values are never written to disk. The user and role editor never records a statement that carries a password, such as `CREATE USER ... IDENTIFIED BY`. A query you write yourself is recorded as you wrote it, so use the pause button before running one that contains a secret.

## Search From External Clients

History is searchable from MCP clients. The `search_query_history` tool returns matching entries with timestamp, connection, query text, source, and outcome. The Raycast extension wraps this in a **Search Query History** command.

See [`search_query_history`](/external-api/mcp-tools) and [Raycast commands](/external-api/raycast#commands).
