-
SELECT b.processlist_id, c.db, a.sql_text, c.command, c.time, c.state
-
FROM performance_schema.events_statements_current a JOIN performance_schema.threads b USING(thread_id)
-
JOIN information_schema.processlist c ON b.processlist_id = c.id
-
WHERE a.sql_text NOT LIKE '%performance%';
结果:
-
+----------------+------+--------------------------------------------+---------+------+---------------------------------+
-
| processlist_id | db | sql_text | command | time | state |
-
+----------------+------+--------------------------------------------+---------+------+---------------------------------+
-
| 585 | test | UPDATE t SET name='fasdfsad' | Sleep | 243 | |
-
| 586 | test | ALTER TABLE t CHANGE name name varchar(32) | Query | 238 | Waiting for table metadata lock |
-
+----------------+------+--------------------------------------------+---------+------+---------------------------------+
-
2 rows in set (0.01 sec)
也可以很容易定位到执行的内容是做了一个update操作未提交。
作者微信公众号(持续更新)