Skip to content

Find slow queries in MariaDB

Rank statement summaries by total execution time to find queries with the greatest combined cost.

SELECT DIGEST_TEXT AS query_text,
COUNT_STAR AS calls,
SUM_TIMER_WAIT / 1000000000000 AS total_seconds,
AVG_TIMER_WAIT / 1000000000000 AS mean_seconds,
SUM_ROWS_EXAMINED AS rows_examined
FROM performance_schema.events_statements_summary_by_digest
WHERE SCHEMA_NAME = DATABASE()
ORDER BY SUM_TIMER_WAIT DESC
LIMIT 100;

Each row groups statements by their query pattern. The timer conversion gives seconds. Compare total time for cumulative cost and mean time for the cost of one call.

  1. Connect to the database you want to inspect.
  2. Click Admin in the toolbar.
  3. Select Slow Queries.
  4. Compare execution times and call counts.

The view requests up to 100 statement groups for the current database, ordered by total execution time. These are server statistics, including work from other clients. You can also run the SQL above in the SQL editor.

Performance Schema must be enabled and collecting statement statistics. Your account needs read access to performance_schema.events_statements_summary_by_digest. Check whether Performance Schema is enabled with:

SELECT @@performance_schema AS enabled;

An enabled server can still have no collected statements. This view reads statement summaries rather than the slow query log file. For missing data or permission errors, follow admin data unavailable.

MariaDB uses EXPLAIN FORMAT=JSON for an estimated plan and ANALYZE FORMAT=JSON for execution measurements. Review the statement before choosing execution analysis: ANALYZE runs it. Follow Explain with AI for plan interpretation.