How SQL operations affect real-time statistics counters
Db2 updates its in-memory real-time statistics (RTS) counters for SQL operations such as INSERT, DELETE, and UPDATE, and externalizes the values to the RTS tables in the catalog at a specified interval and for certain events.
The following table shows the real-time statistics counters that Db2 updates for a specific types of SQL statements.
| SQL statement issued | Incremented counters |
|---|---|
| UPDATE | Update |
| INSERT | Insert |
| DELETE | Delete |
| ROLLBACK (or implicit rollback occurs) | Depends on the type of rolled-back SQL statements:
|
At the interval specified by the STATSINT subsystem parameter or at certain events, Db2 externalizes the RTS counter values to the counter columns in SYSIBM.SYSTABLESPACESTATS and SYSIBM.SYSTABLESPACESTATS catalog tables, and calculates values for the totals columns, TOTALROWS and TOTALENTRIES, based on the counters. For more information, see When Db2 externalizes real-time statistics.
If an insert, update, or delete counter column value in the catalog is 2147483647, the actual number of inserts, updates, or deletes might be greater than this value. However, this limitation does not apply to the calculated totals column values. For more information, see Accuracy of real-time statistics.
UPDATE of partitioning keys
| Action | Incremented counters |
|---|---|
| When UPDATE is executed |
|
| When UPDATE is committed |
|
| When UPDATE is rolled back |
|
If an update to a partitioning key does not cause rows to move to a new partition, the counts are accumulated as expected:
| Action | Incremented counters |
|---|---|
| When UPDATE is executed |
|
| When UPDATE is rolled back |
|