INFORMATION_SCHEMA.PROCESSLIST 已弃用,并可能在未来的 MySQL 版本中被移除。因此,使用此表的 SHOW
PROCESSLIST 实现也已弃用。建议使用 Performance Schema 对 PROCESSLIST 的实现代替。INFORMATION_SCHEMA.PROCESSLIST is
deprecated and subject to removal in a future MySQL release. As
such, the implementation of SHOW
PROCESSLIST which uses this table is also deprecated.
It is recommended to use the Performance Schema implementation
of PROCESSLIST instead.
MySQL 进程列表显示服务器内正在执行的线程所执行的操作。PROCESSLIST 表是获取进程信息的一个来源。关于此表与其他来源的比较,请参见 进程信息的来源。The MySQL process list indicates the operations currently being
performed by the set of threads executing within the server. The
PROCESSLIST table is one source of
process information. For a comparison of this table with other
sources, see Sources of Process Information.
PROCESSLIST 表包含以下列:The PROCESSLIST table has these
columns:
ID连接标识符。此值与在
SHOW PROCESSLIST语句的Id列中显示的值相同,在性能模式threads表的PROCESSLIST_ID列中显示,并由线程中的CONNECTION_ID()函数返回。The connection identifier. This is the same value displayed in theIdcolumn of theSHOW PROCESSLISTstatement, displayed in thePROCESSLIST_IDcolumn of the Performance Schemathreadstable, and returned by theCONNECTION_ID()function within the thread.USERUSER发出该语句的 MySQL 用户。
system user的值指的是服务器为内部处理任务而生成的非客户端线程,例如延迟行处理线程或在副本主机上使用的 I/O 或 SQL 线程。对于system user,在Host列中没有指定主机。unauthenticated user指的是已与客户端连接关联但客户端用户尚未经过身份验证的线程。event_scheduler指监控计划事件的线程(参见 第 27.4 节,“使用事件调度器”)。The MySQL user who issued the statement. A value ofsystem userrefers to a nonclient thread spawned by the server to handle tasks internally, for example, a delayed-row handler thread or an I/O or SQL thread used on replica hosts. Forsystem user, there is no host specified in theHostcolumn.unauthenticated userrefers to a thread that has become associated with a client connection but for which authentication of the client user has not yet occurred.event_schedulerrefers to the thread that monitors scheduled events (see Section 27.4, “Using the Event Scheduler”).NoteUSER值为system user与SYSTEM_USER权限是不同的。前者指定内部线程。后者区分系统用户和普通用户账户类别(参见 第 8.2.11 节,“账户类别”)。AUSERvalue ofsystem useris distinct from theSYSTEM_USERprivilege. The former designates internal threads. The latter distinguishes the system user and regular user account categories (see Section 8.2.11, “Account Categories”).HOSTHOST发出语句的客户端主机名(
system user除外,其没有主机)。TCP/IP 连接的主机名以格式报告,以便更容易确定哪个客户端在做什么。The host name of the client issuing the statement (except forhost_name:client_portsystem user, for which there is no host). The host name for TCP/IP connections is reported informat to make it easier to determine which client is doing what.host_name:client_portDB线程的默认数据库,如果未选择则为
NULL。The default database for the thread, orNULLif none has been selected.COMMAND线程代表客户端执行的命令类型,如果会话处于空闲状态,则为
Sleep。有关线程命令的描述,请参阅第 10.14 节,“检查服务器线程(进程)信息”。此列的值对应于客户端/服务器协议的COM_命令和xxxCom_状态变量。参见第 7.1.10 节,“服务器状态变量”。The type of command the thread is executing on behalf of the client, orxxxSleepif the session is idle. For descriptions of thread commands, see Section 10.14, “Examining Server Thread (Process) Information”. The value of this column corresponds to theCOM_commands of the client/server protocol andxxxCom_status variables. See Section 7.1.10, “Server Status Variables”.xxxTIMETIME线程处于当前状态的时间(以秒为单位)。对于副本 SQL 线程,该值为最后一个已复制事件的时间戳与副本主机的实际时间之间的秒数。参见 第 19.2.3 节,“复制线程”。The time in seconds that the thread has been in its current state. For a replica SQL thread, the value is the number of seconds between the timestamp of the last replicated event and the real time of the replica host. See Section 19.2.3, “Replication Threads”.
STATE表示线程正在执行的操作、事件或状态。有关
STATE值的描述,请参见 第 10.14 节,“检查服务器线程(进程)信息”。An action, event, or state that indicates what the thread is doing. For descriptions ofSTATEvalues, see Section 10.14, “Examining Server Thread (Process) Information”.大多数状态对应于非常快速的操作。如果一个线程在某个状态停留了好几秒,可能存在需要调查的问题。Most states correspond to very quick operations. If a thread stays in a given state for many seconds, there might be a problem that needs to be investigated.
INFO线程正在执行的语句,如果未执行任何语句则为
NULL。该语句可能是发送到服务器的语句,或者如果该语句执行其他语句,则为最内层语句。例如,如果CALL语句执行了一个存储过程,而该存储过程正在执行SELECT语句,则INFO值显示SELECT语句。The statement the thread is executing, orNULLif it is executing no statement. The statement might be the one sent to the server, or an innermost statement if the statement executes other statements. For example, if aCALLstatement executes a stored procedure that is executing aSELECTstatement, theINFOvalue shows theSELECTstatement.
注意Notes
PROCESSLIST是一个非标准的INFORMATION_SCHEMA表。PROCESSLISTis a nonstandardINFORMATION_SCHEMAtable.像
SHOW PROCESSLIST语句的输出一样,PROCESSLIST表提供有关所有线程的信息,即使是属于其他用户的线程,如果你具有PROCESS权限。否则(没有PROCESS权限),非匿名用户只能访问他们自己的线程信息,而无法访问其他用户的线程信息,匿名用户则无法访问线程信息。Like the output from theSHOW PROCESSLISTstatement, thePROCESSLISTtable provides information about all threads, even those belonging to other users, if you have thePROCESSprivilege. Otherwise (without thePROCESSprivilege), nonanonymous users have access to information about their own threads but not threads for other users, and anonymous users have no access to thread information.如果一个 SQL 语句引用了
PROCESSLIST表,MySQL 会在语句执行开始时一次性填充整个表,因此在语句执行期间具有读取一致性。对于多语句事务,则没有读取一致性。If an SQL statement refers to thePROCESSLISTtable, MySQL populates the entire table once, when statement execution begins, so there is read consistency during the statement. There is no read consistency for a multi-statement transaction.
以下语句是等效的:The following statements are equivalent:
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST SHOW FULL PROCESSLIST
您可以通过检查服务器状态变量的值来获取有关使用此表的信息:Deprecated_use_i_s_processlist_count 和 Deprecated_use_i_s_processlist_last_timestamp。Deprecated_use_i_s_processlist_count 显示自上次服务器重启以来访问 PROCESSLIST 表的次数;Deprecated_use_i_s_processlist_last_timestamp 提供该表上次访问的时间,格式为 Unix 时间戳。You can obtain information about use of this table by checking the
values of the server status variables
Deprecated_use_i_s_processlist_count
and
Deprecated_use_i_s_processlist_last_timestamp.
Deprecated_use_i_s_processlist_count shows the
number of times the PROCESSLIST table has been
accessed since the last server restart;
Deprecated_use_i_s_processlist_last_timestamp
provides the last time the table was accessed, as a Unix
timestamp.