O'Reilly logo

Mastering MariaDB by Federico Razzoli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with the EXPLAIN statement

The EXPLAIN statement is the main tool to understand how a statement is executed within a server. In MariaDB 10, this works not only with the SELECT statements, but also with the UPDATE and DELETE statements. The syntax of the EXPLAIN statement is:

EXPLAIN [EXTENDED] <statement>;

The EXTENDED clause adds a column to the output and generates a note (which can be seen with the SHOW WARNINGS command) containing statement as it has been internally rewritten by the optimizer.

After MariaDB 10, another property of this command was added, shown as follows:

SHOW EXPLAIN FOR <thread_id>;

This command allows us to obtain the execution plan from a running statement. This is useful when a statement is taking a lot of time and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required