Understanding MariaDB Performance Schema Instruments with ps_is_instrument_default_enabled


What it is

  • This particular function belongs to the sys schema, which contains functions and information for managing the MariaDB server itself.

  • ps_is_instrument_default_enabled is a stored function. In MariaDB, stored functions are pre-written SQL programs that you can call to perform specific tasks.

What it does

  • It returns either 'YES' if the instrument is enabled by default or 'NO' if it's not.

  • It takes the name of a Performance Schema instrument as input.

  • This function checks the default state of a specific Performance Schema instrument. The Performance Schema is a component in MariaDB that collects performance data about the server's operations.

Unfortunately, there isn't publicly available information about the internal programming logic behind this specific function.

However, the MariaDB Knowledge Base offers a page on ps_is_instrument_default_enabled that explains its functionality .



-- Check if the instrument 'wait/io/delay' is enabled by default
SELECT ps_is_instrument_default_enabled('wait/io/delay');

-- Check if an instrument with an unknown name is enabled by default
SELECT ps_is_instrument_default_enabled('some_unknown_instrument');

These examples use the function to check the default enabled state of two Performance Schema instruments:

  1. wait/io/delay: This instrument tracks I/O wait times.
  2. some_unknown_instrument: This is a fictional instrument name to show what the function returns for an instrument that doesn't exist.

The first query will return 'YES' or 'NO' depending on whether the wait/io/delay instrument is enabled by default in your MariaDB configuration.



  1. MariaDB Documentation
  1. Information Schema
  • While not directly indicating default states, you can query the INFORMATION_SCHEMA.INSTRUMENTS table. This table provides information about the available Performance Schema instruments.
SELECT NAME AS instrument_name, STATUS
FROM information_schema.INSTRUMENTS
WHERE NAME = 'wait/io/delay';

This query retrieves the name (instrument_name) and status (STATUS) of the wait/io/delay instrument. Possible values for STATUS include ENABLED or DISABLED. However, this doesn't tell you if it's the default state.

  1. Server Configuration File
  • The MariaDB configuration file (usually named my.cnf or mariadb.cnf) might contain settings related to enabling/disabling specific instruments. Search the file for keywords like "performance_schema" or the specific instrument name to see if there are manual overrides.