The INNODB_TRX table provides
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.
For usage information, see Section 17.15.2.1, “Using InnoDB Transaction and Locking Information”.
The INNODB_TRX table has these
columns:
TRX_IDA unique transaction ID number, internal to
InnoDB. These IDs are not created for transactions that are read only and nonlocking. For details, see Section 10.5.3, “Optimizing InnoDB Read-Only Transactions”.TRX_WEIGHTThe 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,
InnoDBselects the transaction with the smallest weight as the “victim” to roll back. Transactions that have changed nontransactional tables are considered heavier than others, regardless of the number of altered and locked rows.TRX_STATEThe transaction execution state. Permitted values are
RUNNING,LOCK WAIT,ROLLING BACK, andCOMMITTING.TRX_STARTEDThe transaction start time.
TRX_REQUESTED_LOCK_IDThe ID of the lock the transaction is currently waiting for, if
TRX_STATEisLOCK WAIT; otherwiseNULL. To obtain details about the lock, join this column with theENGINE_LOCK_IDcolumn of the Performance Schemadata_lockstable.TRX_WAIT_STARTEDThe time when the transaction started waiting on the lock, if
TRX_STATEisLOCK WAIT; otherwiseNULL.TRX_MYSQL_THREAD_IDThe MySQL thread ID. To obtain details about the thread, join this column with the
IDcolumn of theINFORMATION_SCHEMAPROCESSLISTtable, but see Section 17.15.2.3, “Persistence and Consistency of InnoDB Transaction and Locking Information”.TRX_QUERYThe SQL statement that is being executed by the transaction.
TRX_OPERATION_STATEThe transaction's current operation, if any; otherwise
NULL.TRX_TABLES_IN_USEThe number of
InnoDBtables used while processing the current SQL statement of this transaction.TRX_TABLES_LOCKEDThe number of
InnoDBtables 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_STRUCTSThe number of locks reserved by the transaction.
TRX_LOCK_MEMORY_BYTESThe total size taken up by the lock structures of this transaction in memory.
TRX_ROWS_LOCKEDThe 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_MODIFIEDThe number of modified and inserted rows in this transaction.
TRX_CONCURRENCY_TICKETSA value indicating how much work the current transaction can do before being swapped out, as specified by the
innodb_concurrency_ticketssystem variable.TRX_ISOLATION_LEVELThe isolation level of the current transaction.
TRX_UNIQUE_CHECKSWhether 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_CHECKSWhether 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_ERRORThe detailed error message for the last foreign key error, if any; otherwise
NULL.TRX_ADAPTIVE_HASH_LATCHEDWhether the adaptive hash index is locked by the current transaction. When the adaptive hash index search system is partitioned, a single transaction does not lock the entire adaptive hash index. Adaptive hash index partitioning is controlled by
innodb_adaptive_hash_index_parts, which is set to 8 by default.TRX_ADAPTIVE_HASH_TIMEOUTDeprecated in MySQL 5.7.8. Always returns 0.
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. When the adaptive hash index search system is partitioned (controlled by
innodb_adaptive_hash_index_parts), the value remains 0.TRX_IS_READ_ONLYA value of 1 indicates the transaction is read only.
TRX_AUTOCOMMIT_NON_LOCKINGA value of 1 indicates the transaction is a
SELECTstatement that does not use theFOR UPDATEorLOCK IN SHARED MODEclauses, and is executing withautocommitenabled so that the transaction contains only this one statement. When this column andTRX_IS_READ_ONLYare both 1,InnoDBoptimizes the transaction to reduce the overhead associated with transactions that change table data.TRX_SCHEDULE_WEIGHTThe transaction schedule weight assigned by the Contention-Aware Transaction Scheduling (CATS) algorithm to transactions waiting for a lock. The value is relative to the values of other transactions. A higher value has a greater weight. A value is computed only for transactions in a
LOCK WAITstate, as reported by theTRX_STATEcolumn. A NULL value is reported for transactions that are not waiting for a lock. TheTRX_SCHEDULE_WEIGHTvalue is different from theTRX_WEIGHTvalue, which is computed by a different algorithm for a different purpose.
Example
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX\G
*************************** 1. row ***************************
trx_id: 1510
trx_state: RUNNING
trx_started: 2014-11-19 13:24:40
trx_requested_lock_id: NULL
trx_wait_started: NULL
trx_weight: 586739
trx_mysql_thread_id: 2
trx_query: DELETE FROM employees.salaries WHERE salary > 65000
trx_operation_state: updating or deleting
trx_tables_in_use: 1
trx_tables_locked: 1
trx_lock_structs: 3003
trx_lock_memory_bytes: 450768
trx_rows_locked: 1407513
trx_rows_modified: 583736
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
trx_is_read_only: 0
trx_autocommit_non_locking: 0
trx_schedule_weight: NULL
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 17.15.2.3, “Persistence and Consistency of InnoDB Transaction and Locking Information”.
You must have the
PROCESSprivilege to query this table.Use the
INFORMATION_SCHEMACOLUMNStable or theSHOW COLUMNSstatement to view additional information about the columns of this table, including data types and default values.