All Products
Search
Document Center

TRACE

Last Updated: Jul 31, 2020

You can execute the TRACE statement to view the execution of an SQL statement. You must use TRACE [SQL] and SHOW TRACE together.

Note: The difference between TRACE SQL and EXPLAIN SQL is that TRACE SQL is truly executed.

For example, you can execute these statements to view the execution results of the select 1 statement.

  1. mysql> trace select 1;
  2. +---+
  3. | 1 |
  4. +---+
  5. | 1 |
  6. +---+
  7. 1 row in set (0.03 sec)
  8. mysql> show trace;
  9. +------+----------+----------------+-----------------------------------+---------------+--------------------------+------+-----------+--------+
  10. | ID | TYPE | GROUP_NAME | DBKEY_NAME | TIME_COST(MS) | CONNECTION_TIME_COST(MS) | ROWS | STATEMENT | PARAMS |
  11. +------+----------+----------------+-----------------------------------+---------------+--------------------------+------+-----------+--------+
  12. | 0 | Optimize | DRDS | DRDS | 3 | 0.00 | 0 | select 1 | NULL |
  13. | 1 | Query | TDDL5_00_GROUP | db218249098_sqa_zmf_tddl5_00_3309 | 7 | 0.15 | 1 | select 1 | NULL |
  14. +------+----------+----------------+-----------------------------------+---------------+--------------------------+------+-----------+--------+
  15. 2 rows in set (0.01 sec)