Snippets
Built-in diagnostic queries and your own reusable SQL blocks, one drag away.
For: analysts and developers.
Snippets are short, reusable bits of SQL. QueryDeck ships with a curated library of diagnostic queries for PostgreSQL and MySQL, and you can add your own.
Open the snippets panel
| Way to open | Where |
|---|---|
| Sidebar | Snippets section |
| Command palette | Cmd+K, type "snippets" |
| Menu | View → Show Snippets |
The panel splits into two folders by default:
- Built-in — diagnostics that ship with QueryDeck
- My snippets — your own additions
Built-in snippets
These are the queries we use ourselves. They are read-only — you can drag them into the editor, copy them, or fork them into "My snippets" to customize.
PostgreSQL
| Snippet | What it shows |
|---|---|
| Table sizes | Every table sorted by total size on disk (data + indexes + toast) |
| Index usage | Which indexes are actually used and which are dead weight |
| Slow queries | Top queries by total time from pg_stat_statements |
| Locks | Current blocking locks with the holder and waiter |
| Active connections | Sessions on the server with their state, query, and idle time |
| Bloat estimate | Tables with significant dead row counts |
| Cache hit ratio | Buffer cache hit rate per table |
MySQL
| Snippet | What it shows |
|---|---|
| Table sizes | Every table sorted by size in MB |
| Slow queries | Queries from the slow log if enabled |
| Active connections | Sessions on the server with their state and query |
| InnoDB status | Output of SHOW ENGINE INNODB STATUS |
| Buffer pool stats | Hit ratio and dirty page count |
If you connect to a database where a snippet doesn't apply (e.g., pg_stat_statements not enabled), the snippet still runs and the server returns a helpful error pointing you at the missing extension or grant.
Insert a snippet into the editor
Three ways:
- Double-click a snippet — opens a new tab with the SQL ready to run.
- Drag a snippet onto an existing tab — inserts at the cursor.
Cmd+K→ type the snippet name → pressEnter.
The snippet stays in the library after insertion. Edit your tab freely.
Create your own snippet
- Highlight the SQL in the editor you want to save.
- Right-click →
Save as Snippet... - Give it a name. Optionally add a description and a folder.
- Save.
You can also create a snippet from scratch: in the snippets panel, click + and start typing.
Organize with folders
Right-click in the panel to create a folder. Drag snippets into it. Folders can be nested.
A useful structure for a team:
Snippets/
├── Built-in/
│ └── ...
└── My snippets/
├── Auth & users/
│ ├── Find user by email
│ └── Reset password (no-op example)
├── Stripe/
│ ├── Last 50 charges
│ └── Refunds today
└── Performance/
└── Tables without indexesParameterized snippets
A snippet can include placeholders. Use {{name}} syntax:
SELECT * FROM users WHERE email = '{{email}}';When you insert a parameterized snippet, QueryDeck opens a small form asking for each placeholder. Fill, press Enter, and the SQL is inserted with the values filled in.
Placeholders are simple text substitution. They are not SQL bind parameters — if you're handling untrusted input, write the query manually.
Snippets vs saved queries
| Snippets | Saved queries |
|---|---|
| Short, reusable blocks of SQL | Full queries you want to keep |
| Inserted into a tab to compose | Loaded as a tab to run as-is |
| Not tied to a connection | Tied to one or more connections |
| Built-in library ships with the app | Always your own |
If you find yourself running the same long query every Monday, that's a saved query. If you're constantly typing the same JOIN pattern, that's a snippet.
What's next
- Saved queries for full named queries
- Query history if you forgot to save and need to recover
- Notebooks for snippet-style composition with documentation