当前位置:网站首页>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_IDThe only business ID NumberTRX_WEIGHTThe weight of the transaction , reflect ( But not necessarily the exact count ) Number of rows changed and transaction locked . In order to solve the deadlock ,InnoDBSelect 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_STATETransaction execution status . The allowed values areRUNNING、LOCK WAIT、ROLLING BACKandCOMMITTING. You can judge whether a certain current transaction is waiting for a lockTRX_STARTEDTransaction start time .TRX_REQUESTED_LOCK_IDThe lock that the transaction is currently waiting for ID, IfTRX_STATEyesLOCK WAIT; otherwiseNULL. To get more information about locks , Please compare this column with theLOCK_IDColumn Connect INNODB_LOCKS.
You can get the lock that the current transaction is waiting for , Easy to analyze deadlock problems .
TRX_WAIT_STARTEDThe time when the transaction starts waiting for the lock , IfTRX_STATEyesLOCK WAIT; otherwiseNULL.TRX_MYSQL_THREAD_IDMySQL Threads ID. To get more information about threads , Please compare this column with theIDColumn ConnectINFORMATION_SCHEMAPROCESSLISTTRX_QUERYThe transaction is executing SQL sentence .TRX_OPERATION_STATEThe current operation of the transaction , If any ; otherwiseNULL.TRX_TABLES_IN_USEInnoDBProcess the current SQL Use The number of watches .TRX_TABLES_LOCKEDInnoDBAt 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_STRUCTSNumber of locks reserved by transaction .TRX_LOCK_MEMORY_BYTESThe total size of the lock structure of this transaction in memory .TRX_ROWS_LOCKEDThe 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_MODIFIEDNumber of rows modified and inserted in this transaction .TRX_CONCURRENCY_TICKETSA 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_LEVELIsolation level of the current transaction .TRX_UNIQUE_CHECKSWhether 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_CHECKSWhether 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_ERRORDetailed error information of the last foreign key error , If any ; otherwiseNULL.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 . The adaptive hash index partition is created by control innodb_adaptive_hash_index_parts, The default setting is 8.TRX_ADAPTIVE_HASH_TIMEOUTWhether 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_ONLYvalue 1 Indicates that the transaction is read-only .TRX_AUTOCOMMIT_NON_LOCKINGvalue 1 Indicates that the transaction is SELECT Don't useFOR UPDATEorLOCK IN SHARED MODEStatement of clause , And execute when enabled , autocommit Therefore, the transaction only contains this statement . When this column andTRX_IS_READ_ONLYAre all 1 when ,InnoDBOptimize 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_IDA unique lock ID NumberLOCK_TRX_IDOf the transaction that holds the lock ID. To get detailed information about transactions , Please compare this column with theTRX_IDColumn Connect INNODB_TRX.LOCK_MODEHow 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_TYPEThe type of lock . Allowed valueRECORDApplicable to row level lock 、TABLETable lock .LOCK_TABLEThe name of the table that has or contains the locked record .LOCK_INDEXName of index , IfLOCK_TYPEyesRECORD; otherwiseNULL.LOCK_SPACELock the table space of the record ID, IfLOCK_TYPEyesRECORD; otherwiseNULL.LOCK_PAGELock the page number of the record , IfLOCK_TYPEyesRECORD; otherwiseNULL.LOCK_RECThe heap number of the locked record in the page , IfLOCK_TYPEyesRECORD; 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_IDrequest ( Blocking ) The transaction ID.REQUESTED_LOCK_IDThe lock that the transaction is waiting for ID. To get more information about locks , Please compare this column with theLOCK_IDColumn Connect INNODB_LOCKS.BLOCKING_TRX_IDBlocking a transaction ID.BLOCKING_LOCK_IDA transaction holds a lock ID, This transaction prevents another transaction from continuing . To get more information about locks , Please compare this column with theLOCK_IDColumn 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 .
边栏推荐
- MRO工业品企业采购系统:如何精细化采购协同管理?想要升级的工业品企业必看!
- A full set of teaching materials, real questions of Android interview of 7 major manufacturers including Alibaba Kwai pinduoduo
- Don't miss this underestimated movie because of controversy!
- How to type multiple spaces when editing CSDN articles
- Php+redis realizes the function of canceling orders over time
- Simple application of VBA script in Excel
- GCC【7】- 编译检查的是函数的声明,链接检查的是函数的定义bug
- 三面蚂蚁金服成功拿到offer,Android开发社招面试经验
- 五金机电行业智能供应链管理系统解决方案:数智化供应链为传统产业“造新血”
- English topic assignment (25)
猜你喜欢

Mysql Information Schema 學習(一)--通用錶

Actf 2022 came to a successful conclusion, and 0ops team won the second consecutive championship!!

Synchronous development of business and application: strategic suggestions for application modernization
![Fast power template for inverse element, the role of inverse element and example [the 20th summer competition of Shanghai University Programming League] permutation counting](/img/dd/c3f4a9c38b156e3a9b9adfd6253773.gif)
Fast power template for inverse element, the role of inverse element and example [the 20th summer competition of Shanghai University Programming League] permutation counting

LeetCode-1279. Traffic light intersection

Low CPU load and high loadavg processing method

spark基础-scala

保证接口数据安全的10种方案

第五期个人能力认证考核通过名单公布

MRO industrial products enterprise procurement system: how to refine procurement collaborative management? Industrial products enterprises that want to upgrade must see!
随机推荐
【计算情与思】扫地僧、打字员、信息恐慌与奥本海默
MySQL information Schema Learning (i) - - General table
学习探索-函数防抖
JDBC details
Swagger2 reports an error illegal DefaultValue null for parameter type integer
Problems encountered in using RT thread component fish
Computer network: sorting out common network interview questions (I)
通俗的讲解,带你入门协程
谷粒商城--分布式高级篇P129~P339(完结)
Interview assault 63: how to remove duplication in MySQL?
中缀表达式转后缀表达式详细思路及代码实现
swagger2报错Illegal DefaultValue null for parameter type integer
Use of map (the data of the list is assigned to the form, and the JSON comma separated display assignment)
Mysql Information Schema 學習(一)--通用錶
R language uses DT function to generate t-distribution density function data and plot function to visualize t-distribution density function data
R language ggplot2 visualization: use the ggdotplot function of ggpubr package to visualize dot plot, set the palette parameter, and set the colors of data points and box graphs of dot plots at differ
How to type multiple spaces when editing CSDN articles
MRO industrial products enterprise procurement system: how to refine procurement collaborative management? Industrial products enterprises that want to upgrade must see!
MATLAB中deg2rad和rad2deg函数的使用
Yyds dry goods inventory leetcode question set 751 - 760