# Performance Schema events\_statements\_history\_long Table

The `events_statements_history_long` table by default contains the ten thousand most recent completed statement events. This number can be adjusted by setting the [performance\_schema\_events\_statements\_history\_long\_size](https://mariadb.com/docs/server/reference/system-tables/performance-schema-system-variables#performance_schema_events_statements_history_long_size) system variable when the server starts up.

The table structure is identical to the [events\_statements\_current](https://mariadb.com/docs/server/reference/system-tables/performance-schema/performance-schema-tables/performance-schema-events_statements_current-table) table structure, and contains the following columns:

| Column                     | Description                                                                                                                                                                                                                                                                             |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| THREAD\_ID                 | Thread associated with the event. Together with EVENT\_ID uniquely identifies the row.                                                                                                                                                                                                  |
| EVENT\_ID                  | Thread's current event number at the start of the event. Together with THREAD\_ID uniquely identifies the row.                                                                                                                                                                          |
| END\_EVENT\_ID             | NULL when the event starts, set to the thread's current event number at the end of the event.                                                                                                                                                                                           |
| EVENT\_NAME                | Event instrument name and a NAME from the setup\_instruments table                                                                                                                                                                                                                      |
| SOURCE                     | Name and line number of the source file containing the instrumented code that produced the event.                                                                                                                                                                                       |
| TIMER\_START               | Value in picoseconds when the event timing started or NULL if timing is not collected. Relative to the server start, not to the epoch, so cannot directly be converted to a timestamp.                                                                                                  |
| TIMER\_END                 | Value in picoseconds when the event timing ended, or NULL if timing is not collected. Relative to the server start, not to the epoch, so cannot directly be converted to a timestamp.                                                                                                   |
| TIMER\_WAIT                | Value in picoseconds of the event's duration or NULL if timing is not collected.                                                                                                                                                                                                        |
| LOCK\_TIME                 | Time in picoseconds spent waiting for locks. The time is calculated in microseconds but stored in picoseconds for compatibility with other timings.                                                                                                                                     |
| SQL\_TEXT                  | The SQL statement, or NULL if the command is not associated with an SQL statement.                                                                                                                                                                                                      |
| DIGEST                     | [Statement digest](https://mariadb.com/docs/server/reference/system-tables/performance-schema/performance-schema-digests).                                                                                                                                                              |
| DIGEST\_TEXT               | [Statement digest](https://mariadb.com/docs/server/reference/system-tables/performance-schema/performance-schema-digests) text.                                                                                                                                                         |
| CURRENT\_SCHEMA            | Statement's default database for the statement, or NULL if there was none.                                                                                                                                                                                                              |
| OBJECT\_SCHEMA             | Reserved, currently NULL                                                                                                                                                                                                                                                                |
| OBJECT\_NAME               | Reserved, currently NULL                                                                                                                                                                                                                                                                |
| OBJECT\_TYPE               | Reserved, currently NULL                                                                                                                                                                                                                                                                |
| OBJECT\_INSTANCE\_BEGIN    | Address in memory of the statement object.                                                                                                                                                                                                                                              |
| MYSQL\_ERRNO               | Error code. See [MariaDB Error Codes](https://mariadb.com/docs/server/reference/error-codes/mariadb-error-code-reference) for a full list.                                                                                                                                              |
| RETURNED\_SQLSTATE         | The [SQLSTATE](https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-diagnostics/sqlstate) value.                                                                                                                  |
| MESSAGE\_TEXT              | Statement error message. See [MariaDB Error Codes](https://mariadb.com/docs/server/reference/error-codes/mariadb-error-code-reference).                                                                                                                                                 |
| ERRORS                     | 0 if SQLSTATE signifies completion (starting with 00) or warning (01), otherwise 1.                                                                                                                                                                                                     |
| WARNINGS                   | Number of warnings from the diagnostics area.                                                                                                                                                                                                                                           |
| ROWS\_AFFECTED             | Number of rows affected the statement affected.                                                                                                                                                                                                                                         |
| ROWS\_SENT                 | Number of rows returned.                                                                                                                                                                                                                                                                |
| ROWS\_EXAMINED             | Number of rows read during the statement's execution.                                                                                                                                                                                                                                   |
| CREATED\_TMP\_DISK\_TABLES | Number of on-disk temp tables created by the statement.                                                                                                                                                                                                                                 |
| CREATED\_TMP\_TABLES       | Number of temp tables created by the statement.                                                                                                                                                                                                                                         |
| SELECT\_FULL\_JOIN         | Number of joins performed by the statement which did not use an index.                                                                                                                                                                                                                  |
| SELECT\_FULL\_RANGE\_JOIN  | Number of joins performed by the statement which used a range search of the first table.                                                                                                                                                                                                |
| SELECT\_RANGE              | Number of joins performed by the statement which used a range of the first table.                                                                                                                                                                                                       |
| SELECT\_RANGE\_CHECK       | Number of joins without keys performed by the statement that check for key usage after each row.                                                                                                                                                                                        |
| SELECT\_SCAN               | Number of joins performed by the statement which used a full scan of the first table.                                                                                                                                                                                                   |
| SORT\_MERGE\_PASSES        | Number of merge passes by the sort algorithm performed by the statement. If too high, you may need to increase the [sort\_buffer\_size](https://mariadb.com/docs/server/server-management/variables-and-modes/server-system-variables#sort_buffer_size).                                |
| SORT\_RANGE                | Number of sorts performed by the statement which used a range.                                                                                                                                                                                                                          |
| SORT\_ROWS                 | Number of rows sorted by the statement.                                                                                                                                                                                                                                                 |
| SORT\_SCAN                 | Number of sorts performed by the statement which used a full table scan.                                                                                                                                                                                                                |
| NO\_INDEX\_USED            | 0 if the statement performed a table scan with an index, 1 if without an index.                                                                                                                                                                                                         |
| NO\_GOOD\_INDEX\_USED      | 0 if a good index was found for the statement, 1 if no good index was found. See the Range checked for each record description in the [EXPLAIN](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/explain) article. |
| NESTING\_EVENT\_ID         | Reserved, currently NULL.                                                                                                                                                                                                                                                               |
| NESTING\_EVENT\_TYPE       | Reserved, currently NULL.                                                                                                                                                                                                                                                               |

It is possible to empty this table with a `TRUNCATE TABLE` statement.

[events\_statements\_current](https://mariadb.com/docs/server/reference/system-tables/performance-schema/performance-schema-tables/performance-schema-events_statements_current-table) and [events\_statements\_history](https://mariadb.com/docs/server/reference/system-tables/performance-schema/performance-schema-tables/performance-schema-events_statements_history-table) are related tables.

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

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