All Products
Search
Document Center

PolarDB:Performance Agent

Last Updated:Mar 28, 2026

Performance Agent is a PolarDB for MySQL plug-in that writes node-level performance statistics to an in-memory table at a configurable interval. Query the table directly with SQL or connect it to a monitoring platform like Grafana to track CPU, memory, I/O, connections, and InnoDB engine metrics in real time.

Prerequisites

Before you begin, ensure that you have:

How it works

Performance Agent collects performance data at a configurable interval and writes each snapshot as a row into the PERF_STATISTICS memory table in the performance_schema system database. The table stores the performance data that is generated over the most recent period of time.

Note

Enabling performance_schema lets you monitor locks, transactions, and memory metrics, but it consumes a significant amount of system memory and can affect cluster performance. It is disabled by default in PolarDB for MySQL. If you enable it, configure only the metrics you need based on your cluster's specifications and available resources.

Parameters

ParameterDescriptionDefault
performance_agent_enabledEnables or disables Performance Agent. Valid values: ON, OFF.ON
performance_agent_intervalHow often Performance Agent collects data. Valid values: 1–60. Unit: seconds.1
performance_agent_perfstat_volume_sizeMaximum number of rows in the PERF_STATISTICS table.3600

With the defaults (interval = 1, volume_size = 3600), the table retains approximately one hour of data.

To modify these parameters, see Specify cluster and node parameters.

PERF_STATISTICS table

Schema

