Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 30.1Mb
PDF (A4) - 30.3Mb
PDF (RPM) - 30.2Mb
EPUB - 7.8Mb
HTML Download (TGZ) - 7.6Mb
HTML Download (Zip) - 7.6Mb
HTML Download (RPM) - 6.6Mb
Eclipse Doc Plugin (TGZ) - 8.3Mb
Eclipse Doc Plugin (Zip) - 10.2Mb
Man Pages (TGZ) - 200.0Kb
Man Pages (Zip) - 311.5Kb
Info (Gzip) - 2.9Mb
Info (Zip) - 2.9Mb
Excerpts from this Manual The threads Table

The threads table contains a row for each server thread. Each row contains information about a thread and indicates whether monitoring is enabled for it:

mysql> SELECT * FROM threads\G
*************************** 1. row ***************************
          THREAD_ID: 1
               NAME: thread/sql/main
               TYPE: BACKGROUND
               ROLE: NULL
*************************** 4. row ***************************
          THREAD_ID: 51
               NAME: thread/sql/one_connection
               TYPE: FOREGROUND
   PROCESSLIST_HOST: localhost
     PROCESSLIST_DB: performance_schema
               ROLE: NULL

When the Performance Schema initializes, it populates the threads table based on the threads in existence then. Thereafter, a new row is added each time the server creates a thread.

The INSTRUMENTED column value for new threads is determined by the contents of the setup_actors table. For information about how to use the setup_actors table to control this column, see Section, “Pre-Filtering by Thread”.

Removal of rows from the threads table occurs when threads end. For a thread associated with a client session, removal occurs when the session ends. If a client has auto-reconnect enabled and the session reconnects after a disconnect, the session becomes associated with a new row in the threads table that has a different PROCESSLIST_ID value. The initial INSTRUMENTED value for the new thread may be different from that of the original thread: The setup_actors table may have changed in the meantime, and if the INSTRUMENTED value for the original thread was changed after it was initialized, that change does not carry over to the new thread.

The threads table columns with names having a prefix of PROCESSLIST_ provide information similar to that available from the INFORMATION_SCHEMA.PROCESSLIST table or the SHOW PROCESSLIST statement. Thus, all three sources provide thread-monitoring information. Use of threads differs from use of the other two sources in these ways:

  • Access to threads does not require a mutex and has minimal impact on server performance. INFORMATION_SCHEMA.PROCESSLIST and SHOW PROCESSLIST have negative performance consequences because they require a mutex.

  • threads provides additional information for each thread, such as whether it is a foreground or background thread, and the location within the server associated with the thread.

  • threads provides information about background threads, so it can be used to monitor activity the other thread information sources cannot.

  • You can enable or disable thread monitoring (that is, whether events executed by the thread are instrumented). To control the initial INSTRUMENTED value for new foreground threads, use the setup_actors table. To control monitoring of existing threads, set the INSTRUMENTED column of threads table rows. (For more information about the conditions under which thread monitoring occurs, see the description of the INSTRUMENTED column.)

For these reasons, DBAs who perform server monitoring using INFORMATION_SCHEMA.PROCESSLIST or SHOW PROCESSLIST may wish to monitor using the threads table instead.


For INFORMATION_SCHEMA.PROCESSLIST and SHOW PROCESSLIST, information about threads for other users is shown only if the current user has the PROCESS privilege. That is not true of the threads table; all rows are shown to any user who has the SELECT privilege for the table. Users who should not be able to see threads for other users should not be given that privilege.

The threads table has these columns:


    A unique thread identifier.

  • NAME

    The name associated with the thread instrumentation code in the server. For example, thread/sql/one_connection corresponds to the thread function in the code responsible for handling a user connection, and thread/sql/main stands for the main() function of the server.

  • TYPE

    The thread type, either FOREGROUND or BACKGROUND. User connection threads are foreground threads. Threads associated with internal server activity are background threads. Examples are internal InnoDB threads, binlog dump threads sending information to slaves, and slave I/O and SQL threads.


    For threads that are displayed in the INFORMATION_SCHEMA.PROCESSLIST table, this is the same value displayed in the ID column of that table. It is also the value displayed in the Id column of SHOW PROCESSLIST output, and the value that CONNECTION_ID() would return within that thread.

    For background threads (threads not associated with a user connection), PROCESSLIST_ID is NULL, so the values are not unique. (Before MySQL 5.6.9, the value is 0 for background threads.)


    The user associated with a foreground thread, NULL for a background thread.


    The host name of the client associated with a foreground thread, NULL for a background thread.


    The default database for the thread, or NULL if there is none.


    For foreground threads, the type of command the thread is executing on behalf of the client, or Sleep if the session is idle. For descriptions of thread commands, see Section 8.14, “Examining Thread Information”. The value of this column corresponds to the COM_xxx commands of the client/server protocol and Com_xxx status variables. See Section 5.1.6, “Server Status Variables”

    Background threads do not execute commands on behalf of clients, so this column may be NULL.


    The time in seconds that the thread has been in its current state.


    An action, event, or state that indicates what the thread is doing. For descriptions of PROCESSLIST_STATE values, see Section 8.14, “Examining Thread Information”. If the value if NULL, the thread may correspond to an idle client session or the work it is doing is not instrumented with stages.

    Most states correspond to very quick operations. If a thread stays in a given state for many seconds, there might be a problem that bears investigation.


    The statement the thread is executing, or NULL if it is not executing any statement. The statement might be the one sent to the server, or an innermost statement if the statement executes other statements. For example, if a CALL statement executes a stored procedure that is executing a SELECT statement, the PROCESSLIST_INFO value shows the SELECT statement.


    If this thread is a subthread (spawned by another thread), this is the THREAD_ID value of the spawning thread. Thread spawning occurs, for example, to handle insertion of rows from INSERT DELAYED statements.

  • ROLE



    Whether events executed by the thread are instrumented. The value is YES or NO.

    • For foreground threads, the initial INSTRUMENTED value is determined by whether the user account associated with the thread matches any row in the setup_actors table. Matching is based on the values of the PROCESSLIST_USER and PROCESSLIST_HOST columns.

      If the thread spawns a subthread, matching occurs again for the threads table row created for the subthread.

    • For background threads, INSTRUMENTED is YES by default. setup_actors is not consulted because there is no associated user for background threads.

    • For any thread, its INSTRUMENTED value can be changed during the lifetime of the thread. This is the only threads table column that can be modified.

    For monitoring of events executed by the thread to occur, these things must be true:

    • The thread_instrumentation consumer in the setup_consumers table must be YES.

    • The threads.INSTRUMENTED column must be YES.

    • Monitoring occurs only for those thread events produced from instruments that have the ENABLED column set to YES in the setup_instruments table.

Download this Manual
PDF (US Ltr) - 30.1Mb
PDF (A4) - 30.3Mb
PDF (RPM) - 30.2Mb
EPUB - 7.8Mb
HTML Download (TGZ) - 7.6Mb
HTML Download (Zip) - 7.6Mb
HTML Download (RPM) - 6.6Mb
Eclipse Doc Plugin (TGZ) - 8.3Mb
Eclipse Doc Plugin (Zip) - 10.2Mb
Man Pages (TGZ) - 200.0Kb
Man Pages (Zip) - 311.5Kb
Info (Gzip) - 2.9Mb
Info (Zip) - 2.9Mb
User Comments
Sign Up Login You must be logged in to post a comment.