

# SQL statistics for MariaDB and MySQL


MariaDB and MySQL collect SQL statistics only at the digest level. No statistics are shown at the statement level.

**Topics**
+ [

## Digest statistics for MariaDB and MySQL
](#USER_PerfInsights.UsingDashboard.AnalyzeDBLoad.AdditionalMetrics.MySQL.truncation)
+ [

## Per-second statistics for MariaDB and MySQL
](#USER_PerfInsights.UsingDashboard.AnalyzeDBLoad.AdditionalMetrics.MySQL.per-second)
+ [

## Per-call statistics for MariaDB and MySQL
](#USER_PerfInsights.UsingDashboard.AnalyzeDBLoad.AdditionalMetrics.MySQL.truncation.per-call)
+ [

## Primary statistics for MariaDB and MySQL
](#USER_PerfInsights.UsingDashboard.AnalyzeDBLoad.AdditionalMetrics.MySQL.primary)

## Digest statistics for MariaDB and MySQL


Performance Insights collects SQL digest statistics from the `events_statements_summary_by_digest` table. The `events_statements_summary_by_digest` table is managed by your database. 

The digest table doesn't have an eviction policy. When the table is full, the AWS Management Console shows the following message:

```
Performance Insights is unable to collect SQL Digest statistics on new queries because the table events_statements_summary_by_digest is full. 
Please truncate events_statements_summary_by_digest table to clear the issue. Check the User Guide for more details.
```

In this situation, MariaDB and MySQL don't track SQL queries. To address this issue, Performance Insights automatically truncates the digest table when both of the following conditions are met:
+ The table is full.
+ Performance Insights manages the Performance Schema automatically.

  For automatic management, the `performance_schema` parameter must be set to `0` and the **Source** must not be set to `user`. If Performance Insights isn't managing the Performance Schema automatically, see [Overview of the Performance Schema for Performance Insights on Amazon RDS for MariaDB or MySQL](USER_PerfInsights.EnableMySQL.md).

In the AWS CLI, check the source of a parameter value by running the [describe-db-parameters](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-parameters.html) command.

## Per-second statistics for MariaDB and MySQL


The following SQL statistics are available for MariaDB and MySQL DB instances.


| Metric | Unit | 
| --- | --- | 
| db.sql\$1tokenized.stats.count\$1star\$1per\$1sec | Calls per second | 
| db.sql\$1tokenized.stats.sum\$1timer\$1wait\$1per\$1sec | Average latency per second (in ms) | 
| db.sql\$1tokenized.stats.sum\$1select\$1full\$1join\$1per\$1sec | Select full join per second | 
| db.sql\$1tokenized.stats.sum\$1select\$1range\$1check\$1per\$1sec | Select range check per second | 
| db.sql\$1tokenized.stats.sum\$1select\$1scan\$1per\$1sec | Select scan per second | 
| db.sql\$1tokenized.stats.sum\$1sort\$1merge\$1passes\$1per\$1sec | Sort merge passes per second | 
| db.sql\$1tokenized.stats.sum\$1sort\$1scan\$1per\$1sec | Sort scans per second | 
| db.sql\$1tokenized.stats.sum\$1sort\$1range\$1per\$1sec | Sort ranges per second | 
| db.sql\$1tokenized.stats.sum\$1sort\$1rows\$1per\$1sec | Sort rows per second | 
| db.sql\$1tokenized.stats.sum\$1rows\$1affected\$1per\$1sec | Rows affected per second | 
| db.sql\$1tokenized.stats.sum\$1rows\$1examined\$1per\$1sec | Rows examined per second | 
| db.sql\$1tokenized.stats.sum\$1rows\$1sent\$1per\$1sec | Rows sent per second | 
| db.sql\$1tokenized.stats.sum\$1created\$1tmp\$1disk\$1tables\$1per\$1sec | Created temporary disk tables per second | 
| db.sql\$1tokenized.stats.sum\$1created\$1tmp\$1tables\$1per\$1sec | Created temporary tables per second | 
| db.sql\$1tokenized.stats.sum\$1lock\$1time\$1per\$1sec | Lock time per second (in ms) | 

## Per-call statistics for MariaDB and MySQL


The following metrics provide per call statistics for a SQL statement.


| Metric | Unit | 
| --- | --- | 
| db.sql\$1tokenized.stats.sum\$1timer\$1wait\$1per\$1call | Average latency per call (in ms)  | 
| db.sql\$1tokenized.stats.sum\$1select\$1full\$1join\$1per\$1call | Select full joins per call | 
| db.sql\$1tokenized.stats.sum\$1select\$1range\$1check\$1per\$1call | Select range check per call | 
| db.sql\$1tokenized.stats.sum\$1select\$1scan\$1per\$1call | Select scans per call | 
| db.sql\$1tokenized.stats.sum\$1sort\$1merge\$1passes\$1per\$1call | Sort merge passes per call | 
| db.sql\$1tokenized.stats.sum\$1sort\$1scan\$1per\$1call | Sort scans per call | 
| db.sql\$1tokenized.stats.sum\$1sort\$1range\$1per\$1call | Sort ranges per call | 
| db.sql\$1tokenized.stats.sum\$1sort\$1rows\$1per\$1call | Sort rows per call | 
| db.sql\$1tokenized.stats.sum\$1rows\$1affected\$1per\$1call | Rows affected per call | 
| db.sql\$1tokenized.stats.sum\$1rows\$1examined\$1per\$1call | Rows examined per call | 
| db.sql\$1tokenized.stats.sum\$1rows\$1sent\$1per\$1call | Rows sent per call | 
| db.sql\$1tokenized.stats.sum\$1created\$1tmp\$1disk\$1tables\$1per\$1call | Created temporary disk tables per call | 
| db.sql\$1tokenized.stats.sum\$1created\$1tmp\$1tables\$1per\$1call | Created temporary tables per call | 
| db.sql\$1tokenized.stats.sum\$1lock\$1time\$1per\$1call | Lock time per call (in ms) | 

## Primary statistics for MariaDB and MySQL


The following SQL statistics are available for MariaDB and MySQL DB instances.


| Metric | Unit | 
| --- | --- | 
| db.sql\$1tokenized.stats.count\$1star | Calls | 
| db.sql\$1tokenized.stats.sum\$1timer\$1wait | Wait time (in ms) | 
| db.sql\$1tokenized.stats.sum\$1select\$1full\$1join | Select full join | 
| db.sql\$1tokenized.stats.sum\$1select\$1range\$1check | Select range checks | 
| db.sql\$1tokenized.stats.sum\$1select\$1scan | Select scans | 
| db.sql\$1tokenized.stats.sum\$1sort\$1merge\$1passes | Sort merge passes | 
| db.sql\$1tokenized.stats.sum\$1sort\$1scan | Sort scans | 
| db.sql\$1tokenized.stats.sum\$1sort\$1range | Sort ranges | 
| db.sql\$1tokenized.stats.sum\$1sort\$1rows | Sort rows | 
| db.sql\$1tokenized.stats.sum\$1rows\$1affected | Rows affected | 
| db.sql\$1tokenized.stats.sum\$1rows\$1examined | Rows examined | 
| db.sql\$1tokenized.stats.sum\$1rows\$1sent | Rows sent | 
| db.sql\$1tokenized.stats.sum\$1created\$1tmp\$1disk\$1tables | Created temporary disk tables | 
| db.sql\$1tokenized.stats.sum\$1created\$1tmp\$1tables | Created temporary tables | 
| db.sql\$1tokenized.stats.sum\$1lock\$1time | Lock time (in ms) | 