MySQL Variables session_track_state_change 数据库 参数变量解释及正确配置使用
本站中文解释
MySQL参数变量 session_track_state_change 用于控制是否开启会话状态跟踪功能,默认为 OFF。
当 session_track_state_change 参数开启(ON),MySQL开始记录当前会话状态的变化,比如说在当前会话中有哪些连接,及查询执行状态,并且将记录的信息保存在一个叫做“state_change”的状态标识符中。
要设置 session_track_state_change,请在MySQL服务器上执行以下操作:
set global session_track_state_change=ON;
这样就可以启用会话状态跟踪功能,从而允许MySQL跟踪会话中的变化,从而更方便地确定会话中查询的执行状态。
官方英文解释
session_track_state_change
Command-Line Format | --session-track-state-change[={OFF|ON}] |
---|---|
System Variable | session_track_state_change |
Scope | Global, Session |
Dynamic | Yes |
Type | Boolean |
Default Value | OFF |
Controls whether the server tracks changes to the state of the
current session and notifies the client when state changes
occur. Changes can be reported for these attributes of client
session state:
-
The default schema (database).
-
Session-specific values for system variables.
-
User-defined variables.
-
Temporary tables.
-
Prepared statements.
If the session state tracker is enabled, notification occurs
for each change that involves tracked session attributes, even
if the new attribute values are the same as the old. For
example, setting a user-defined variable to its current value
results in a notification.
The
session_track_state_change
variable controls only notification of when changes occur, not
what the changes are. For example, state-change notifications
occur when the default schema is set or tracked session system
variables are assigned, but the notification does not include
the schema name or variable values. To receive notification of
the schema name or session system variable values, use the
session_track_schema
or
session_track_system_variables
system variable, respectively.
Assigning a value to
session_track_state_change
itself is not considered a state change and is not reported
as such. However, if its name listed in the value of
session_track_system_variables
,
any assignments to it do result in notification of the new
value.
For more information about session state tracking, see
Section 5.1.15, “Server Tracking of Client Session State”.