mariadb-explain

Generates correct MariaDB EXPLAIN, ANALYZE, and SHOW EXPLAIN query-plan statements.

28|115|Updated Jan 28, 2025
One-click install
npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-explain-mariadb-corporation
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mariadb-explain
Source: https://github.com/mariadb-corporation/mariadb-docs/tree/main/agent-skills/granular/statements/mariadb-explain
Command: npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-explain-mariadb-corporation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? LLMs frequently emit MySQL-style plan-inspection syntax that fails on MariaDB, such as EXPLAIN ANALYZE or EXPLAIN FORMAT=TREE, or misuse ANALYZE on DML without realizing it actually executes the write. This Skill encodes MariaDB's actual grammar and runtime behavior for the EXPLAIN/ANALYZE statement family so generated SQL is valid and safe. ## Core Features & Use Cases - Correct statement selection: Distinguishes plain EXPLAIN (estimate only, never executes), standalone ANALYZE <statement> (executes for real, adds r_rows/r_filtered), and SHOW EXPLAIN/ANALYZE FOR <connection_id> for inspecting live queries. - Dialect delta table: Maps common mistakes to MariaDB forms — no EXPLAIN ANALYZE, no FORMAT=TREE, EXPLAIN EXTENDED required for the filtered column, and EXPLAIN tbl_name being a DESCRIBE synonym. - DML safety guidance: Warns that ANALYZE UPDATE/DELETE/INSERT actually commits writes, while EXPLAIN on DML is a true dry run. - Use Case: When asked to profile a slow query on MariaDB 11.8, produce ANALYZE FORMAT=JSON SELECT ... instead of the invalid EXPLAIN ANALYZE, or use SHOW EXPLAIN FOR <id> to inspect a query still running in another connection. ## Quick Start Ask the AI to write or review a MariaDB query-plan statement, for example: show me how to get real executed row counts for this SELECT on MariaDB.

Frequently Asked Questions about mariadb-explain

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run EXPLAIN ANALYZE in MariaDB?▼

MariaDB has no EXPLAIN ANALYZE statement; use the standalone ANALYZE keyword instead, as in ANALYZE SELECT ... . The ANALYZE statement actually executes the query and reports real row counts via r_rows and r_filtered columns.

What is the difference between EXPLAIN and ANALYZE in MariaDB?▼

EXPLAIN only optimizes the query and reports estimates without executing anything. ANALYZE actually runs the statement, discarding SELECT results but committing INSERT, UPDATE, or DELETE writes, and adds runtime statistics like r_rows and r_filtered.

Does MariaDB support EXPLAIN FORMAT=TREE?▼

No, MariaDB supports only FORMAT=JSON and FORMAT=TRADITIONAL for EXPLAIN output. Using FORMAT=TREE raises an ER_UNKNOWN_EXPLAIN_FORMAT error.

How can I see the plan of a query already running in MariaDB?▼

Use SHOW EXPLAIN FOR <connection_id> or SHOW ANALYZE FOR <connection_id> after finding the id with SHOW PROCESSLIST. These snapshot the plan of a live query in another session without killing or rerunning it.

Why does my MariaDB EXPLAIN output not show a filtered column?▼

Plain tabular EXPLAIN omits the filtered column in MariaDB. Use EXPLAIN EXTENDED to add it, or run ANALYZE, which always includes filtered and r_filtered; FORMAT=JSON output carries these fields unconditionally.

Is ANALYZE safe to run on UPDATE or DELETE statements?▼

No, ANALYZE on UPDATE, DELETE, INSERT, or REPLACE actually performs the modification and commits it. Only EXPLAIN is a true dry run for DML; ANALYZE skips writes only when the optimizer proves the WHERE clause matches nothing.