This topic describes how to use the TRACE statement.

You can execute the TRACE statement to view the execution result of an SQL statement. You must use the TRACE <SQL> statement and the SHOW TRACE statement together.

Note The difference between the TRACE <SQL> statement and the EXPLAIN <SQL> statement is that the TRACE <SQL> statement is executed.

Examples

Use the TRACE statement to view the execution result of the select 1 statement.

mysql> trace select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.03 sec)

mysql> show trace;
+------+----------+----------------+-----------------------------------+---------------+--------------------------+------+-----------+--------+
| ID   | TYPE     | GROUP_NAME     | DBKEY_NAME                        | TIME_COST(MS) | CONNECTION_TIME_COST(MS) | ROWS | STATEMENT | PARAMS |
+------+----------+----------------+-----------------------------------+---------------+--------------------------+------+-----------+--------+
|    0 | Optimize | DRDS           | DRDS                              | 3             | 0.00                     |    0 | select 1  | NULL   |
|    1 | Query    | TDDL5_00_GROUP | db218249098_sqa_zmf_tddl5_00_3309 | 7             | 0.15                     |    1 | select 1  | NULL   |
+------+----------+----------------+-----------------------------------+---------------+--------------------------+------+-----------+--------+
2 rows in set (0.01 sec)