> For the complete documentation index, see [llms.txt](https://docs.percona.com/percona-monitoring-and-management/3/llms.txt).

# QAN Stored metrics

Stored metrics captures queries after they complete, so you can review historical performance, find slow queries, and track optimization progress over time.

## Supported databases

Stored metrics supports MySQL, MongoDB, and PostgreSQL with the following requirements:

**MySQL**

- MySQL 5.1 or later (if using the slow query log)
- MySQL 5.6.9 or later (if using Performance Schema)
- 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 when using MySQL’s Performance Schema. See [Query Analytics with MySQL](https://docs.percona.com/percona-monitoring-and-management/3/use/qan/mysql.md#limitations-with-performance-schema).

**PostgreSQL**

- PostgreSQL 11 or later
- `pg_stat_monitor` extension (recommended) or `pg_stat_statements` extension
- Appropriate `shared_preload_libraries` configuration
- Superuser privileges for PMM monitoring account

**MongoDB**

- MongoDB 6.0 or later (4.4+ may work with limited features)

**Profiler requirements**

- Profiling enabled for Query Analytics
- Appropriate user roles: `clusterMonitor`, `read` (local), and custom monitoring roles
- For MongoDB 8.0+: Additional `directShardOperations` role required for sharded clusters

**Mongolog requirements**

- MongoDB configured to log slow operations to a file
- MongoDB server has write permissions to the log directory and file
- PMM agent has read permissions to the MongoDB log file
- Appropriate user roles: `clusterMonitor`, or custom monitoring roles (`getCmdLineOpts` privilege on `{ cluster: true }`)

## Dashboard layout

The Stored metrics view contains three panels:

- [Filters panel](https://docs.percona.com/percona-monitoring-and-management/3/use/qan/panels/filters.md): narrow results by database, service, or query type
- [Overview panel](https://docs.percona.com/percona-monitoring-and-management/3/use/qan/panels/overview.md): see query metrics and trends
- [Details panel](https://docs.percona.com/percona-monitoring-and-management/3/use/qan/panels/details.md): examine individual query performance

## Data collection

Stored metrics collects data once per minute. When collection delays occur, gaps may appear in the sparkline.

## Monitor PMM Server’s internal PostgreSQL

By default, Query Analytics hides queries from PMM Server’s internal PostgreSQL database. This keeps the focus on your monitored databases.

Enable this when you need to troubleshoot PMM Server performance, check resource usage, or ensure applications are not accidentally using the default `postgres` database. This is particularly useful in [High Availability (HA) deployments](https://docs.percona.com/percona-monitoring-and-management/3/install-pmm/HA.md).

To enable:

1. Go to **Configuration > Settings > Advanced settings**.
1. Switch on the **QAN for PMM Server** option.
1. Open **Query Analytics** and filter by `pmm-server-postgresql` to view queries.

If PMM Server was started with the `PMM_ENABLE_INTERNAL_PG_QAN` environment variable, the variable decides whether this QAN is on. PMM refuses to switch it the other way, both from the **QAN for PMM Server** option and from `pmm-admin inventory change agent`. To control it from the UI, start PMM Server without the variable. See [Configure environment variables for PMM Server](https://docs.percona.com/percona-monitoring-and-management/3/install-pmm/install-pmm-server/deployment-options/docker/env_var.md).

When enabled, you’ll see queries related to PMM’s internal operations: inventory, settings, Advisor checks, alerts, backups, and authentication. These are usually lightweight, but unusual spikes may indicate performance issues.

Warning

Do not use PMM Server’s PostgreSQL database for application workloads. Use dedicated databases for your applications.

## See also

- [Real-time Query Analytics](https://docs.percona.com/percona-monitoring-and-management/3/use/qan/QAN-realtime-analytics.md)
- [Filters panel](https://docs.percona.com/percona-monitoring-and-management/3/use/qan/panels/filters.md)
- [Overview panel](https://docs.percona.com/percona-monitoring-and-management/3/use/qan/panels/overview.md)
- [Details panel](https://docs.percona.com/percona-monitoring-and-management/3/use/qan/panels/details.md)
