Chapter 17 · Performance Schema, sys Schema, Logs, and Observability

sys Schema Views, User/Host Activity, I/O, Statements, Memory, and Index Usage

Use MariaDB sys schema as a verified convenience layer over Performance Schema and Information Schema for user, host, statement, I/O, memory, and index investigations without automating heuristic conclusions.

Advanced145–185 minutessys schema correlation labMariaDB Community 12.3.2 baselineCurriculum anchor: 11.8 LTS · verify target-version behaviorFree local MariaDB tooling · Last reviewed: August 2026

Learning outcomes

Performance Schema is precise but low-level. MariaDB’s sys schema provides human-friendly views and helper routines over Performance Schema and Information Schema. That convenience is valuable only if you verify the schema exists on the target server and understand the source tables behind a result. A sys view can summarize a symptom; it does not turn a heuristic into a safe production action.

01

Verify sys schema availability/version before relying on it and distinguish human-readable views from raw x$ views.

02

Use user/host, statement, I/O, and memory views to narrow an investigation.

03

Trace sys findings back to Performance Schema or Information Schema source data.

04

Treat unused/redundant-index views as hypotheses that require workload and constraint validation.

05

Build a reproducible ServiceHub investigation without assuming sys exists on every MariaDB version/package.

Availability and cost

MariaDB sys schema views are available from MariaDB 10.6, but verify the exact target installation with INFORMATION_SCHEMA. Some sys views can themselves be expensive because they aggregate large Performance Schema or InnoDB metadata. A convenience view is not free simply because it is named sys.

1. Verify sys before using it

sql · check schema and version instead of assuming
SELECT VERSION() AS server_version;SELECT SCHEMA_NAMEFROM information_schema.SCHEMATAWHERE SCHEMA_NAME='sys';SELECT TABLE_NAME, TABLE_TYPEFROM information_schema.TABLESWHERE TABLE_SCHEMA='sys'ORDER BY TABLE_NAMELIMIT 30;

If no sys row appears, do not copy queries that assume it exists. Continue with Performance Schema/Information Schema directly or install/upgrade according to the exact MariaDB package/version documentation. If it exists, inspect actual views rather than relying on a MySQL sys-schema tutorial.

sql · create a disposable ServiceHub observability workload
DROP DATABASE IF EXISTS servicehub17;CREATE DATABASE servicehub17 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;USE servicehub17;CREATE TABLE tickets (  ticket_id BIGINT PRIMARY KEY AUTO_INCREMENT,  customer_id BIGINT NOT NULL,  status ENUM('open','waiting','closed') NOT NULL,  priority TINYINT NOT NULL,  opened_at DATETIME(6) NOT NULL,  closed_at DATETIME(6) NULL,  INDEX ix_status_opened(status, opened_at),  INDEX ix_customer(customer_id)) ENGINE=InnoDB;CREATE TABLE ticket_events (  event_id BIGINT PRIMARY KEY AUTO_INCREMENT,  ticket_id BIGINT NOT NULL,  event_type VARCHAR(40) NOT NULL,  event_at DATETIME(6) NOT NULL,  payload VARCHAR(500) NULL,  INDEX ix_ticket_time(ticket_id, event_at)) ENGINE=InnoDB;INSERT INTO tickets(customer_id,status,priority,opened_at,closed_at)WITH RECURSIVE seq AS (  SELECT 1 AS n  UNION ALL SELECT n+1 FROM seq WHERE n < 500)SELECT 1000 + (n % 80),       CASE WHEN n % 7 = 0 THEN 'closed' WHEN n % 3 = 0 THEN 'waiting' ELSE 'open' END,       1 + (n % 5),       NOW(6) - INTERVAL n MINUTE,       CASE WHEN n % 7 = 0 THEN NOW(6) - INTERVAL (n-2) MINUTE ELSE NULL ENDFROM seq;INSERT INTO ticket_events(ticket_id,event_type,event_at,payload)SELECT ticket_id,       CASE WHEN ticket_id % 4=0 THEN 'comment' ELSE 'status_change' END,       opened_at + INTERVAL 30 SECOND,       RPAD('x', 120, 'x')FROM tickets;

2. User and host activity: convenience over multiple sources

sys.user_summary and sys.host_summary aggregate statement, connection, I/O, and memory information into a compact diagnostic surface. Use them to choose where to investigate next, not to label a client “bad.”

sql · inspect high-level user and host summaries
SELECT * FROM sys.user_summary ORDER BY statement_latency DESC LIMIT 10;SELECT * FROM sys.host_summary ORDER BY statement_latency DESC LIMIT 10;

The formatted views favor human readability. Many sys views also have x$... counterparts with raw numeric values intended for tooling. When building collectors, prefer raw units so parsers do not need to interpret formatted strings such as “23.4 MiB” or “4.7 ms.”

sql · compare formatted and raw host I/O views
SELECT * FROM sys.host_summary_by_file_io LIMIT 10;SELECT * FROM sys.`x$host_summary_by_file_io` LIMIT 10;

