Skip to content

CONCEPT Cited by 1 source

MySQL sys schema

The sys schema is a curated set of views + stored procedures over performance_schema that present server telemetry in human-readable form. It exists because performance_schema tables are wide, use picosecond timers, and require joins + computations to produce the diagnostic answers operators actually want. sys pre-bakes the common questions.

(Source: sources/2026-04-21-planetscale-identifying-and-profiling-problematic-mysql-queries.)

Canonical diagnostic views

Named in the PlanetScale post:

  • sys.statements_with_sorting — queries using ORDER BY / GROUP BY that required a sort (candidates for a covering index).
  • sys.statements_with_runtimes_in_95th_percentile — queries whose avg runtime is in the top 5% of the workload; the "which queries are slow?" view.
  • sys.statements_with_full_table_scans — queries that scanned at least one table end-to-end; candidates for missing indexes.

Worked example from the post:

SELECT query, db, exec_count, total_latency
  FROM sys.statements_with_full_table_scans
  ORDER BY exec_count DESC LIMIT 5;

returns, for a workload without secondary indexes, queries running thousands of times each, accumulating minutes of cumulative latency — a diagnostic signal that some tables need indexing.

Column conveniences

sys columns are pre-formatted: avg_latency shows 2.13 s / 881.20 ms / 70.52 ms rather than the raw picosecond integer. For programmatic consumption, the underlying performance_schema columns are still available.

Relationship to performance_schema

  • sys is not a separate source of truth — it's views.
  • Everything in sys can be derived from performance_schema; sys is ergonomics.
  • Queries against sys views inherit the same instrumentation-overhead trade-offs as direct performance_schema queries.

Seen in

  • PlanetScale's field manual for query diagnosis (2024-03-29). Dicken uses sys.statements_with_* views as the easier-to-read complement to raw performance_schema digest queries, positioning them as the "start here" diagnostic surface before dropping to lower-level performance_schema tables for narrow questions like per-table unindexed-read counts. (Source: sources/2026-04-21-planetscale-identifying-and-profiling-problematic-mysql-queries.)
Last updated · 378 distilled / 1,213 read