文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 82%

28.3.23 INFORMATION_SCHEMA PROCESSLIST 表28.3.23 The INFORMATION_SCHEMA PROCESSLIST Table

Important

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 the Id column of the SHOW PROCESSLIST statement, displayed in the PROCESSLIST_ID column of the Performance Schema threads table, and returned by the CONNECTION_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 of system user refers 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. For system user, there is no host specified in the Host column. unauthenticated user refers to a thread that has become associated with a client connection but for which authentication of the client user has not yet occurred. event_scheduler refers to the thread that monitors scheduled events (see Section 27.4, “Using the Event Scheduler”).

    Note

    USER 值为 system user 与 SYSTEM_USER 权限是不同的。前者指定内部线程。后者区分系统用户和普通用户账户类别(参见 第 8.2.11 节,“账户类别”)。A USER value of system user is distinct from the SYSTEM_USER privilege. 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 连接的主机名以 host_name:client_port 格式报告,以便更容易确定哪个客户端在做什么。The host name of the client issuing the statement (except for system user, for which there is no host). The host name for TCP/IP connections is reported in host_name:client_port format to make it easier to determine which client is doing what.

  • DB

    线程的默认数据库,如果未选择则为NULL。The default database for the thread, or NULL if none has been selected.

  • COMMAND

    线程代表客户端执行的命令类型,如果会话处于空闲状态,则为Sleep。有关线程命令的描述,请参阅第 10.14 节,“检查服务器线程(进程)信息”。此列的值对应于客户端/服务器协议的COM_xxx命令和Com_xxx状态变量。参见第 7.1.10 节,“服务器状态变量”。The type of command the thread is executing on behalf of the client, or Sleep if 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 the COM_xxx commands of the client/server protocol and Com_xxx status variables. See Section 7.1.10, “Server Status Variables”.

  • TIMETIME

    线程处于当前状态的时间(以秒为单位)。对于副本 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 of STATE values, 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, or NULL if 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 a CALL statement executes a stored procedure that is executing a SELECT statement, the INFO value shows the SELECT statement.

注意Notes

  • PROCESSLIST 是一个非标准的 INFORMATION_SCHEMA 表。PROCESSLIST is a nonstandard INFORMATION_SCHEMA table.

  • 像 SHOW PROCESSLIST 语句的输出一样,PROCESSLIST 表提供有关所有线程的信息,即使是属于其他用户的线程,如果你具有 PROCESS 权限。否则(没有 PROCESS 权限),非匿名用户只能访问他们自己的线程信息,而无法访问其他用户的线程信息,匿名用户则无法访问线程信息。Like the output from the SHOW PROCESSLIST statement, the PROCESSLIST table provides information about all threads, even those belonging to other users, if you have the PROCESS privilege. Otherwise (without the PROCESS privilege), 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 the PROCESSLIST table, 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.