Creates a report of the current server status for diagnostic purposes.
This procedure disables binary logging during its execution by
manipulating the session value of the
sql_log_bin system variable.
That is a restricted operation, so the procedure requires
privileges sufficient to set restricted session variables. See
Section 7.1.9.1, “System Variable Privileges”.
Data collected for diagnostics()
includes this information:
Information from the
metricsview (see Section 30.4.3.21, “The metrics View”)Information from other relevant
sysschema views, such as the one that determines queries in the 95th percentileInformation from the
ndbinfoschema, if the MySQL server is part of NDB ClusterReplication status (both source and replica)
Some of the sys schema views are calculated as initial (optional), overall, and delta values:
The initial view is the content of the view at the start of the
diagnostics()procedure. This output is the same as the start values used for the delta view. The initial view is included if thediagnostics.include_rawconfiguration option isON.The overall view is the content of the view at the end of the
diagnostics()procedure. This output is the same as the end values used for the delta view. The overall view is always included.The delta view is the difference from the beginning to the end of procedure execution. The minimum and maximum values are the minimum and maximum values from the end view, respectively. They do not necessarily reflect the minimum and maximum values in the monitored period. Except for the
metricsview, the delta is calculated only between the first and last outputs.
in_max_runtime INT UNSIGNED: The maximum data collection time in seconds. UseNULLto collect data for the default of 60 seconds. Otherwise, use a value greater than 0.in_interval INT UNSIGNED: The sleep time between data collections in seconds. UseNULLto sleep for the default of 30 seconds. Otherwise, use a value greater than 0.in_auto_config ENUM('current', 'medium', 'full'): The Performance Schema configuration to use. Permitted values are:current: Use the current instrument and consumer settings.medium: Enable some instruments and consumers.full: Enable all instruments and consumers.
NoteThe more instruments and consumers enabled, the more impact on MySQL server performance. Be careful with the
mediumsetting and especially thefullsetting, which has a large performance impact.Use of the
mediumorfullsetting requires theSUPERprivilege.If a setting other than
currentis chosen, the current settings are restored at the end of the procedure.
diagnostics() operation can be
modified using the following configuration options or their
corresponding user-defined variables (see
Section 30.4.2.1, “The sys_config Table”):
debug,@sys.debugIf this option is
ON, produce debugging output. The default isOFF.diagnostics.allow_i_s_tables,@sys.diagnostics.allow_i_s_tablesIf this option is
ON, thediagnostics()procedure is permitted to perform table scans on the Information SchemaTABLEStable. This can be expensive if there are many tables. The default isOFF.diagnostics.include_raw,@sys.diagnostics.include_rawIf this option is
ON, thediagnostics()procedure output includes the raw output from querying themetricsview. The default isOFF.statement_truncate_len,@sys.statement_truncate_lenThe maximum length of statements returned by the
format_statement()function. Longer statements are truncated to this length. The default is 64.
Create a diagnostics report that starts an iteration every 30 seconds and runs for at most 120 seconds using the current Performance Schema settings:
mysql> CALL sys.diagnostics(120, 30, 'current');
To capture the output from the
diagnostics() procedure in a file as it
runs, use the mysql client tee
and
filenamenotee commands (see
Section 6.5.1.2, “mysql Client Commands”):
mysql> tee diag.out;
mysql> CALL sys.diagnostics(120, 30, 'current');
mysql> notee;