Information Schema USER_STATISTICS Table

The Information Schema USER_STATISTICS table holds statistics about user activity. This is part of the User Statistics feature, which is not enabled by default.

You can use this table to find out such things as which user is causing the most load and which users are being abusive. You can also use this table to measure how close to capacity the server may be.

It contains the following columns:

Field Type Notes
USER varchar(48) The username. The value '#mysql_system_user#' appears when there is no username (such as for the slave SQL thread).
TOTAL_CONNECTIONS int(21) The number of connections created for this user.
CONCURRENT_CONNECTIONS int(21) The number of concurrent connections for this user.
CONNECTED_TIME int(21) The cumulative number of seconds elapsed while there were connections from this user.
BUSY_TIME double The cumulative number of seconds there was activity on connections from this user.
CPU_TIME double The cumulative CPU time elapsed while servicing this user's connections.
BYTES_RECEIVED int(21) The number of bytes received from this user's connections.
BYTES_SENT int(21) The number of bytes sent to this user's connections.
BINLOG_BYTES_WRITTEN int(21) The number of bytes written to the binary log from this user's connections.
ROWS_READ int(21) The number of rows read by this user's connections.
ROWS_SENT int(21) The number of rows sent by this user's connections.
ROWS_DELETED int(21) The number of rows deleted by this user's connections.
ROWS_INSERTED int(21) The number of rows inserted by this user's connections.
ROWS_UPDATED int(21) The number of rows updated by this user's connections.
SELECT_COMMANDS int(21) The number of SELECT commands executed from this user's connections.
UPDATE_COMMANDS int(21) The number of UPDATE commands executed from this user's connections.
OTHER_COMMANDS int(21) The number of other commands executed from this user's connections.
COMMIT_TRANSACTIONS int(21) The number of COMMIT commands issued by this user's connections.
ROLLBACK_TRANSACTIONS int(21) The number of ROLLBACK commands issued by this user's connections.
DENIED_CONNECTIONS int(21) The number of connections denied to this user.
LOST_CONNECTIONS int(21) The number of this user's connections that were terminated uncleanly.
ACCESS_DENIED int(21) The number of times this user's connections issued commands that were denied.
EMPTY_QUERIES int(21) The number of times this user's connections sent empty queries to the server.
TOTAL_SSL_CONNECTIONS int(21) The number of TLS connections created for this user. (>= MariaDB 10.1.1)
MAX_STATEMENT_TIME_EXCEEDED int(21) The number of times a statement was aborted, because it was executed longer than its MAX_STATEMENT_TIME threshold. (>= MariaDB 10.1.1)

Example

SELECT * FROM information_schema.USER_STATISTICS\G
*************************** 1. row ***************************
                  USER: root
     TOTAL_CONNECTIONS: 1
CONCURRENT_CONNECTIONS: 0
        CONNECTED_TIME: 297
             BUSY_TIME: 0.001725
              CPU_TIME: 0.001982
        BYTES_RECEIVED: 388
            BYTES_SENT: 2327
  BINLOG_BYTES_WRITTEN: 0
             ROWS_READ: 0
             ROWS_SENT: 12
          ROWS_DELETED: 0
         ROWS_INSERTED: 13
          ROWS_UPDATED: 0
       SELECT_COMMANDS: 4
       UPDATE_COMMANDS: 0
        OTHER_COMMANDS: 3
   COMMIT_TRANSACTIONS: 0
 ROLLBACK_TRANSACTIONS: 0
    DENIED_CONNECTIONS: 0
      LOST_CONNECTIONS: 0
         ACCESS_DENIED: 0
         EMPTY_QUERIES: 1
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.

© 2021 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/information-schema-user_statistics-table/