MySQL EXPLAIN EXTENDED
1,328 total views, 2 views today
查询MySQL SQL语句的执行计划,一般都是EXPLAIN SQL_STATMENT。EXPLAIN EXTENDED比EXPLAIN查询出的结果多了filtered列,filtered列展示了表的过滤条件过滤后预估的百分比,这给DBA优化工作带来了一定程度的判断根据。
EXPLAIN EXTENDED的结果中,会有warning提示,通过show warnings\G命令,可以看到优化器对原有SQL的查询重写优化过后的SQL。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
mysql> explain select * from a\G ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect... Connection id: 12 Current database: test *************************** 1. row *************************** id: 1 select_type: SIMPLE table: a type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 4 Extra: 1 row in set (0.01 sec) mysql> explain extended select * from a\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: a type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 4 filtered: 100.00 Extra: 1 row in set, 1 warning (0.00 sec) mysql> show warnings\G *************************** 1. row *************************** Level: Note Code: 1003 Message: select `test`.`a`.`id` AS `id`,`test`.`a`.`name` AS `name` from `test`.`a` //查询重写优化过后的SQL 1 row in set (0.00 sec) |