You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
6.6 KiB

  1. -- Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  2. --
  3. -- This program is free software; you can redistribute it and/or modify
  4. -- it under the terms of the GNU General Public License as published by
  5. -- the Free Software Foundation; version 2 of the License.
  6. --
  7. -- This program is distributed in the hope that it will be useful,
  8. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. -- GNU General Public License for more details.
  11. --
  12. -- You should have received a copy of the GNU General Public License
  13. -- along with this program; if not, write to the Free Software
  14. -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. DROP PROCEDURE IF EXISTS ps_setup_show_enabled;
  16. DELIMITER $$
  17. CREATE DEFINER='mariadb.sys'@'localhost' PROCEDURE ps_setup_show_enabled (
  18. IN in_show_instruments BOOLEAN,
  19. IN in_show_threads BOOLEAN
  20. )
  21. COMMENT '
  22. Description
  23. -----------
  24. Shows all currently enabled Performance Schema configuration.
  25. Parameters
  26. -----------
  27. in_show_instruments (BOOLEAN):
  28. Whether to print enabled instruments (can print many items)
  29. in_show_threads (BOOLEAN):
  30. Whether to print enabled threads
  31. Example
  32. -----------
  33. mysql> CALL sys.ps_setup_show_enabled(TRUE, TRUE);
  34. +----------------------------+
  35. | performance_schema_enabled |
  36. +----------------------------+
  37. | 1 |
  38. +----------------------------+
  39. 1 row in set (0.00 sec)
  40. +---------------+
  41. | enabled_users |
  42. +---------------+
  43. | \'%\'@\'%\' |
  44. +---------------+
  45. 1 row in set (0.01 sec)
  46. +-------------+---------+---------+-------+
  47. | object_type | objects | enabled | timed |
  48. +-------------+---------+---------+-------+
  49. | EVENT | %.% | YES | YES |
  50. | FUNCTION | %.% | YES | YES |
  51. | PROCEDURE | %.% | YES | YES |
  52. | TABLE | %.% | YES | YES |
  53. | TRIGGER | %.% | YES | YES |
  54. +-------------+---------+---------+-------+
  55. 5 rows in set (0.01 sec)
  56. +---------------------------+
  57. | enabled_consumers |
  58. +---------------------------+
  59. | events_statements_current |
  60. | global_instrumentation |
  61. | thread_instrumentation |
  62. | statements_digest |
  63. +---------------------------+
  64. 4 rows in set (0.05 sec)
  65. +---------------------------------+-------------+
  66. | enabled_threads | thread_type |
  67. +---------------------------------+-------------+
  68. | sql/main | BACKGROUND |
  69. | sql/thread_timer_notifier | BACKGROUND |
  70. | innodb/io_ibuf_thread | BACKGROUND |
  71. | innodb/io_log_thread | BACKGROUND |
  72. | innodb/io_read_thread | BACKGROUND |
  73. | innodb/io_read_thread | BACKGROUND |
  74. | innodb/io_write_thread | BACKGROUND |
  75. | innodb/io_write_thread | BACKGROUND |
  76. | innodb/page_cleaner | BACKGROUND |
  77. | innodb/srv_lock_timeout_thread | BACKGROUND |
  78. | innodb/srv_error_monitor_thread | BACKGROUND |
  79. | innodb/srv_monitor_thread | BACKGROUND |
  80. | innodb/srv_master_thread | BACKGROUND |
  81. | innodb/srv_purge_thread | BACKGROUND |
  82. | innodb/srv_worker_thread | BACKGROUND |
  83. | innodb/srv_worker_thread | BACKGROUND |
  84. | innodb/srv_worker_thread | BACKGROUND |
  85. | innodb/buf_dump_thread | BACKGROUND |
  86. | innodb/dict_stats_thread | BACKGROUND |
  87. | sql/signal_handler | BACKGROUND |
  88. | sql/compress_gtid_table | FOREGROUND |
  89. | root@localhost | FOREGROUND |
  90. +---------------------------------+-------------+
  91. 22 rows in set (0.01 sec)
  92. +-------------------------------------+-------+
  93. | enabled_instruments | timed |
  94. +-------------------------------------+-------+
  95. | wait/io/file/sql/map | YES |
  96. | wait/io/file/sql/binlog | YES |
  97. ...
  98. | statement/com/Error | YES |
  99. | statement/com/ | YES |
  100. | idle | YES |
  101. +-------------------------------------+-------+
  102. 210 rows in set (0.08 sec)
  103. Query OK, 0 rows affected (0.89 sec)
  104. '
  105. SQL SECURITY INVOKER
  106. DETERMINISTIC
  107. READS SQL DATA
  108. BEGIN
  109. SELECT @@performance_schema AS performance_schema_enabled;
  110. -- In 5.7.6 and later the setup_actors table has an ENABLED column to
  111. -- specify whether the actor is enabled. Before that all actors matched
  112. -- in the setup_actors table were enabled.
  113. SELECT CONCAT('\'', user, '\'@\'', host, '\'') AS enabled_users
  114. FROM performance_schema.setup_actors
  115. WHERE enabled = 'YES'
  116. ORDER BY enabled_users;
  117. SELECT object_type,
  118. CONCAT(object_schema, '.', object_name) AS objects,
  119. enabled,
  120. timed
  121. FROM performance_schema.setup_objects
  122. WHERE enabled = 'YES'
  123. ORDER BY object_type, objects;
  124. SELECT name AS enabled_consumers
  125. FROM performance_schema.setup_consumers
  126. WHERE enabled = 'YES'
  127. ORDER BY enabled_consumers;
  128. IF (in_show_threads) THEN
  129. SELECT IF(name = 'thread/sql/one_connection',
  130. CONCAT(processlist_user, '@', processlist_host),
  131. REPLACE(name, 'thread/', '')) AS enabled_threads,
  132. TYPE AS thread_type
  133. FROM performance_schema.threads
  134. WHERE INSTRUMENTED = 'YES' AND name <> 'thread/innodb/thread_pool_thread'
  135. ORDER BY enabled_threads;
  136. END IF;
  137. IF (in_show_instruments) THEN
  138. SELECT name AS enabled_instruments,
  139. timed
  140. FROM performance_schema.setup_instruments
  141. WHERE enabled = 'YES'
  142. ORDER BY enabled_instruments;
  143. END IF;
  144. END$$
  145. DELIMITER ;