The INNODB_TRX table contains
information about every transaction currently executing inside
InnoDB, including whether the transaction is
waiting for a lock, when the transaction started, and the SQL
statement the transaction is executing, if any.
Table 21.8 INNODB_TRX Columns
| Column name | Description |
|---|---|
TRX_ID | Unique transaction ID number, internal to InnoDB.
(Starting in MySQL 5.6, these IDs are not created for
transactions that are read only and nonlocking. See
Optimizing InnoDB Read-Only Transactions for details.) |
TRX_WEIGHT | The weight of a transaction, reflecting (but not necessarily the exact
count of) the number of rows altered and the number of
rows locked by the transaction. To resolve a deadlock,
InnoDB selects the transaction with the
smallest weight as the “victim” to roll back.
Transactions that have changed non-transactional tables
are considered heavier than others, regardless of the
number of altered and locked rows. |
TRX_STATE | Transaction execution state. Permitted values are
RUNNING, LOCK WAIT,
ROLLING BACK, and
COMMITTING. |
TRX_STARTED | Transaction start time. |
TRX_REQUESTED_LOCK_ID | ID of the lock the transaction is currently waiting for, if
TRX_STATE is LOCK
WAIT; otherwise NULL. To
obtain details about the lock, join this column with the
LOCK_ID column of the
INNODB_LOCKS table. |
TRX_WAIT_STARTED | Time when the transaction started waiting on the lock, if
TRX_STATE is LOCK
WAIT; otherwise NULL. |
TRX_MYSQL_THREAD_ID | MySQL thread ID. To obtain details about the thread, join this column
with the ID column of the
INFORMATION_SCHEMA
PROCESSLIST table, but see
Section 14.18.2.3, “Persistence and Consistency of InnoDB Transaction and Locking
Information”. |
TRX_QUERY | The SQL statement that is being executed by the transaction. |
TRX_OPERATION_STATE | The transaction's current operation, if any; otherwise
NULL. |
TRX_TABLES_IN_USE | The number of InnoDB tables used while processing the
current SQL statement of this transaction. |
TRX_TABLES_LOCKED | Number of InnoDB tables that the current SQL
statement has row locks on. (Because these are row locks,
not table locks, the tables can usually still be read from
and written to by multiple transactions, despite some rows
being locked.) |
TRX_LOCK_STRUCTS | The number of locks reserved by the transaction. |
TRX_LOCK_MEMORY_BYTES | Total size taken up by the lock structures of this transaction in memory. |
TRX_ROWS_LOCKED | Approximate number or rows locked by this transaction. The value might include delete-marked rows that are physically present but not visible to the transaction. |
TRX_ROWS_MODIFIED | The number of modified and inserted rows in this transaction. |
TRX_CONCURRENCY_TICKETS | A value indicating how much work the current transaction can do before
being swapped out, as specified by the
innodb_concurrency_tickets
system variable. |
TRX_ISOLATION_LEVEL | The isolation level of the current transaction. |
TRX_UNIQUE_CHECKS | Whether unique checks are turned on or off for the current transaction. For example, they might be turned off during a bulk data load. |
TRX_FOREIGN_KEY_CHECKS | Whether foreign key checks are turned on or off for the current transaction. For example, they might be turned off during a bulk data load. |
TRX_LAST_FOREIGN_KEY_ERROR | Detailed error message for the last foreign key error, if any; otherwise
NULL. |
TRX_ADAPTIVE_HASH_LATCHED | Whether the adaptive hash index is locked by the current transaction. (Only a single transaction at a time can modify the adaptive hash index.) |
TRX_ADAPTIVE_HASH_TIMEOUT | Whether to relinquish the search latch immediately for the adaptive hash index, or reserve it across calls from MySQL. When there is no adaptive hash index contention, this value remains zero and statements reserve the latch until they finish. During times of contention, it counts down to zero, and statements release the latch immediately after each row lookup. |
Example:
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX\G
*************************** 1. row ***************************
trx_id: 3B7
trx_state: RUNNING
trx_started: 2014-11-19 14:33:45
trx_requested_lock_id: NULL
trx_wait_started: NULL
trx_weight: 1
trx_mysql_thread_id: 2
trx_query: SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX
trx_operation_state: NULL
trx_tables_in_use: 0
trx_tables_locked: 0
trx_lock_structs: 1
trx_lock_memory_bytes: 376
trx_rows_locked: 0
trx_rows_modified: 0
trx_concurrency_tickets: 0
trx_isolation_level: REPEATABLE READ
trx_unique_checks: 1
trx_foreign_key_checks: 1
trx_last_foreign_key_error: NULL
trx_adaptive_hash_latched: 0
trx_adaptive_hash_timeout: 10000
*************************** 2. row ***************************
trx_id: 3B6
trx_state: RUNNING
trx_started: 2014-11-19 14:32:38
trx_requested_lock_id: NULL
trx_wait_started: NULL
trx_weight: 94055
trx_mysql_thread_id: 1
trx_query: DELETE FROM employees.salaries WHERE salary > 75000
trx_operation_state: updating or deleting
trx_tables_in_use: 1
trx_tables_locked: 1
trx_lock_structs: 841
trx_lock_memory_bytes: 129464
trx_rows_locked: 392752
trx_rows_modified: 93214
trx_concurrency_tickets: 0
trx_isolation_level: REPEATABLE READ
trx_unique_checks: 1
trx_foreign_key_checks: 1
trx_last_foreign_key_error: NULL
trx_adaptive_hash_latched: 0
trx_adaptive_hash_timeout: 10000
Notes:
Use this table to help diagnose performance problems that occur during times of heavy concurrent load. Its contents are updated as described in Section 14.18.2.3, “Persistence and Consistency of InnoDB Transaction and Locking Information”.
Use DESCRIBE or
SHOW COLUMNS to view additional
information about the columns of this table including data
types and default values.
You must have the PROCESS
privilege to query this table.
For usage information, see Section 14.18.2.1, “Using InnoDB Transaction and Locking Information”.