- MySQL 5.1 Reference Manual :: 12 SQL Statement Syntax :: 12.8 MySQL Utility Statements :: 12.8.2 EXPLAIN Syntax
-
- MySQL 5.1 Reference Manual
- Preface, Notes, Licenses
- 1 General Information
- 2 Installing and Upgrading MySQL
- 3 Tutorial
- 4 MySQL Programs
- 5 MySQL Server Administration
- 6 Backup and Recovery
- 7 Optimization
- 8 Language Structure
- 9 Internationalization and Localization
- 10 Data Types
- 11 Functions and Operators
- 12 SQL Statement Syntax
- 13 Storage Engines
- 14 High Availability and Scalability
- 15 MySQL Enterprise Monitor
- 16 Replication
- 17 MySQL Cluster NDB 6.X/7.X
- 18 Partitioning
- 19 Stored Programs and Views
- 20 INFORMATION_SCHEMA Tables
- 21 Connectors and APIs
- 22 Extending MySQL
- A MySQL 5.1 Frequently Asked Questions
- B Errors, Error Codes, and Common Problems
- C MySQL Change History
- D Restrictions and Limits
- Index
- Standard Index
- C Function Index
- Command Index
- Function Index
- INFORMATION_SCHEMA Index
- Transaction Isolation Level Index
- JOIN Types Index
- Operator Index
- Option Index
- Privileges Index
- SQL Modes Index
- Status Variable Index
- Statement/Syntax Index
- System Variable Index
EXPLAIN
tbl_name
Or:
EXPLAIN [EXTENDED | PARTITIONS] SELECT
select_options
The
EXPLAIN
statement can be used either as a synonym forDESCRIBE
or as a way to obtain information about how MySQL executes aSELECT
statement:-
EXPLAIN
is synonymous withtbl_name
DESCRIBE
ortbl_name
SHOW COLUMNS FROM
.tbl_name
For a description of the
DESCRIBE
andSHOW COLUMNS
statements, see Section 12.8.1, “DESCRIBE
Syntax”, and Section 12.4.5.6, “SHOW COLUMNS
Syntax”. -
When you precede a
SELECT
statement with the keywordEXPLAIN
, MySQL displays information from the optimizer about the query execution plan. That is, MySQL explains how it would process theSELECT
, including information about how tables are joined and in which order.EXPLAIN EXTENDED
can be used to provide additional information.For information regarding the use of
EXPLAIN
andEXPLAIN EXTENDED
for obtaining query execution plan information, see Section 7.2.1, “Optimizing Queries withEXPLAIN
”. -
EXPLAIN PARTITIONS
is available beginning with MySQL 5.1.5. It is useful only when examining queries involving partitioned tables.For details, see Section 18.3.4, “Obtaining Information About Partitions”.