用於檢視配置的儲存過程 | 全方位認識 sys 系統庫
在上一篇《用於修改配置的儲存過程 | 全方位認識 sys 系統庫》中,我們介紹了sys 系統庫中用於修改配置的儲存過程,利用這些儲存過程可以代替修改performance_schema配置表的DML語句等操作,本期的內容講介紹用於檢視performance_schema配置資訊的儲存過程。
PS:下文中如果儲存過程定義文字較短的會列出部儲存過程的定義文字,以便大家更直觀地學習它們。過長的儲存過程定義文字請自行按照《初相識 | 全方位認識 sys 系統庫》一文中介紹的下載路徑下載檢視。
01.ps_setup_show_disabled()
檢視當前被禁用的performance_schema配置資訊,通過查詢performance_schema.setup_actors表enabled為NO、performance_schema.setup_objects表enabled為NO、performance_schema.setup_consumers表enabled為NO、performance_schema.threads表INSTRUMENTED為NO、performance_schema.setup_instruments表enabled為NO 實現,其中,呼叫時傳遞的兩個布林型值,第一個為控制是否列印performance_schema.setup_instruments表中處於關閉狀態的配置(instruments關閉選項的返回值可能比較長),第二個控制是否列印performance_schema.threads表中處於關閉狀態的配置,因為這倆表列印的資訊最多,所以需要單獨傳值控制。
引數:
-
in_show_instruments BOOLEAN:是否顯示關閉的instruments,返回的instruments關閉狀態列表可能比較長
-
in_show_threads BOOLEAN:是否顯示關閉的執行緒
示例
mysql> CALL sys.ps_setup_show_disabled(TRUE, TRUE); +----------------------------+ | performance_schema_enabled | +----------------------------+ | 1 | +----------------------------+ 1 row in set (0.00 sec)
02.ps_setup_show_disabled_consumers()
檢視當前禁用的consumers配置項,通過查詢performance_schema.setup_consumers表enabled欄位為NO實現,執行時無需任何傳入引數
儲存過程定義語句文字
DROP PROCEDURE IF EXISTS ps_setup_show_disabled_consumers; DELIMITER $$ CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_show_disabled_consumers () COMMENT ' Description ----------- Shows all currently disabled consumers. Parameters ----------- None Example ----------- mysql> CALL sys.ps_setup_show_disabled_consumers(); +---------------------------+ | disabled_consumers | +---------------------------+ | events_statements_current | | global_instrumentation | | thread_instrumentation | | statements_digest | +---------------------------+ 4 rows in set (0.05 sec) ' SQL SECURITY INVOKER DETERMINISTIC READS SQL DATA BEGIN SELECT name AS disabled_consumers FROM performance_schema.setup_consumers WHERE enabled = 'NO' ORDER BY disabled_consumers; END$$ DELIMITER ;
03.ps_setup_show_disabled_instruments()
檢視當前禁用的instruments配置,通過查詢performance_schema.setup_instruments表enabled欄位為NO的值實現,執行時無需任何傳入引數,返回的instruments列表可能比較長
儲存過程定義語句文字
DROP PROCEDURE IF EXISTS ps_setup_show_disabled_instruments;
DELIMITER $$
CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_show_disabled_instruments ()
COMMENT '
Description
-----------
Shows all currently disabled instruments.
Parameters
-----------
None
Example
-----------
mysql> CALL sys.ps_setup_show_disabled_instruments();
'
SQL SECURITY INVOKER
DETERMINISTIC
READS SQL DATA
BEGIN
SELECT name AS disabled_instruments, timed
FROM performance_schema.setup_instruments
WHERE enabled = 'NO'
ORDER BY disabled_instruments;
END$$
DELIMITER ;
04.ps_setup_show_enabled()
顯示當前啟用的performance配置(所有配置表),通過查詢performance_schema.setup_actors表enabled為YES、performance_schema.setup_objects表enabled為YES、performance_schema.setup_consumers表enabled為YES、performance_schema.threads表INSTRUMENTED為YES、performance_schema.setup_instruments表enabled為YES實現,其中,呼叫時傳遞的兩個布林型值,第一個為控制是否列印setup_instruments表中處於啟用狀態的配置,第二個控制是否列印performance_schema.threads表中處於啟用狀態的配置,因為這倆表列印的資訊最多,所以需要單獨傳值控制。
引數:
-
in_show_instruments BOOLEAN:是否顯示啟用的instruments,返回的instruments啟用狀態列表可能比較長
-
in_show_threads BOOLEAN:是否顯示啟用監控功能的執行緒
示例
mysql> CALL sys.ps_setup_show_enabled(TRUE, TRUE);
+----------------------------+
| performance_schema_enabled |
+----------------------------+
| 1 |
+----------------------------+
1 row in set (0.00 sec)
05.ps_setup_show_enabled_consumers()
檢視當前啟用的consumers配置,通過查詢performance_schema.setup_consumers表enabled欄位為YES實現,執行時無需任何傳入引數
儲存過程定義語句文字
DROP PROCEDURE IF EXISTS ps_setup_show_enabled_consumers;
DELIMITER $$
CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_show_enabled_consumers ()
COMMENT '
Description
-----------
Shows all currently enabled consumers.
Parameters
-----------
None
Example
-----------
mysql> CALL sys.ps_setup_show_enabled_consumers();
+---------------------------+
| enabled_consumers |
+---------------------------+
| events_statements_current |
| global_instrumentation |
| thread_instrumentation |
| statements_digest |
+---------------------------+
4 rows in set (0.05 sec)
'
SQL SECURITY INVOKER
DETERMINISTIC
READS SQL DATA
BEGIN
SELECT name AS enabled_consumers
FROM performance_schema.setup_consumers
WHERE enabled = 'YES'
ORDER BY enabled_consumers;
END$$
DELIMITER ;
06.ps_setup_show_enabled_instruments()
檢視當前啟用的instruments配置,通過查詢performance_schema.setup_instruments表enabled欄位為YES的值實現,執行時無需任何傳入引數,但返回的instruments列表可能比較長
儲存過程定義語句文字
DROP PROCEDURE IF EXISTS ps_setup_show_enabled_instruments;
DELIMITER $$
CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_show_enabled_instruments ()
COMMENT '
Description
-----------
Shows all currently enabled instruments.
Parameters
-----------
None
Example
-----------
mysql> CALL sys.ps_setup_show_enabled_instruments();
'
SQL SECURITY INVOKER
DETERMINISTIC
READS SQL DATA
BEGIN
SELECT name AS enabled_instruments, timed
FROM performance_schema.setup_instruments
WHERE enabled = 'YES'
ORDER BY enabled_instruments;
END$$
DELIMITER ;
本期內容就介紹到這裡,本期內容參考連結如下:
-
https://dev.mysql.com/doc/refman/5.7/en/sys-ps-setup-show-enabled-instruments.html
-
https://dev.mysql.com/doc/refman/5.7/en/sys-ps-setup-show-disabled.html
-
https://dev.mysql.com/doc/refman/5.7/en/sys-ps-setup-show-disabled-consumers.html
-
https://dev.mysql.com/doc/refman/5.7/en/sys-ps-setup-show-disabled-instruments.html
-
https://dev.mysql.com/doc/refman/5.7/en/sys-ps-setup-show-enabled.html
-
https://dev.mysql.com/doc/refman/5.7/en/sys-ps-setup-show-enabled-consumers.html
| 作者簡介
羅小波·沃趣科技高階資料庫技術專家
IT從業多年,歷任運維工程師,高階運維工程師,運維經理,資料庫工程師,曾參與版本釋出系統,輕量級監控系統,運維管理平臺,資料庫管理平臺的設計與編寫,熟悉MySQL的體系結構時,InnoDB儲存引擎,喜好專研開源技術,追求完美。