INFORMATION_SCHEMA.PROCESSLIST table is used to display the runtime status information of all current sessions (threads) within an instance. It can be used in scenarios such as viewing session connections, identifying slow queries, and troubleshooting long-running transactions.PROCESSLIST table by adding fields such as TIME_MS, ROWS_SENT, ROWS_EXAMINED, and TID, providing more granular observability into session runtime behavior.PROCESS privilege can only view information about their own sessions.PROCESS privilege is granted, you can view information for all sessions within the instance.SHOW PROCESSLIST or SHOW FULL PROCESSLIST statements. In these results, the INFO column is truncated to a maximum of 100 characters in SHOW PROCESSLIST, but is displayed in full in SHOW FULL PROCESSLIST and INFORMATION_SCHEMA.PROCESSLIST.Field Name | Type | Description |
ID | bigint unsigned | The session connection ID, which corresponds to the return value of CONNECTION_ID(), can be used as a parameter for the KILL statement. |
USER | varchar(32) | The MySQL username that initiated the session. System sessions are displayed as system user, and unauthenticated sessions are displayed as unauthenticated user. |
HOST | varchar(261) | The hostname or IP address of the client that initiated the session, in the format host_name:port or ip:port. |
DB | varchar(64) | The default database name currently used by the session. If no default database is selected, the value is NULL. |
COMMAND | varchar(16) | The type of command being executed by the session. Common values include Sleep, Query, Connect, Binlog Dump, Killed, and so on. |
TIME | int | The elapsed time of the current COMMAND, in seconds. |
STATE | varchar(64) | The action, event, or state that the thread is currently performing, used to describe the execution stage the session is currently in. A value of NULL indicates no state information. |
INFO | varchar(65535) | The SQL statement being executed by the session. If no statement is being executed, the value is NULL. |
TIME_MS | bigint | The elapsed time of the current COMMAND, in milliseconds, providing higher-precision timing than the TIME field. |
ROWS_SENT | bigint unsigned | The number of rows that the current statement of the session has returned to the client. |
ROWS_EXAMINED | bigint unsigned | The number of rows that the current statement of the session has scanned, which can be used to help locate SQL statements with abnormal execution efficiency. |
TID | bigint unsigned | The coroutine ID (that is, the bthread ID) corresponding to the session. If the session does not use a coroutine, the value is 0. It is used for troubleshooting thread-level issues on the system side. |
tdsql> SELECT * FROM information_schema.PROCESSLIST\\G*************************** 1. row ***************************ID: 2155297USER: testHOST: 10.10.10.10:59078DB: __tdsql_recycle_bin__COMMAND: QueryTIME: 0STATE: executingINFO: SELECT * FROM `information_schema`.`PROCESSLIST`TIME_MS: 2ROWS_SENT: 0ROWS_EXAMINED: 0TID: 268435659*************************** 2. row ***************************ID: 2149066USER: tdsql3_sys_localHOST: localhostDB: NULLCOMMAND: SleepTIME: 9STATE: NULLINFO: NULLTIME_MS: 8726ROWS_SENT: 4ROWS_EXAMINED: 4TID: 4217659552 rows in set (0.01 sec)
SELECT ID, USER, HOST, DB, COMMAND, TIME, STATE, INFOFROM information_schema.PROCESSLISTWHERE COMMAND <> 'Sleep' AND TIME > 10ORDER BY TIME DESC;
KILL 2155297;
Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários