全部产品
云市场

TRACE

更新时间:2018-04-27 22:10:21

TRACE 语句用于查看具体 SQL 的执行情况。TRACE [SQL] 和 SHOW TRACE 要结合使用。

注意:TRACE SQL 和 EXPLAIN SQL 的区别在于 TRACE SQL 会实际执行该语句。

例如查看 select 1这条语句的执行情况。

  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)