CREATE TEMPORARY TABLE `PERF_STATISTICS` (
  `TIME` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `PROCS_MEM_USAGE` double NOT NULL DEFAULT '0',
  `PROCS_CPU_RATIO` double NOT NULL DEFAULT '0',
  `PROCS_IOPS` double NOT NULL DEFAULT '0',
  `PROCS_IO_READ_BYTES` bigint(21) NOT NULL DEFAULT '0',
  `PROCS_IO_WRITE_BYTES` bigint(21) NOT NULL DEFAULT '0',
  `MYSQL_CONN_ABORT` int(11) NOT NULL DEFAULT '0',
  `MYSQL_CONN_CREATED` int(11) NOT NULL DEFAULT '0',
  `MYSQL_USER_CONN_COUNT` int(11) NOT NULL DEFAULT '0',
  `MYSQL_CONN_RUNNING` int(11) NOT NULL DEFAULT '0',
  `MYSQL_LOCK_IMMEDIATE` int(11) NOT NULL DEFAULT '0',
  `MYSQL_LOCK_WAITED` int(11) NOT NULL DEFAULT '0',
  `MYSQL_COM_INSERT` int(11) NOT NULL DEFAULT '0',
  `MYSQL_COM_UPDATE` int(11) NOT NULL DEFAULT '0',
  `MYSQL_COM_DELETE` int(11) NOT NULL DEFAULT '0',
  `MYSQL_COM_SELECT` int(11) NOT NULL DEFAULT '0',
  `MYSQL_COM_COMMIT` int(11) NOT NULL DEFAULT '0',
  `MYSQL_COM_ROLLBACK` int(11) NOT NULL DEFAULT '0',
  `MYSQL_COM_PREPARE` int(11) NOT NULL DEFAULT '0',
  `MYSQL_LONG_QUERY` int(11) NOT NULL DEFAULT '0',
  `MYSQL_TCACHE_GET` bigint(21) NOT NULL DEFAULT '0',
  `MYSQL_TCACHE_MISS` bigint(21) NOT NULL DEFAULT '0',
  `MYSQL_TMPFILE_CREATED` int(11) NOT NULL DEFAULT '0',
  `MYSQL_TMP_TABLES` int(11) NOT NULL DEFAULT '0',
  `MYSQL_TMP_DISKTABLES` int(11) NOT NULL DEFAULT '0',
  `MYSQL_SORT_MERGE` int(11) NOT NULL DEFAULT '0',
  `MYSQL_SORT_ROWS` int(11) NOT NULL DEFAULT '0',
  `MYSQL_BYTES_RECEIVED` bigint(21) NOT NULL DEFAULT '0',
  `MYSQL_BYTES_SENT` bigint(21) NOT NULL DEFAULT '0',
  `MYSQL_BINLOG_OFFSET` int(11) NOT NULL DEFAULT '0',
  `MYSQL_IOLOG_OFFSET` int(11) NOT NULL DEFAULT '0',
  `MYSQL_RELAYLOG_OFFSET` int(11) NOT NULL DEFAULT '0',
  `EXTRA` json NOT NULL DEFAULT 'null'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Column reference

Columns are grouped by functional area.

System resources

ColumnDescription
TIMETimestamp of the row. Format: yyyy-MM-dd HH:mm:ss.
PROCS_MEM_USAGEPhysical memory used by the cluster. Unit: bytes.
PROCS_CPU_RATIOCPU utilization.
PROCS_IOPSNumber of I/O operations performed.
PROCS_IO_READ_BYTESData read by I/O operations. Unit: bytes.
PROCS_IO_WRITE_BYTESData written by I/O operations. Unit: bytes.

Connections and sessions

ColumnDescription
MYSQL_CONN_ABORTNumber of closed connections.
MYSQL_CONN_CREATEDNumber of new connections.
MYSQL_USER_CONN_COUNTTotal number of connections.
MYSQL_CONN_RUNNINGNumber of active connections.

Locks

ColumnDescription
MYSQL_LOCK_IMMEDIATENumber of locks held.
MYSQL_LOCK_WAITEDNumber of lock wait events.

SQL statements

ColumnDescription
MYSQL_COM_INSERTNumber of INSERT statements executed.
MYSQL_COM_UPDATENumber of UPDATE statements executed.
MYSQL_COM_DELETENumber of DELETE statements executed.
MYSQL_COM_SELECTNumber of SELECT statements executed.
MYSQL_COM_COMMITNumber of explicitly committed transactions.
MYSQL_COM_ROLLBACKNumber of rolled-back transactions.
MYSQL_COM_PREPARENumber of prepared statements.
MYSQL_LONG_QUERYNumber of slow queries.

Cache and temporary objects

ColumnDescription
MYSQL_TCACHE_GETNumber of cache hits.
MYSQL_TCACHE_MISSNumber of cache misses.
MYSQL_TMPFILE_CREATEDNumber of temporary files created.
MYSQL_TMP_TABLESNumber of temporary tables created.
MYSQL_TMP_DISKTABLESNumber of temporary disk tables created.

Sort operations

ColumnDescription
MYSQL_SORT_MERGENumber of times data is merged and sorted.
MYSQL_SORT_ROWSNumber of rows sorted.

Network and replication

ColumnDescription
MYSQL_BYTES_RECEIVEDData received by the node. Unit: bytes.
MYSQL_BYTES_SENTData sent by the node. Unit: bytes.
MYSQL_BINLOG_OFFSETSize of the binary log file generated. Unit: bytes.
MYSQL_IOLOG_OFFSETSize of the binary log file sent by the primary node. Unit: bytes.
MYSQL_RELAYLOG_OFFSETSize of the binary log file applied by the read-only node. Unit: bytes.

InnoDB engine (EXTRA column)

The EXTRA column stores InnoDB engine statistics as a JSON object. The values are equivalent to those returned by SHOW STATUS.

Use JSON path expressions to extract individual fields:

SELECT TIME, EXTRA->'$.INNODB_ROWS_READ', EXTRA->'$.INNODB_ROWS_INSERTED'
FROM performance_schema.PERF_STATISTICS
ORDER BY TIME DESC
LIMIT 30;
FieldDescription
INNODB_TRX_CNTNumber of transactions.
INNODB_DATA_READData read. Unit: bytes.
INNODB_IBUF_SIZENumber of pages merged.
INNODB_LOG_WAITSNumber of times InnoDB waited to write log data.
INNODB_MAX_PURGENumber of transactions deleted.
INNODB_N_WAITINGNumber of locks InnoDB is waiting for.
INNODB_ROWS_READNumber of rows read.
INNODB_LOG_WRITESNumber of times InnoDB wrote log data.
INNODB_IBUF_MERGESNumber of times data is merged by InnoDB.
INNODB_DATA_WRITTENData written. Unit: bytes.
INNODB_DBLWR_WRITESNumber of doublewrite operations.
INNODB_IBUF_SEGSIZESize of data inserted into the insert buffer.
INNODB_ROWS_DELETEDNumber of rows deleted.
INNODB_ROWS_UPDATEDNumber of rows updated.
INNODB_COMMIT_TRXCNTNumber of committed transactions.
INNODB_IBUF_FREELISTLength of the idle list.
INNODB_MYSQL_TRX_CNTNumber of MySQL transactions.
INNODB_ROWS_INSERTEDNumber of rows inserted.
INNODB_ACTIVE_TRX_CNTNumber of active transactions.
INNODB_OS_LOG_WRITTENLog data written to disk. Unit: bytes.
INNODB_ACTIVE_VIEW_CNTNumber of active views.
INNODB_RSEG_HISTORY_LENLength of the TRX_RSEG_HISTORY table.
INNODB_AVG_COMMIT_TRXTIMEAverage time to commit a transaction.
INNODB_MAX_COMMIT_TRXTIMEMaximum time to commit a transaction.
INNODB_DBLWR_PAGES_WRITTENNumber of pages written by doublewrite operations.

Query examples

All examples query performance_schema.PERF_STATISTICS and order results by TIME DESC.

Retrieve raw snapshots

Query CPU utilization and memory usage for the last 30 seconds:

MySQL> SELECT TIME, PROCS_MEM_USAGE, PROCS_CPU_RATIO
       FROM performance_schema.PERF_STATISTICS
       ORDER BY TIME DESC
       LIMIT 30;
+---------------------+-----------------+-----------------+
| TIME                | PROCS_MEM_USAGE | PROCS_CPU_RATIO |
+---------------------+-----------------+-----------------+
| 2020-02-27 11:15:36 |       857812992 |           18.55 |
| 2020-02-27 11:15:35 |       857808896 |           18.54 |
| 2020-02-27 11:15:34 |       857268224 |           19.64 |
| 2020-02-27 11:15:33 |       857268224 |           21.06 |
| 2020-02-27 11:15:32 |       857264128 |           20.39 |
| 2020-02-27 11:15:31 |       857272320 |           20.32 |
| 2020-02-27 11:15:30 |       857272320 |           21.35 |
| 2020-02-27 11:15:29 |       857272320 |            28.8 |
| 2020-02-27 11:15:28 |       857268224 |           29.08 |
| 2020-02-27 11:15:27 |       857268224 |           26.92 |
| 2020-02-27 11:15:26 |       857268224 |           23.84 |
| 2020-02-27 11:15:25 |       857264128 |           13.76 |
| 2020-02-27 11:15:24 |       857264128 |           15.12 |
| 2020-02-27 11:15:23 |       857264128 |           14.76 |
| 2020-02-27 11:15:22 |       857264128 |           15.38 |
| 2020-02-27 11:15:21 |       857260032 |           13.23 |
| 2020-02-27 11:15:20 |       857260032 |           12.75 |
| 2020-02-27 11:15:19 |       857260032 |           12.17 |
| 2020-02-27 11:15:18 |       857255936 |           13.22 |
| 2020-02-27 11:15:17 |       857255936 |           20.51 |
| 2020-02-27 11:15:16 |       857255936 |           28.74 |
| 2020-02-27 11:15:15 |       857251840 |           29.85 |
| 2020-02-27 11:15:14 |       857251840 |           29.31 |
| 2020-02-27 11:15:13 |       856981504 |           28.85 |
| 2020-02-27 11:15:12 |       856981504 |           29.19 |
| 2020-02-27 11:15:11 |       856977408 |           29.12 |
| 2020-02-27 11:15:10 |       856977408 |           29.32 |
| 2020-02-27 11:15:09 |       856977408 |            29.2 |
| 2020-02-27 11:15:08 |       856973312 |           29.36 |
| 2020-02-27 11:15:07 |       856973312 |           28.79 |
+---------------------+-----------------+-----------------+
30 rows in set (0.08 sec)

Query InnoDB rows read and inserted over the last 30 seconds:

MySQL> SELECT TIME, EXTRA->'$.INNODB_ROWS_READ', EXTRA->'$.INNODB_ROWS_INSERTED'
       FROM performance_schema.PERF_STATISTICS
       ORDER BY TIME DESC
       LIMIT 30;
+---------------------+-----------------------------+---------------------------------+
| TIME                | EXTRA->'$.INNODB_ROWS_READ' | EXTRA->'$.INNODB_ROWS_INSERTED' |
+---------------------+-----------------------------+---------------------------------+
| 2020-02-27 11:22:17 | 39209                       | 0                               |
| 2020-02-27 11:22:16 | 36098                       | 0                               |
| 2020-02-27 11:22:15 | 38035                       | 0                               |
| 2020-02-27 11:22:14 | 37384                       | 0                               |
| 2020-02-27 11:22:13 | 38336                       | 0                               |
| 2020-02-27 11:22:12 | 33946                       | 0                               |
| 2020-02-27 11:22:11 | 36301                       | 0                               |
| 2020-02-27 11:22:10 | 36835                       | 0                               |
| 2020-02-27 11:22:09 | 36900                       | 0                               |
| 2020-02-27 11:22:08 | 36402                       | 0                               |
| 2020-02-27 11:22:07 | 39672                       | 0                               |
| 2020-02-27 11:22:06 | 39316                       | 0                               |
| 2020-02-27 11:22:05 | 37830                       | 0                               |
| 2020-02-27 11:22:04 | 36396                       | 0                               |
| 2020-02-27 11:22:03 | 34820                       | 0                               |
| 2020-02-27 11:22:02 | 37350                       | 0                               |
| 2020-02-27 11:22:01 | 39463                       | 0                               |
| 2020-02-27 11:22:00 | 38419                       | 0                               |
| 2020-02-27 11:21:59 | 37673                       | 0                               |
| 2020-02-27 11:21:58 | 35117                       | 0                               |
| 2020-02-27 11:21:57 | 36140                       | 0                               |
| 2020-02-27 11:21:56 | 37592                       | 0                               |
| 2020-02-27 11:21:55 | 39765                       | 0                               |
| 2020-02-27 11:21:54 | 35553                       | 0                               |
| 2020-02-27 11:21:53 | 35882                       | 0                               |
| 2020-02-27 11:21:52 | 37061                       | 0                               |
| 2020-02-27 11:21:51 | 40699                       | 0                               |
| 2020-02-27 11:21:50 | 39608                       | 0                               |
| 2020-02-27 11:21:49 | 39317                       | 0                               |
| 2020-02-27 11:21:48 | 37413                       | 0                               |
+---------------------+-----------------------------+---------------------------------+
30 rows in set (0.08 sec)

Connect to a monitoring platform

Connect PERF_STATISTICS to an external monitoring platform to visualize metrics over time. The screenshot below shows an example Grafana dashboard connected to PolarDB performance data.

Grafana