Image

9

Explaining the MySQL EXPLAIN

The MySQL EXPLAIN command is used to show the Query Execution Plan (QEP) for your SQL statement. The output from the command provides insight into how the MySQL optimizer will execute the SQL statement. The MySQL EXPLAIN command does not provide any tuning recommendations, but it does provide valuable information to help you make tuning decisions.

In this final chapter, we will be detailing the full syntax and options for the EXPLAIN command.

Syntax

The QEP is produced with the EXPLAIN command. The syntax has two options:

mysql> EXPLAIN [EXTENDED | PARTITIONS ]
    -> SELECT ...

or

mysql> EXPLAIN table

The MySQL ...

Get Effective MySQL Optimizing SQL Statements now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.