Host attribution is useful for finding a noisy application tier, but NAT, proxies, connection pooling, and local background threads can change what “host” means. Record the deployment topology before treating host aggregation as user identity.

3. Statements and I/O: use sys to shortlist, then prove

sql · find expensive normalized statement shapes
USE servicehub17;SELECT COUNT(*) FROM tickets WHERE status='open';SELECT * FROM tickets WHERE customer_id=1021 ORDER BY opened_at DESC LIMIT 10;SELECT query, db, exec_count, total_latency, avg_latency, rows_examined, rows_sentFROM sys.statement_analysisWHERE db='servicehub17'ORDER BY total_latency DESCLIMIT 10;

statement_analysis is a convenient projection of digest data. Once a query shape matters, go back to the source digest row and the actual SQL plan. Formatted latency is useful to humans, but change-control decisions should preserve raw values, execution counts, and the observation window.

sql · connect a sys finding back to Performance Schema
SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR,       SUM_TIMER_WAIT, SUM_ROWS_EXAMINED, SUM_ROWS_SENTFROM performance_schema.events_statements_summary_by_digestWHERE SCHEMA_NAME='servicehub17'ORDER BY SUM_TIMER_WAIT DESCLIMIT 10;EXPLAINSELECT * FROM servicehub17.ticketsWHERE customer_id=1021ORDER BY opened_at DESCLIMIT 10;

If the query is expensive because it returns thousands of rows, an index may not solve the user-facing problem. If the plan scans due to a missing composite index, the plan evidence—not the sys ranking alone—supports the hypothesis.

4. Memory and index usage: useful signals with sharp edges

sql · inspect memory and table/index summaries when present
SELECT * FROM sys.memory_global_total;SELECT * FROM sys.memory_by_user_by_current_bytesORDER BY current_allocated DESCLIMIT 10;SELECT * FROM sys.schema_index_statisticsWHERE table_schema='servicehub17'ORDER BY rows_selected DESC;

Memory instrumentation depends on Performance Schema instrumentation state. If a view returns little data, verify the source instruments before concluding memory use is negligible.

Unused is not useless

Views such as schema_unused_indexes summarize observed index usage within the Performance Schema collection lifetime. An index can appear unused because the server restarted, summaries were reset, a monthly job has not run, or a constraint/replication/maintenance workflow needs it. Never automate DROP INDEX from one snapshot.

sql · treat an unused-index view as a hypothesis
SELECT *FROM sys.schema_unused_indexesWHERE object_schema='servicehub17';SHOW CREATE TABLE servicehub17.tickets;SHOW INDEX FROM servicehub17.tickets;

Before dropping an index, check primary/unique constraints, foreign-key requirements, production query corpus, rare jobs, write cost, replica/reporting workloads, and rollback time. Then test the candidate change in a representative environment.

5. Wrong approach: “sys said unused, so drop it now”

Imagine ix_customer shows no reads in a short quiet lab window. Dropping it immediately can turn customer-history lookups into scans.

sql · deliberately remove the customer index in the disposable lab
ALTER TABLE servicehub17.tickets DROP INDEX ix_customer;EXPLAINSELECT * FROM servicehub17.ticketsWHERE customer_id=1021ORDER BY opened_at DESCLIMIT 10;

The plan may now scan substantially more rows. The repair is not “sys was wrong”; the mistake was treating a bounded observation as complete workload knowledge.

sql · repair and verify the access path
ALTER TABLE servicehub17.ticketsADD INDEX ix_customer(customer_id);EXPLAINSELECT * FROM servicehub17.ticketsWHERE customer_id=1021ORDER BY opened_at DESCLIMIT 10;

6. Production judgment and cleanup

Use sys for fast triage, especially when a human needs readable summaries. Use Performance Schema for the raw evidence and exact collection semantics underneath it. For automation, prefer raw x$ views or source tables and explicitly version your collector queries.

Prerequisites and boundaries

Mandatory lab: MariaDB Community Server 12.3.2 with sys schema present and Performance Schema enabled; curriculum anchor 11.8 LTS. If sys is absent, the lesson remains reproducible by inspecting the underlying Performance Schema/Information Schema sources, but the sys-specific queries should be skipped rather than fabricated.

Check your understanding

  1. Why must you verify that sys exists before using it?
  2. What is the practical difference between a formatted sys view and its x$ counterpart?
  3. Why should statement_analysis lead to EXPLAIN rather than replace it?
  4. Why can schema_unused_indexes produce a false sense of safety?
  5. What should you record before comparing sys snapshots over time?
Review the answers

Sys is version/package dependent and must be verified. Human views format units while x$ views expose raw values for tooling. statement_analysis identifies costly shapes but does not explain access-path mechanics. Unused-index evidence is bounded by the collection window and workload coverage. Record server/version, uptime/reset time, workload, instrumentation state, and topology before comparing snapshots.

sql · cleanup
DROP DATABASE IF EXISTS servicehub17;

Authoritative references

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only assets compatible with the Ethereum/ERC-20 network. Do not send TRC-20/TRON assets.