PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.2Kb
Man Pages (Zip) - 402.4Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0
To obtain the execution plan for an explainable statement executing in a named connection, use this statement:
EXPLAIN [options] FOR CONNECTIONconnection_id;EXPLAIN FOR CONNECTION returns theEXPLAIN information that is currently being used to execute a query in a given connection. Because of changes to data (and supporting statistics) it may produce a different result from runningEXPLAIN on the equivalent query text. This difference in behavior can be useful in diagnosing more transient performance problems. For example, if you are running a statement in one session that is taking a long time to complete, usingEXPLAIN FOR CONNECTION in another session may yield useful information about the cause of the delay.
connection_id is the connection identifier, as obtained from theINFORMATION_SCHEMAPROCESSLIST table or theSHOW PROCESSLIST statement. If you have thePROCESS privilege, you can specify the identifier for any connection. Otherwise, you can specify the identifier only for your own connections. In all cases, you must have sufficient privileges to explain the query on the specified connection.
If the named connection is not executing a statement, the result is empty. Otherwise,EXPLAIN FOR CONNECTION applies only if the statement being executed in the named connection is explainable. This includesSELECT,DELETE,INSERT,REPLACE, andUPDATE. (However,EXPLAIN FOR CONNECTION does not work for prepared statements, even prepared statements of those types.)
If the named connection is executing an explainable statement, the output is what you would obtain by usingEXPLAIN on the statement itself.
If the named connection is executing a statement that is not explainable, an error occurs. For example, you cannot name the connection identifier for your current session becauseEXPLAIN is not explainable:
mysql> SELECT CONNECTION_ID();+-----------------+| CONNECTION_ID() |+-----------------+| 373 |+-----------------+1 row in set (0.00 sec)mysql> EXPLAIN FOR CONNECTION 373;ERROR 1889 (HY000): EXPLAIN FOR CONNECTION command is supportedonly for SELECT/UPDATE/INSERT/DELETE/REPLACE TheCom_explain_other status variable indicates the number ofEXPLAIN FOR CONNECTION statements executed.
PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.2Kb
Man Pages (Zip) - 402.4Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0