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.

RunbookPostgreSQLMySQLMariaDBSQL Server
Slow queriespg_stat_statements, sessions running now, sequential scansstatement digests, the slow query log, full table scansstatements running now, the slow query log, statement digestsQuery Store, the plan cache, requests running now, missing indexes
Locks and blockingwho blocks whom, locks not granted, long transactionsrow lock waits, metadata lock waits, long transactionsrow lock waits, metadata locks, long transactionsblocked requests, locks not granted, long transactions
Table and index sizelargest tables, dead rows, unused indexes, transaction ID agelargest tables, free space, unused indexesas MySQLlargest tables, files, fragmentation, unused indexes
Replication lagstandbys, slots, a standby's own lag, subscriptionsreceivers, appliers' lag, connected replicasreplica status, connected replicasavailability groups' replicas and lag
Connections and sessionsin use, by client, idle in a transactionin use, by client, idlein use, by client, idlein use, by client, sleeping with a transaction

ClickHouse has runbooks of its own, read from its system tables:

RunbookWhat it shows
Slow queriesfrom 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 queriesfrom 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 mutationsmerges 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 sizethe 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 queuefor 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

Notebook › Open Runbook… (Notebook › Open 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

Notebook › Run All Cells 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