MySQL 5.7: Introduced EXPLAIN FOR CONNECTION to check the Execution Plan of Running Connections

In this post, I am sharing one of the new feature of MySQL 5.7 which is EXPLAIN FOR CONNECTION.

As we all aware about the EXPLAIN command of MySQL Server, which we are using to find a query execution information.

EXPLAIN FOR CONNECTION is a new feature and using this we can find EXPLAIN information about a running query connection.

When we are diagnosing performance problems, then this is very useful for us.
For example, We are running a statement in one session which is taking a long time to complete, but using EXPLAIN FOR CONNECTION we can check the reason of delay in another session.

We need to pass connection_id to check the running connection information.
We can check connection_id using different method like,

You can also visit this article to find and kill running connections of MySQL.

The syntax :

Once you execute this command and the result is empty because there are no any explainable statements. If we have SELECT, INSERT, UPDATE and DELETE, we can get execution information using this option.

For example:

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of