Understanding the sys.ps_is_instrument_default_enabled() Function in MySQL

In MySQL, we can use the sys.ps_is_instrument_default_enabled() function to check whether a given Performance Schema instrument is enabled by default.

The function returns YES or NO, depending on whether the instrument is enabled by default.

Syntax

The syntax goes like this:

sys.ps_is_instrument_default_enabled(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_enabled('statement/sql/select');

Result:

YES

This shows that the statement/sql/select instrument is enabled by default.

Here’s one that’s disabled by default:

SELECT sys.ps_is_instrument_default_enabled('stage/sql/setup');

Result:

NO

Non-Existent Instrument

If the instrument doesn’t exist I get a YES:

SELECT sys.ps_is_instrument_default_enabled('homer/simpson');

Result:

YES

NULL Instrument

If the argument is NULL, then YES is returned:

SELECT sys.ps_is_instrument_default_enabled(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_enabled( NULL, NULL );

Result:

ERROR 1318 (42000): Incorrect number of arguments for FUNCTION sys.ps_is_instrument_default_enabled; expected 1, got 2

The same applies when we don’t pass any arguments:

SELECT sys.ps_is_instrument_default_enabled( );

Result:

ERROR 1318 (42000): Incorrect number of arguments for FUNCTION sys.ps_is_instrument_default_enabled; expected 1, got 0