当前位置:网站首页>MySQL information schema learning (II) -- InnoDB table
MySQL information schema learning (II) -- InnoDB table
2022-07-06 19:30:00 【Night hunter - Demon King】
Learn about and innodb Related table .
1.INNODB_TRX
Provide information about each transaction currently executed internally Information about InnoDB
, Including whether the transaction is waiting for locking 、 When the transaction starts and what the transaction is executing SQL sentence .
The main Column :
TRX_ID
The only business ID NumberTRX_WEIGHT
The weight of the transaction , reflect ( But not necessarily the exact count ) Number of rows changed and transaction locked . In order to solve the deadlock ,InnoDB
Select the transaction with the smallest weight as “ The victim ” Roll back . Transactions that have changed non transactional tables are considered heavier than other transactions , No matter how many rows are changed and locked .TRX_STATE
Transaction execution status . The allowed values areRUNNING
、LOCK WAIT
、ROLLING BACK
andCOMMITTING
. You can judge whether a certain current transaction is waiting for a lockTRX_STARTED
Transaction start time .TRX_REQUESTED_LOCK_ID
The lock that the transaction is currently waiting for ID, IfTRX_STATE
yesLOCK WAIT
; otherwiseNULL
. To get more information about locks , Please compare this column with theLOCK_ID
Column Connect INNODB_LOCKS.
You can get the lock that the current transaction is waiting for , Easy to analyze deadlock problems .
TRX_WAIT_STARTED
The time when the transaction starts waiting for the lock , IfTRX_STATE
yesLOCK WAIT
; otherwiseNULL
.TRX_MYSQL_THREAD_ID
MySQL Threads ID. To get more information about threads , Please compare this column with theID
Column ConnectINFORMATION_SCHEMA
PROCESSLISTTRX_QUERY
The transaction is executing SQL sentence .TRX_OPERATION_STATE
The current operation of the transaction , If any ; otherwiseNULL
.TRX_TABLES_IN_USE
InnoDB
Process the current SQL Use The number of watches .TRX_TABLES_LOCKED
InnoDB
At present SQL Statement has a row lock Number of tables for .( Because these are row locks , Not a watch lock , So although some rows are locked , However, tables can usually still be read and written by multiple transactions .)TRX_LOCK_STRUCTS
Number of locks reserved by transaction .TRX_LOCK_MEMORY_BYTES
The total size of the lock structure of this transaction in memory .TRX_ROWS_LOCKED
The approximate number or rows locked by this transaction . The value may include delete tag lines that actually exist but are not visible to the transaction .TRX_ROWS_MODIFIED
Number of rows modified and inserted in this transaction .TRX_CONCURRENCY_TICKETS
A value , Indicates how much work the current transaction can do before it is swapped out , from innodb_concurrency_tickets The system variable specifies .TRX_ISOLATION_LEVEL
Isolation level of the current transaction .TRX_UNIQUE_CHECKS
Whether to turn unique checking on or off for the current transaction . for example , They may be turned off during bulk data loading .TRX_FOREIGN_KEY_CHECKS
Whether to turn foreign key checking on or off for the current transaction . for example , They may be turned off during bulk data loading .TRX_LAST_FOREIGN_KEY_ERROR
Detailed error information of the last foreign key error , If any ; otherwiseNULL
.TRX_ADAPTIVE_HASH_LATCHED
Whether 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 . The adaptive hash index partition is created by control innodb_adaptive_hash_index_parts, The default setting is 8.TRX_ADAPTIVE_HASH_TIMEOUT
Whether to discard the search latch of adaptive hash index immediately , Or from MySQL Keep it in the call of . When there is no adaptive hash index contention , This value remains at zero , And statements retain latches until they are complete . During the dispute , It counts down to zero , And the statement releases the latch immediately after each line lookup . When the adaptive hash index search system is partitioned ( from control innodb_adaptive_hash_index_parts) when , This value remains at 0.TRX_IS_READ_ONLY
value 1 Indicates that the transaction is read-only .TRX_AUTOCOMMIT_NON_LOCKING
value 1 Indicates that the transaction is SELECT Don't useFOR UPDATE
orLOCK IN SHARED MODE
Statement of clause , And execute when enabled , autocommit Therefore, the transaction only contains this statement . When this column andTRX_IS_READ_ONLY
Are all 1 when ,InnoDB
Optimize transactions to reduce the overhead associated with transactions that change table data .
2.INNODB_LOCKS
Provide relevant InnoDB
Information about each lock that the transaction has requested but has not yet acquired , And the information held by the transaction blocking each lock of another transaction . Main column :
LOCK_ID
A unique lock ID NumberLOCK_TRX_ID
Of the transaction that holds the lock ID. To get detailed information about transactions , Please compare this column with theTRX_ID
Column Connect INNODB_TRX.LOCK_MODE
How to request a lock . The allowed lock mode descriptors areS
,X
,IS
,IX
,GAP
,AUTO_INC
, andUNKNOWN
. Lock mode descriptors can be used in combination to identify specific lock modes .LOCK_TYPE
The type of lock . Allowed valueRECORD
Applicable to row level lock 、TABLE
Table lock .LOCK_TABLE
The name of the table that has or contains the locked record .LOCK_INDEX
Name of index , IfLOCK_TYPE
yesRECORD
; otherwiseNULL
.LOCK_SPACE
Lock the table space of the record ID, IfLOCK_TYPE
yesRECORD
; otherwiseNULL
.LOCK_PAGE
Lock the page number of the record , IfLOCK_TYPE
yesRECORD
; otherwiseNULL
.LOCK_REC
The heap number of the locked record in the page , IfLOCK_TYPE
yesRECORD
; otherwiseNULL
.
3.INNODB_LOCK_WAIT
Contains each block InnoDB
One or more rows of a transaction , Indicates the lock it has requested and any locks that block the request .
Main column :
REQUESTING_TRX_ID
request ( Blocking ) The transaction ID.REQUESTED_LOCK_ID
The lock that the transaction is waiting for ID. To get more information about locks , Please compare this column with theLOCK_ID
Column Connect INNODB_LOCKS.BLOCKING_TRX_ID
Blocking a transaction ID.BLOCKING_LOCK_ID
A transaction holds a lock ID, This transaction prevents another transaction from continuing . To get more information about locks , Please compare this column with theLOCK_ID
Column connection INNODB_LOCKS.
trx Table describes transactions ,lock Table describes the lock ,lock_wait Describes the relationship between blocking transaction locks .
for instance , Create a new table members
Start transaction 1
start TRANSACTION;
SELECT * FROM members WHERE id = 1 for UPDATE;
Start transaction 2
start TRANSACTION;
SELECT * FROM members WHERE id = 1 for UPDATE;
Observe the present 3 The state of the table :
Business table There are currently two transactions 1 and 2 Business 1 Running Business 2 Waiting for lock
Lock table There is currently a lock , Business 1,2 Are requesting row locks
Lock wait list Business 1 Waiting for transaction 2 Lock of
Later, learn to use these tables to diagnose and analyze problems .
边栏推荐
- Dark horse -- redis
- 快速幂模板求逆元,逆元的作用以及例题【第20届上海大学程序设计联赛夏季赛】排列计数
- In 50W, what have I done right?
- CPU负载很低,loadavg很高处理方法
- Lick the dog until the last one has nothing (simple DP)
- 【翻译】Linkerd在欧洲和北美的采用率超过了Istio,2021年增长118%。
- English topic assignment (25)
- A method of removing text blur based on pixel repair
- 1805. 字符串中不同整数的数目
- JDBC details
猜你喜欢
Characteristic colleges and universities, jointly build Netease Industrial College
CCNP Part 11 BGP (III) (essence)
学习探索-使用伪元素清除浮动元素造成的高度坍塌
Synchronous development of business and application: strategic suggestions for application modernization
Help improve the professional quality of safety talents | the first stage of personal ability certification and assessment has been successfully completed!
快速幂模板求逆元,逆元的作用以及例题【第20届上海大学程序设计联赛夏季赛】排列计数
Analysis of frequent chain breaks in applications using Druid connection pools
RT-Thread 组件 FinSH 使用时遇到的问题
Simple understanding of MySQL database
Xingnuochi technology's IPO was terminated: it was planned to raise 350million yuan, with an annual revenue of 367million yuan
随机推荐
How to do smoke test
黑馬--Redis篇
思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
The slave i/o thread stops because master and slave have equal MySQL serv
php+redis实现超时取消订单功能
凤凰架构2——访问远程服务
Use of deg2rad and rad2deg functions in MATLAB
Graffiti intelligence is listed on the dual main board in Hong Kong: market value of 11.2 billion Hong Kong, with an annual revenue of 300 million US dollars
Mathematical knowledge -- code implementation of Gaussian elimination (elementary line transformation to solve equations)
Elastic search indexes are often deleted [closed] - elastic search indexes gets deleted frequently [closed]
【翻译】供应链安全项目in-toto移至CNCF孵化器
Cereals Mall - Distributed Advanced p129~p339 (end)
JDBC details
深入分析,Android面试真题解析火爆全网
Zero foundation entry polardb-x: build a highly available system and link the big data screen
【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
史上超级详细,想找工作的你还不看这份资料就晚了
凤凰架构3——事务处理
Take a look at how cabloyjs workflow engine implements activiti boundary events
【计算情与思】扫地僧、打字员、信息恐慌与奥本海默