Documentation Home
MySQL 9.3 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.8Mb
PDF (A4) - 40.9Mb
Man Pages (TGZ) - 261.1Kb
Man Pages (Zip) - 368.3Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


MySQL 9.3 Reference Manual  / ...  / MySQL Performance Schema  / Performance Schema Table Descriptions  /  Performance Schema Connection Tables

29.12.8 Performance Schema Connection Tables

When a client connects to the MySQL server, it does so under a particular user name and from a particular host. The Performance Schema provides statistics about these connections, tracking them per account (user and host combination) as well as separately per user name and host name, using these tables:

  • accounts: Connection statistics per client account

  • hosts: Connection statistics per client host name

  • users: Connection statistics per client user name

The meaning ofaccount in the connection tables is similar to its meaning in the MySQL grant tables in themysql system database, in the sense that the term refers to a combination of user and host values. They differ in that, for grant tables, the host part of an account can be a pattern, whereas for Performance Schema tables, the host value is always a specific nonpattern host name.

Each connection table hasCURRENT_CONNECTIONS andTOTAL_CONNECTIONS columns to track the current and total number of connections pertracking value on which its statistics are based. The tables differ in what they use for the tracking value. Theaccounts table hasUSER andHOST columns to track connections per user and host combination. Theusers andhosts tables have aUSER andHOST column, respectively, to track connections per user name and host name.

The Performance Schema also counts internal threads and threads for user sessions that failed to authenticate, using rows withUSER andHOST column values ofNULL.

Suppose that clients nameduser1 anduser2 each connect one time fromhosta andhostb. The Performance Schema tracks the connections as follows:

  • Theaccounts table has four rows, for theuser1/hosta,user1/hostb,user2/hosta, anduser2/hostb account values, each row counting one connection per account.

  • Thehosts table has two rows, forhosta andhostb, each row counting two connections per host name.

  • Theusers table has two rows, foruser1 anduser2, each row counting two connections per user name.

When a client connects, the Performance Schema determines which row in each connection table applies, using the tracking value appropriate to each table. If there is no such row, one is added. Then the Performance Schema increments by one theCURRENT_CONNECTIONS andTOTAL_CONNECTIONS columns in that row.

When a client disconnects, the Performance Schema decrements by one theCURRENT_CONNECTIONS column in the row and leaves theTOTAL_CONNECTIONS column unchanged.

TRUNCATE TABLE is permitted for connection tables. It has these effects:

  • Rows are removed for accounts, hosts, or users that have no current connections (rows withCURRENT_CONNECTIONS = 0).

  • Nonremoved rows are reset to count only current connections: For rows withCURRENT_CONNECTIONS > 0,TOTAL_CONNECTIONS is reset toCURRENT_CONNECTIONS.

  • Summary tables that depend on the connection table are implicitly truncated, as described later in this section.

The Performance Schema maintains summary tables that aggregate connection statistics for various event types by account, host, or user. These tables have_summary_by_account,_summary_by_host, or_summary_by_user in the name. To identify them, use this query:

mysql> SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES       WHERE TABLE_SCHEMA = 'performance_schema'       AND TABLE_NAME REGEXP '_summary_by_(account|host|user)'       ORDER BY TABLE_NAME;+------------------------------------------------------+| TABLE_NAME                                           |+------------------------------------------------------+| events_errors_summary_by_account_by_error            || events_errors_summary_by_host_by_error               || events_errors_summary_by_user_by_error               || events_stages_summary_by_account_by_event_name       || events_stages_summary_by_host_by_event_name          || events_stages_summary_by_user_by_event_name          || events_statements_summary_by_account_by_event_name   || events_statements_summary_by_host_by_event_name      || events_statements_summary_by_user_by_event_name      || events_transactions_summary_by_account_by_event_name || events_transactions_summary_by_host_by_event_name    || events_transactions_summary_by_user_by_event_name    || events_waits_summary_by_account_by_event_name        || events_waits_summary_by_host_by_event_name           || events_waits_summary_by_user_by_event_name           || memory_summary_by_account_by_event_name              || memory_summary_by_host_by_event_name                 || memory_summary_by_user_by_event_name                 |+------------------------------------------------------+

For details about individual connection summary tables, consult the section that describes tables for the summarized event type:

TRUNCATE TABLE is permitted for connection summary tables. It removes rows for accounts, hosts, or users with no connections, and resets the summary columns to zero for the remaining rows. In addition, each summary table that is aggregated by account, host, user, or thread is implicitly truncated by truncation of the connection table on which it depends. The following table describes the relationship between connection table truncation and implicitly truncated tables.

Table 29.2 Implicit Effects of Connection Table Truncation

Truncated Connection TableImplicitly Truncated Summary Tables
accountsTables with names containing_summary_by_account,_summary_by_thread
hostsTables with names containing_summary_by_account,_summary_by_host,_summary_by_thread
usersTables with names containing_summary_by_account,_summary_by_user,_summary_by_thread

Truncating a_summary_global summary table also implicitly truncates its corresponding connection and thread summary tables. For example, truncatingevents_waits_summary_global_by_event_name implicitly truncates the wait event summary tables that are aggregated by account, host, user, or thread.