mysql実行計画の取得方法
mysql実行計画の取得方法:1.explainでsqlの実行計画を表示します.2.パススレッドが実行中のsqlは、そのsqlの実行計画を表示します.
show processlist;またはselect*from information_schema.
mysql> select from information_schema.
mysql> EXPLAIN FOR CONNECTION 178;+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+----------------------------------------------------+| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+----------------------------------------------------+| 1 | SIMPLE | t_adress | NULL | ALL | NULL | NULL | NULL | NULL | 200096 | 100.00 | NULL || 1 | SIMPLE | t | NULL | ALL | NULL | NULL | NULL | NULL | 309664 | 100.00 | Using where; Using join buffer (Block Nested Loop) |+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+----------------------------------------------------+2 rows in set (0.01 sec)
使いやすいのではないでしょうか.
最后に一言言います:今日は心が苦しくて、寝ました.....
explain sql , sql , ?
sql , , sql , sql , , , , mysql5.7 sql , sql , :
show processlist;またはselect*from information_schema.
PROCESSLIST
where info is not null order by time desc ;を参照してください.mysql> select from information_schema.
PROCESSLIST
where info is not null;+-----+------+-----------------+------+---------+------+--------------+-----------------------------------------------------------------------+| ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO |+-----+------+-----------------+------+---------+------+--------------+-----------------------------------------------------------------------+| 17 | root | localhost | NULL | Query | 0 | executing | select from information_schema. PROCESSLIST
where info is not null || 178 | root | localhost:60124 | app1 | Query | 560 | Sending data | select count(*) from t ,t_adress where t.adress = t_adress.adress |+-----+------+-----------------+------+---------+------+--------------+-----------------------------------------------------------------------+2 rows in set (0.00 sec) mysql> EXPLAIN FOR CONNECTION 178;+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+----------------------------------------------------+| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+----------------------------------------------------+| 1 | SIMPLE | t_adress | NULL | ALL | NULL | NULL | NULL | NULL | 200096 | 100.00 | NULL || 1 | SIMPLE | t | NULL | ALL | NULL | NULL | NULL | NULL | 309664 | 100.00 | Using where; Using join buffer (Block Nested Loop) |+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+----------------------------------------------------+2 rows in set (0.01 sec)
使いやすいのではないでしょうか.
最后に一言言います:今日は心が苦しくて、寝ました.....