In MySQL, we can use the sys.ps_is_instrument_default_timed()
function to check whether a given Performance Schema instrument is timed by default.
The function returns YES
or NO
, depending on whether the instrument is timed by default.
Syntax
The syntax goes like this:
sys.ps_is_instrument_default_timed(in_instrument)
Where in_instrument
is the name of the instrument to check.
Example
Here’s an example to demonstrate:
SELECT sys.ps_is_instrument_default_timed('statement/sql/select');
Result:
YES
This shows that the statement/sql/select
instrument is timed by default.
Here’s one that’s not timed by default:
SELECT sys.ps_is_instrument_default_timed('stage/sql/setup');
Result:
NO
Non-Existent Instrument
If the instrument doesn’t exist I get a YES
:
SELECT sys.ps_is_instrument_default_timed('homer/simpson');
Result:
YES
NULL
Instrument
If the argument is NULL
, then YES
is returned:
SELECT sys.ps_is_instrument_default_timed(NULL);
Result:
YES
Passing the Wrong Number of Arguments
Passing the wrong number of arguments results in an error:
SELECT sys.ps_is_instrument_default_timed( NULL, NULL );
Result:
ERROR 1318 (42000): Incorrect number of arguments for FUNCTION sys.ps_is_instrument_default_timed; expected 1, got 2
The same applies when we don’t pass any arguments:
SELECT sys.ps_is_instrument_default_timed( );
Result:
ERROR 1318 (42000): Incorrect number of arguments for FUNCTION sys.ps_is_instrument_default_timed; expected 1, got 0