At a glance
Slow-Query Rate % is the share of SQL statements over the last 15 minutes whose service latency crossed the slow threshold (200ms by default, the same line the p95 card uses). It answers a question a raw latency percentile cannot: “what fraction of my workload is actually slow right now?” A p99 can look ugly while only a sliver of traffic is affected, and a healthy-looking average can hide a steady drip of slow statements. This card collapses that into one number a DBA or on-call SRE can read at a glance. At or under 1% is a comfortable cluster; 1 to 5% is worth watching; above 5% fires an alert because a meaningful slice of your workload is now slow enough for users to feel.
Calculation
The rate is a simple ratio computed over the rolling 15-minute window:- What “slow” means. The slow threshold defaults to 200ms of service latency, the time CockroachDB spends planning and executing the statement (it excludes network round-trip to the client). This is the same threshold the Statement Latency p95 (ms) card alerts on, so the two read consistently. The threshold is configurable per profile.
- Service latency, not full round-trip. Because the measure is server-side service latency, a slow client or a saturated network link will not inflate this number. That keeps it a clean signal of database-side slowness.
- Count-weighted, not time-weighted. Every statement counts once regardless of how slow it was. A statement at 205ms and a statement at 9 seconds each add one to the numerator. This is deliberate: the card answers “how much of my workload is slow”, and the Top Contended Statements and latency-percentile cards answer “how slow, and why”.
- Internal statements excluded. Background and internal SQL (schema jobs, statistics collection, internal range housekeeping) is filtered out so the rate reflects application traffic, not the cluster talking to itself.
Worked example
A platform team runs a 5-node CockroachDB cluster (v23.2) backing the cart, catalogue, and order services for an ecommerce stack. Snapshot taken on 14 Apr 26 at 12:05 BST during the lunchtime peak.
At 12:05 the card fires. The team’s first move is to check whether the spike is real load or a thin denominator: Statements per Second (live) shows a healthy ~1,500 statements/second, so this is not a quiet-period artefact, a genuine 6.6% of a busy workload is slow.
Next, the breakdown. The team opens Top Contended Statements and finds a single
UPDATE inventory SET qty = qty - $1 WHERE sku = $2 pattern accounting for the bulk of the slow events: a flash sale on one hot SKU is serialising writes to the same range, and the contention is dragging the slow rate up. Statement Latency p99 (ms) confirms the tail has blown out to 1,400ms.
- The rate tells you how much, not why. A high Slow-Query Rate is the prompt; the Top Contended Statements and latency-percentile cards tell you which statements and how slow. Never act on the headline alone.
- Always check the denominator. On a quiet cluster a tiny number of slow analytical queries can push the percentage high without any user impact. Pair it with statements-per-second so you know whether 6% means “60 slow queries” or “60,000”.
Sibling cards
Reconciling against the source
CockroachDB does not print a single “slow-query rate” figure, so reconcile it from the statement statistics that feed it:- DB Console SQL Activity. The Statements page lets you sort by latency and filter by a latency floor; counting statements above 200ms against the total over a 15-minute window reproduces the rate. The Statements page also exposes the per-statement execution counts and latency percentiles used in the calculation.
crdb_internaltables.SELECT * FROM crdb_internal.node_statement_statistics(and the cluster-widecrdb_internal.cluster_statement_statistics) expose per-statement counts and latency, so you can compute the ratio directly in SQL.- Slow-query logging. If you have enabled the SQL slow-query log (the
sql.log.slow_query.latency_thresholdcluster setting), the log captures every statement over the configured threshold; the count of log lines over a window divided by total statements is another way to sanity-check the rate. - Time-series. The
sql.service.latencyhistogram in the DB Console Metrics dashboard underpins the percentile cards and the slow threshold.