As of MySQL 5.6.3, the Performance Schema provides statistics about connections to the server. When a client connects, it does so under a particular user name and from a particular host. The Performance Schema tracks connections per account (user name plus host name) and separately per user name and per host name, using these tables:
There are also summary tables that aggregate information about connections. See Section 184.108.40.206, “Connection Summary Tables”.
The meaning of “account” in the connection tables
is similar to its meaning in the MySQL grant tables in the
mysql database, in the sense that the term
refers to a combination of user and host values. Where they
differ is that in the grant tables, the host part of an account
can be a pattern, whereas in the Performance Schema tables the
host value is always a specific nonpattern host name.
The connection tables all have
TOTAL_CONNECTIONS columns to track the
current and total number of connections per “tracking
value” on which statistics are based. The tables differ
in what they use for the tracking value. The
accounts table has
HOST columns to
track connections per user name plus host name combination. The
hosts tables have a
respectively, to track connections per user name and per host
Suppose that clients named
user2 each connect one time from
Performance Schema tracks the connections as follows:
accounts table will have
four rows, for the
values, each row counting one connection per account.
users table will have two
user2, each row counting two connections
per user name.
hosts table will have two
hostb, each row counting two connections
per host name.
When a client connects, the Performance Schema determines which
row in each connection table applies to the connection, using
the tracking value appropriate to each table. If there is no
such row, one is added. Then the Performance Schema increments
by one the
TOTAL_CONNECTIONS columns in that row.
When a client disconnects, the Performance Schema decrements by
CURRENT_CONNECTIONS column in the row
and leaves the
The Performance Schema also counts threads for internal threads
and user sessions that failed to authenticate. These are counted
in rows with
column values of
Each connection table can be truncated with
TRUNCATE TABLE, which has this
CURRENT_CONNECTIONS = 0 are
For rows with
CURRENT_CONNECTIONS > 0,
TOTAL_CONNECTIONS is reset to
Connection summary tables that depend on the connection table are truncated implicitly (summary values are set to 0). For more information about implicit truncation, see Section 220.127.116.11, “Connection Summary Tables”.