GA

2013/10/01

MySQL 5.7.2のEXPLAIN FOR CONNECTIONの使い方

昨日のMyNA会でちょっと話が出ていたEXPLAIN FOR CONNECTIONの使い方。
正直これそんなに便利なものじゃないと思うんですが。

http://dev.mysql.com/doc/refman/5.7/en/explain.html

{explainable_stmt | FOR CONNECTION connection_id}
となっている通り、EXPLAINに食わせるSQLステートメントの代わりにFOR CONNECTION x; として指定する。


conn1> explain SELECT * FROM t1, t1 AS t2;
+----+-------------+-------+------+---------------+------+---------+------+--------+---------------------------------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows   | Extra                                 |
+----+-------------+-------+------+---------------+------+---------+------+--------+---------------------------------------+
|  1 | SIMPLE      | t1    | ALL  | NULL          | NULL | NULL    | NULL | 953856 | NULL                                  |
|  1 | SIMPLE      | t2    | ALL  | NULL          | NULL | NULL    | NULL | 953856 | Using join buffer (Block Nested Loop) |
+----+-------------+-------+------+---------------+------+---------+------+--------+---------------------------------------+
2 rows in set (0.00 sec)

conn1> SELECT * FROM t1, t1 AS t2;
..(実行中)

conn2> show processlist;
+----+------+-----------+------+---------+------+--------------+----------------------------+
| Id | User | Host      | db   | Command | Time | State        | Info                       |
+----+------+-----------+------+---------+------+--------------+----------------------------+
|  3 | root | localhost | d1   | Query   |    5 | Sending data | SELECT * FROM t1, t1 AS t2 |
|  4 | root | localhost | NULL | Query   |    0 | init         | show processlist           |
+----+------+-----------+------+---------+------+--------------+----------------------------+
2 rows in set (0.51 sec)

conn2> EXPLAIN FOR CONNECTION 3;
+----+-------------+-------+------+---------------+------+---------+------+--------+---------------------------------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows   | Extra                                 |
+----+-------------+-------+------+---------------+------+---------+------+--------+---------------------------------------+
|  1 | SIMPLE      | t1    | ALL  | NULL          | NULL | NULL    | NULL | 953856 | NULL                                  |
|  1 | SIMPLE      | t2    | ALL  | NULL          | NULL | NULL    | NULL | 953856 | Using join buffer (Block Nested Loop) |
+----+-------------+-------+------+---------------+------+---------+------+--------+---------------------------------------+
2 rows in set (0.25 sec)

こんな感じ。おんなじじゃーん、て。

ところでEXPLAIN FOR CONNECTIONかけるとかけた方のコネクション(id= 3のコネクション)がアボートするんだけどこれバグ?;

【2013/10/01 13:36】
EXPLAIN FOR CONNECTIONかけなくても落ちた。

【2013/10/01 13:40】
OOM Killerに殺されてるだけだった…(´;ω;`)

0 件のコメント :

コメントを投稿