Skip to content

EXPLAIN

EXPLAIN SELECT * FROM students;
+----+-------------+-----------+------------+------+---------------+------+---------+------+------+----------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-----------+------------+------+---------------+------+---------+------+------+----------+-------+
| 1 | SIMPLE | students | NULL | ALL | NULL | NULL | NULL | NULL | 1 | 100.00 | NULL |
+----+-------------+-----------+------------+------+---------------+------+---------+------+------+----------+-------+

The EXPLAIN statement in SQL is used to obtain a query execution plan, or a description of how MySQL would execute a given query. The query in the example is asking for all entries in the ‘students’ table. The output describes the steps the MySQL optimizer would take to execute this query. The ‘type’ column of the output specifies the join type, and ‘ALL’ indicates a full table scan which could impact performance for larger tables.