Spec-Zone .ru
спецификации, руководства, описания, API

21.9.9.3. 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     PROCESSLIST_ID: NULL   PROCESSLIST_USER: NULL   PROCESSLIST_HOST: NULL     PROCESSLIST_DB: NULLPROCESSLIST_COMMAND: NULL   PROCESSLIST_TIME: 80284  PROCESSLIST_STATE: NULL   PROCESSLIST_INFO: NULL   PARENT_THREAD_ID: NULL               ROLE: NULL       INSTRUMENTED: YES...*************************** 4. row ***************************          THREAD_ID: 51               NAME: thread/sql/one_connection               TYPE: FOREGROUND     PROCESSLIST_ID: 34   PROCESSLIST_USER: paul   PROCESSLIST_HOST: localhost     PROCESSLIST_DB: performance_schemaPROCESSLIST_COMMAND: Query   PROCESSLIST_TIME: 0  PROCESSLIST_STATE: Sending data   PROCESSLIST_INFO: SELECT * FROM threads   PARENT_THREAD_ID: 1               ROLE: NULL       INSTRUMENTED: YES...

If you have the PROCESS privilege, you can see all threads. Otherwise, you can see only your own threads (that is, threads associated with the MySQL account that you are using).

The threads table has these columns:

The initial contents of the threads table are based on the threads in existence when Performance Schema initialization occurs. Thereafter, a new row is added each time the server creates a 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 will be associated with a new row in the threads table (one 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 PROCESS_ 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:

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