# Performance Schema threads Table

Each server thread is represented as a row in the `threads` table.

The `threads` table contains the following columns:

| Column               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| THREAD\_ID           | A unique thread identifier.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| NAME                 | Name associated with the server's thread instrumentation code, for example thread/sql/main for the server's main() function, and thread/sql/one\_connection for a user connection.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| TYPE                 | FOREGROUND or BACKGROUND, depending on the thread type. User connection threads are FOREGROUND, internal server threads are BACKGROUND.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| PROCESSLIST\_ID      | The PROCESSLIST.ID value for threads displayed in the INFORMATION\_SCHEMA.PROCESSLIST table, or 0 for background threads. Also corresponds with the CONNECTION\_ID() return value for the thread.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| PROCESSLIST\_USER    | Foreground thread user, or NULL for a background thread.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| PROCESSLIST\_HOST    | Foreground thread host, or NULL for a background thread.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| PROCESSLIST\_DB      | Thread's default database, or NULL if none exists.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| PROCESSLIST\_COMMAND | Type of command executed by the thread. These correspond to the COM\_xxx client/server protocol commands, and the Com\_xxx [status variables](/docs/server/server-management/variables-and-modes/server-status-variables.md). See [Thread Command Values](/docs/server/ha-and-performance/optimization-and-tuning/buffers-caches-and-threads/thread-command-values.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| PROCESSLIST\_TIME    | Time in seconds the thread has been in its current state.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| PROCESSLIST\_STATE   | Action, event or state indicating what the thread is doing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| PROCESSLIST\_INFO    | Statement being executed by the thread, or NULL if a statement is not being executed. If a statement results in calling other statements, such as for a [stored procedure](/docs/server/server-usage/stored-routines/stored-procedures.md), the innermost statement from the stored procedure is shown here.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| PARENT\_THREAD\_ID   | THREAD\_ID of the parent thread, if any. Subthreads can for example be spawned as a result of [INSERT DELAYED](/docs/server/reference/sql-statements/data-manipulation/inserting-loading-data/insert-delayed.md) statements.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ROLE                 | Unused.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| INSTRUMENTED         | YES or NO for Whether the thread is instrumented or not. For foreground threads, the initial value is determined by whether there's a user/host match in the [setup\_actors](/docs/server/reference/system-tables/performance-schema/performance-schema-tables/performance-schema-setup_actors-table.md) table. Subthreads are again matched, while for background threads, this will be set to YES by default. To monitor events that the thread executes, INSTRUMENTED must be YES and the thread\_instrumentation consumer in the [setup\_consumers](/docs/server/reference/system-tables/performance-schema/performance-schema-tables/performance-schema-setup_consumers-table.md) table must also be YES.                                                                                                               |
| HISTORY              | YES or NO for Whether to log historical events for the thread. For foreground threads, the initial value is determined by whether there's a user/host match in the [setup\_actors](/docs/server/reference/system-tables/performance-schema/performance-schema-tables/performance-schema-setup_actors-table.md) table. Subthreads are again matched, while for background threads, this will be set to YES by default. To monitor events that the thread executes, INSTRUMENTED must be YES and the thread\_instrumentation consumer in the [setup\_consumers](/docs/server/reference/system-tables/performance-schema/performance-schema-tables/performance-schema-setup_consumers-table.md) table must also be YES. Added in [MariaDB 10.5](/docs/release-notes/community-server/old-releases/10.5/what-is-mariadb-105.md). |
| CONNECTION\_TYPE     | The protocol used to establish the connection. One of TCP/IP, SSL/TLS, Socket, Named Pipe, Shared Memory, or NULL for background threads. Added in [MariaDB 10.5](/docs/release-notes/community-server/old-releases/10.5/what-is-mariadb-105.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| THREAD\_OS\_ID       | The thread or task identifier as defined by the underlying operating system, if there is one. Added in [MariaDB 10.5](/docs/release-notes/community-server/old-releases/10.5/what-is-mariadb-105.md)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |

## Example

```sql
SELECT * FROM performance_schema.threads\G;
*************************** 1. row ***************************
          THREAD_ID: 1
               NAME: thread/sql/main
               TYPE: BACKGROUND
     PROCESSLIST_ID: NULL
   PROCESSLIST_USER: NULL
   PROCESSLIST_HOST: NULL
     PROCESSLIST_DB: NULL
PROCESSLIST_COMMAND: NULL
   PROCESSLIST_TIME: 215859
  PROCESSLIST_STATE: Table lock
   PROCESSLIST_INFO: INTERNAL DDL LOG RECOVER IN PROGRESS
   PARENT_THREAD_ID: NULL
               ROLE: NULL
       INSTRUMENTED: YES
...
*************************** 21. row ***************************
          THREAD_ID: 64
               NAME: thread/sql/one_connection
               TYPE: FOREGROUND
     PROCESSLIST_ID: 44
   PROCESSLIST_USER: root
   PROCESSLIST_HOST: localhost
     PROCESSLIST_DB: NULL
PROCESSLIST_COMMAND: Query
   PROCESSLIST_TIME: 0
  PROCESSLIST_STATE: Sending data
   PROCESSLIST_INFO: SELECT * FROM performance_schema.threads
   PARENT_THREAD_ID: NULL
               ROLE: NULL
       INSTRUMENTED: YES
```

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/system-tables/performance-schema/performance-schema-tables/performance-schema-threads-table.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
