Query History
TablePro automatically saves every query you execute, making it easy to find, re-run, or modify previous queries. The query history persists across sessions and can be searched with full-text search.
Accessing History
History Panel
Open the history panel:
- Click View > Query History
- Or use the keyboard shortcut
Cmd+Y
- Or click the History icon in the toolbar
Recent queries also appear in the sidebar under the active connection.
History Features
Query List
The history panel displays:
| Column | Description |
|---|
| Query | The SQL text (truncated if long) |
| Time | When the query was executed |
| Duration | Execution time |
| Status | Success or error |
| Database | Database/connection used |
Sorting
Sort history by:
- Time: Most recent first (default)
- Duration: Slowest queries first
- Query text: Alphabetically
Click column headers to change sort order.
Filtering
Filter queries by:
- Connection: Show only queries from specific connection
- Status: Show only successful or failed queries
- Time range: Today, this week, this month, all time
Searching History
Full-Text Search
Type in the search box to find queries containing specific text:
SELECT users -- Find all queries containing "SELECT" and "users"
Search Tips
- Search is case-insensitive
- Partial matches are included
- Search looks at the full query text
Example searches:
| Search | Finds |
|---|
users | Queries mentioning “users” |
JOIN orders | Queries joining orders table |
WHERE created | Queries filtering by created |
UPDATE users SET | Update statements on users |
Using History
Re-running Queries
To re-run a query from history:
- Find the query in the history list
- Double-click the query
- It loads into the SQL editor
- Press
Cmd+Enter to execute
Or right-click and select Run Query.
Copying Queries
To copy a query:
- Select the query in the list
- Right-click > Copy Query
- Or press
Cmd+C
The full query text is copied to clipboard.
Editing Before Running
To modify a historical query:
- Double-click to load into editor
- Make your changes
- Execute the modified query
The original history entry is preserved; a new entry is created for the modified query.
History Storage
Where History is Stored
Query history is stored in:
~/Library/Application Support/TablePro/query_history.db
This SQLite database contains:
- Query text
- Execution timestamp
- Duration
- Connection/database info
- Success/failure status
- Error messages (if failed)
History Retention
Configure history retention in Settings > History:
| Setting | Default | Description |
|---|
| Max Entries | 10,000 | Maximum queries to store |
| Max Days | 90 | Delete queries older than this |
| Auto Cleanup | On | Automatically remove old entries |
Set Max Entries to 0 for unlimited history (may impact performance with very large histories).
Clearing History
To clear all history:
- Open Settings > History
- Click Clear All History
- Confirm the action
Clearing history cannot be undone. Consider exporting important queries first.
To clear history for a specific connection:
- Right-click the connection in sidebar
- Select Clear History
Query Details
Viewing Full Query
For long queries, click to expand and see the full text:
Execution Details
Each history entry includes:
| Detail | Description |
|---|
| Started | Timestamp when execution began |
| Duration | How long the query took |
| Rows affected | Number of rows returned/modified |
| Error | Error message if query failed |
Failed Queries
Failed queries show:
- The error message
- The query that caused the error
- Timestamp of the failure
This helps debug issues:
- Find the failed query
- Read the error message
- Load into editor
- Fix and re-run
Best Practices
Annotating Queries
Add comments to important queries for easier searching:
-- Monthly revenue report 2024
SELECT
DATE_FORMAT(created_at, '%Y-%m') as month,
SUM(total) as revenue
FROM orders
WHERE created_at >= '2024-01-01'
GROUP BY month;
Now you can search for “Monthly revenue report” to find it.
Use consistent comment patterns:
-- [REPORT] User growth
-- [DEBUG] Performance issue
-- [ADMIN] Data cleanup
-- [TEMP] Testing query
Exporting Important Queries
For queries you want to keep permanently:
- Find the query in history
- Copy to a SQL file
- Save in version control
Keyboard Shortcuts
| Action | Shortcut |
|---|
| Open history | Cmd+Y |
| Search history | Cmd+F (when history is open) |
| Load selected query | Enter or double-click |
| Copy query | Cmd+C |
Troubleshooting
History Not Saving
- Check disk space - history needs storage
- Verify TablePro has write permissions
- Check if history is disabled in settings
Slow History Search
For very large histories:
- Reduce Max Entries in settings
- Clear old history
- Use more specific search terms
Missing Old Queries
Check Max Days setting - queries older than this limit are automatically deleted.
To prevent automatic deletion:
- Open Settings > History
- Set Max Days to 0 (unlimited)
Duplicate Entries
Each execution creates a new history entry, even for identical queries. This is intentional to track when queries were run.
Next Steps