Skip to content

CONCEPT Cited by 2 sources

Per-pattern time-series

A per-pattern time-series is a stream of aggregated metrics — count, total execution time, rows read, rows returned, rows written, latency percentile sketch — emitted per query-pattern fingerprint per time interval. The per-pattern axis is the grouping key; the time axis is the dimension that makes the signal useful for diagnosis.

(Source: sources/2026-04-21-planetscale-query-performance-analysis-with-insights.)

Why per-pattern, not per-query

Rafer Hazen, 2023-04-20: "Because PlanetScale databases often receive thousands or even millions of queries per second, reporting performance stats for every individual query isn't usually what we want. Instead, we'd like aggregate data for similar queries over time. It's better to know 'This is how long id-based user lookups took over the last hour' versus 'This is how long it took to look up user 123.'"

Per-query telemetry is:

  • Too-high-cardinality for a time-series store.
  • Under-useful for diagnosis — the question is rarely "why was this specific execution slow" and almost always "why is this pattern slow right now".

Per-pattern collapses the stream to O(distinct-patterns) — typically a few hundred even for very large applications.

Axes emitted per pattern per interval

Canonical set from the PlanetScale post:

  • Count — executions of this pattern in the interval.
  • Total execution time — cumulative time spent on this pattern. Enables "where is the workload burning time?" sort (patterns/digest-based-query-prioritization).
  • Total rows read — physical rows touched.
  • Total rows returned — rows in the result set.
  • Total rows written — for DML.
  • Latency sketch DDSketch of execution times; percentile queries derived at read time.

Derived metrics built on top:

  • Rows-read / rows-returned ratio — high ratios indicate inefficient scans; input to the AI index suggestions pipeline.
  • Per-pattern runtime share — this pattern's fraction of cluster-wide runtime; candidates for optimisation picked by the ≥ 0.1% threshold per Hazen 2026.

Time-series shape as diagnostic signal

The time axis turns a flat digest table into a debug tool. Canonical shapes:

  • Sawtooth that monotonically degrades within each period — the DELETE-LIMIT asymptote: hourly job starts fast, degrades to full-table-scan as matches deplete. Fix: index on predicate column.
  • Step-down after deploy — a schema change (index add, query rewrite) drops p95 to near-zero, surfaced via patterns/deploy-marker-overlay-on-time-series.
  • Step-up after deploy — a schema change or app-code release regresses a pattern; the deploy marker identifies the culprit.
  • Diurnal cycling — pattern p95 tracks traffic; capacity signal, not bug signal.

Seen in

Last updated · 470 distilled / 1,213 read