-
Notifications
You must be signed in to change notification settings - Fork 111
ps_setup_enable_thread()
xiaoboluo768 edited this page Jun 9, 2020
·
2 revisions
-
启用指定的线程检测功能,通过修改performance_schema.threads表,调用时传入值作为processlist_id字段值,修改instrumented字段为YES实现,返回一个被启用监控功能的线程数量(已经处于启用状态的线程不会计数,因为是使用ROW_COUNT()函数作为返回值,该函数只记录发生变更的行)
-
参数:
- in_connection_id BIGINT:连接ID(进程ID),为performance_schema.theads表的PROCESSLIST_ID列或SHOW PROCESSLIST输出的id列值
-
定义语句
DROP PROCEDURE IF EXISTS ps_setup_enable_thread;
DELIMITER $$
CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_enable_thread (
IN in_connection_id BIGINT
)
COMMENT '
Description
-----------
Enable the given connection/thread in Performance Schema.
Parameters
-----------
in_connection_id (BIGINT):
The connection ID (PROCESSLIST_ID from performance_schema.threads
or the ID shown within SHOW PROCESSLIST)
Example
-----------
mysql> CALL sys.ps_setup_enable_thread(3);
+------------------+
| summary |
+------------------+
| Enabled 1 thread |
+------------------+
1 row in set (0.01 sec)
To enable the current connection:
mysql> CALL sys.ps_setup_enable_thread(CONNECTION_ID());
+------------------+
| summary |
+------------------+
| Enabled 1 thread |
+------------------+
1 row in set (0.00 sec)
'
SQL SECURITY INVOKER
NOT DETERMINISTIC
MODIFIES SQL DATA
BEGIN
UPDATE performance_schema.threads
SET instrumented = 'YES'
WHERE processlist_id = in_connection_id;
SELECT CONCAT('Enabled ', @rows := ROW_COUNT(), ' thread', IF(@rows != 1, 's', '')) AS summary;
END$$
DELIMITER ;
上一篇: ps_setup_enable_instrument()存储过程 | 下一篇: ps_setup_reload_saved()存储过程
- 验证、测试、整理:罗小波
- QQ:309969177
- 提示:本系列文章的主体结构遵循Oracle MySQL 官方 5.7 手册中,关于information_schema、mysql schema、performance_schema、sys schema的章节结构体系,并额外添加了一些验证、测试数据。鉴于本人精力和能力有限,难免出现一些纰漏,欢迎大家踊跃指正!