From ba220c17d18932bb1378c4c073be1fc66f5c5fb3 Mon Sep 17 00:00:00 2001 From: Dragos Andriciuc Date: Thu, 28 Aug 2025 15:18:20 +0300 Subject: [PATCH] removed limitation and refresh rate tuning from about QAN - add a link to the tab to the new topic - add a new topic for this limitation and refresh rate --- documentation/docs/use/qan/index.md | 48 +++-------------------------- documentation/docs/use/qan/mysql.md | 45 +++++++++++++++++++++++++++ documentation/mkdocs-base.yml | 1 + 3 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 documentation/docs/use/qan/mysql.md diff --git a/documentation/docs/use/qan/index.md b/documentation/docs/use/qan/index.md index 453928e12b1..f3497b5ed8e 100644 --- a/documentation/docs/use/qan/index.md +++ b/documentation/docs/use/qan/index.md @@ -12,6 +12,9 @@ Query Analytics supports MySQL, MongoDB and PostgreSQL with the following minimu - Percona Server 5.6+ (all Performance Schema and slow log features) - MariaDB 5.2+ (for user statistics), 10.0+ (for Performance Schema) + Some limitations and tuning options apply only when using MySQL’s Performance Schema. + See [Query Analytics with MySQL](../qan/mysql.md#limitations-with-performance-schema). + === "PostgreSQL requirements" - PostgreSQL 11 or later - `pg_stat_monitor` extension (recommended) or `pg_stat_statements` extension @@ -42,59 +45,16 @@ The dashboard contains three panels: - the [Overview panel](panels/overview.md) - the [Details panel](panels/details.md) - ### Data retrieval delays Query Analytics data retrieval is not instantaneous because metrics are collected once per minute. When collection delays occur, no data is reported and gaps will appear in the sparkline. ## Label-based access control -Query Analytics integrates with PMM's[label-based access control (LBAC)](../../admin/roles/access-control/intro.md) to enforce data security and user permissions. +Query Analytics integrates with PMM's [label-based access control (LBAC)](../../admin/roles/access-control/intro.md) to enforce data security and user permissions. When LBAC is enabled: - users see only queries from databases and services permitted by their assigned roles - filter dropdown options are dynamically restricted based on user permissions - data visibility is controlled through Prometheus-style label selectors - -## Limitation: Missing query examples in MySQL Performance Schema - -When using MySQL's Performance Schema as the query source, you may encounter the message *“Sorry, no examples found”* in the QAN dashboard. This typically occurs due to the way MySQL handles query sampling and can be influenced by the volume of unique queries, and Performance Schema settings. - -Despite the absence of query examples, all other query metrics are still collected and displayed as expected. - -### Why this happens - -MySQL Performance Schema manages query data across two different tables, which can lead to missing query examples: - -- Summary table (`events_statements_summary_by_digest`): stores aggregated metrics for each normalized query (digest) in a limited buffer. Each unique query appears only once, regardless of how many times it runs. - -- History table (`events_statements_history` or `events_statements_history_long` in MariaDB): stores individual query executions in a limited rolling buffer. Multiple entries may exist for the same query, but older ones are overwritten as new queries are executed. - -A query may appear in the digest summary but not in the history table when: - -- it was executed frequently enough to appear in the digest summary -- all its individual executions were overwritten in the history buffer due to high query volume overwhelming the buffer and ongoing activity - -When this happens, QAN can still display the query’s metrics, but cannot show an example query because it's no longer available in `events_statements_history` table when PMM tries to capture it. - -## Performance Schema refresh rate tuning - -PMM Agent includes a configurable **Performance Schema Refresh Rate** that can help capture more query examples. This setting controls how often PMM scrapes data from the history table. Using a shorter interval increases the likelihood that query examples will be captured before being overwritten. - -### Configuration options - -- Default value: 5 seconds -- Minimum value: 1 second -- Value of 0 uses the default (5 seconds) - -### How to configure -- environment variable: `PMM_AGENT_PERFSCHEMA_REFRESH_RATE`. -- flag for PMM agent binary: `--perfschema-refresh-rate=NUMBER`. -- property in PMM agent config: `perfschema-refresh-rate: NUMBER`. - -### Workaround - -If you're still missing some query examples, consider [using the slow query log (`slowlog`)](../../install-pmm/install-pmm-client/connect-database/mysql/mysql.md#configure-data-source) as the query source instead. -The `slowlog` retains actual query texts over time and can help capture examples even when Performance Schema history buffers are exhausted. - diff --git a/documentation/docs/use/qan/mysql.md b/documentation/docs/use/qan/mysql.md new file mode 100644 index 00000000000..f8f9f3cd1f1 --- /dev/null +++ b/documentation/docs/use/qan/mysql.md @@ -0,0 +1,45 @@ +# Query Analytics with MySQL + +## Limitations with Performance Schema + +### Missing query examples in MySQL Performance Schema + +When using MySQL's Performance Schema as the query source, you may encounter the message *“Sorry, no examples found”* in the QAN dashboard. This typically occurs due to the way MySQL handles query sampling and can be influenced by the volume of unique queries, and Performance Schema settings. + +Despite the absence of query examples, all other query metrics are still collected and displayed as expected. + +### Why this happens + +MySQL Performance Schema manages query data across two different tables, which can lead to missing query examples: + +- Summary table (`events_statements_summary_by_digest`): stores aggregated metrics for each normalized query (digest) in a limited buffer. Each unique query appears only once, regardless of how many times it runs. + +- History table (`events_statements_history` or `events_statements_history_long` in MariaDB): stores individual query executions in a limited rolling buffer. Multiple entries may exist for the same query, but older ones are overwritten as new queries are executed. + +A query may appear in the digest summary but not in the history table when: + +- it was executed frequently enough to appear in the digest summary +- all its individual executions were overwritten in the history buffer due to high query volume overwhelming the buffer and ongoing activity + +When this happens, QAN can still display the query’s metrics, but cannot show an example query because it's no longer available in `events_statements_history` table when PMM tries to capture it. + +## Performance Schema refresh rate tuning + +PMM Agent includes a configurable **Performance Schema Refresh Rate** that can help capture more query examples. This setting controls how often PMM scrapes data from the history table. Using a shorter interval increases the likelihood that query examples will be captured before being overwritten. + +### Configuration options + +- Default value: 5 seconds +- Minimum value: 1 second +- Value of 0 uses the default (5 seconds) + +### How to configure + +- environment variable: `PMM_AGENT_PERFSCHEMA_REFRESH_RATE`. +- flag for PMM agent binary: `--perfschema-refresh-rate=NUMBER`. +- property in PMM agent config: `perfschema-refresh-rate: NUMBER`. + +### Workaround + +If you're still missing some query examples, consider [using the slow query log (`slowlog`)](../../install-pmm/install-pmm-client/connect-database/mysql/mysql.md#configure-data-source) as the query source instead. +The `slowlog` retains actual query texts over time and can help capture examples even when Performance Schema history buffers are exhausted. diff --git a/documentation/mkdocs-base.yml b/documentation/mkdocs-base.yml index 9e65b5869b2..6fdb08dcf09 100644 --- a/documentation/mkdocs-base.yml +++ b/documentation/mkdocs-base.yml @@ -235,6 +235,7 @@ nav: - Annotate: use/dashboards-panels/annotate/annotate.md - Query Analytics: - use/qan/index.md + - use/qan/mysql.md - use/qan/qan_mongo.md - use/qan/share_link.md - Panels on QAN dashboard: