Help › Work in notebooks
Troubleshoot a server with a runbook
Open a ready-made notebook of read-only queries that finds slow queries, locks, large tables, replication lag and busy connections on PostgreSQL, MySQL, MariaDB, SQL Server and ClickHouse.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
A runbook is a notebook that ships with Querlyn: text that says what to look for, and queries that look. Each one is about one question you ask when a server misbehaves, for one engine.
| Runbook | PostgreSQL | MySQL | MariaDB | SQL Server |
|---|---|---|---|---|
| Slow queries | pg_stat_statements, sessions running now, sequential scans | statement digests, the slow query log, full table scans | statements running now, the slow query log, statement digests | Query Store, the plan cache, requests running now, missing indexes |
| Locks and blocking | who blocks whom, locks not granted, long transactions | row lock waits, metadata lock waits, long transactions | row lock waits, metadata locks, long transactions | blocked requests, locks not granted, long transactions |
| Table and index size | largest tables, dead rows, unused indexes, transaction ID age | largest tables, free space, unused indexes | as MySQL | largest tables, files, fragmentation, unused indexes |
| Replication lag | standbys, slots, a standby's own lag, subscriptions | receivers, appliers' lag, connected replicas | replica status, connected replicas | availability groups' replicas and lag |
| Connections and sessions | in use, by client, idle in a transaction | in use, by client, idle | in use, by client, idle | in use, by client, sleeping with a transaction |
ClickHouse has runbooks of its own, read from its system tables:
| Runbook | What it shows |
|---|---|
| Slow queries | from the query log (system.query_log) of the last day: the query shapes that took the most time, the slowest single queries, the ones that read the most, the ones that failed, the load by hour |
| Running queries | from system.processes: each query's time, progress and memory, its client, the load by user, the server's counters and its limits on queries |
| Merges and mutations | merges running now, mutations that have not finished and why, partitions with the most parts and the limits on parts, the background pool |
| Parts and table size | the largest tables, databases, partitions and columns with how well they compress, parts that are no longer active, detached parts, free space on each disk |
| Replication queue | for replicated tables: each replica's delay and queue, what waits in the queue and why, entries that keep failing; the cluster's servers; what distributed tables have still to send |
Kafka, Redis and DynamoDB are not covered: a notebook has no Kafka, Redis or PartiQL cells. The other engines have no runbooks yet.
Open a runbook
(, also in a connection's context menu and the command palette) asks two things:
- Connection: the server to troubleshoot. The connection selected in the sidebar is offered first.
- Runbook: the runbooks for that connection's engine, each with what it shows and what it needs.
Open Runbook opens it as a new notebook on that connection. It is trusted (it comes with Querlyn), it has no file until you save it, and nothing runs until you run it.
Run it
runs every query, or run one cell at a time. Every query only reads: Querlyn's checks prove it, so a Production connection asks nothing, and a read-only connection runs them too.
A runbook cannot end a session or change a setting. When a cell shows the session to end, Server Activity cancels its query or ends it, after asking.
What a runbook needs
Some cells need something of the server: a version, an extension
(PostgreSQL's pg_stat_statements), a feature turned on (MySQL's
Performance Schema, SQL Server's Query Store, ClickHouse's query log), a
permission (PROCESS, VIEW SERVER STATE, SELECT on one of
ClickHouse's system tables), or a role (a replica, a standby, a server
with replicated tables). Such a cell says under its text what it needs.
Before a run, Querlyn checks what its cells need, with a short query of the runbook's that only reads, on a session of its own. A cell whose server lacks something is skipped and says why and what would give it, for example "Skipped: needs the pg_stat_statements extension in this database", followed by what an administrator does to add it. The other cells run. The checks run again each time, so a cell runs once an administrator has added what it needs.
Keep what you find
A runbook is a notebook like any other: add your own cells, name a result and query it in a scratch cell, save it with ⌘S on macOS or Ctrl+S on Windows and Linux, or export it as a report to share what you found. A saved runbook keeps its checks: opened again later, its cells are still skipped where their server lacks what they need.
Help for Querlyn 0.1.0. All help topics