how to get the SQL statement based on the process ID?

2.2k Views Asked by At

I run the SQL below ,after that I run the SELECT * FROM information_schema.processlist to get the SQL statement " update new_table set c1=c1+12", however the column info is null , so how to get the statement ?

use   test_db;
start transaction;
update new_table set c1=c1+12

enter image description here

1

There are 1 best solutions below

0
Bill Karwin On

If the Command column says "Sleep" then there's no SQL query running in that session. The client may have run the UPDATE query you showed, but that query has finished. It's only shown in the processlist while it's executing.

You can examine performance_schema.events_statements_history_long table to see previous queries that ran in each session. It takes a bit of work to join that table to the processlist. See https://dev.mysql.com/doc/mysql-perfschema-excerpt/8.0/en/performance-schema-statement-tables.html