What is the difference between Resolve_lock_time and LockKeys_time?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: Resolve_lock_time 和 LockKeys_time 两者到底有什么区别?

| username: TiDBer_888

What is the difference between Resolve_lock_time and LockKeys_time?

| username: xfworld | Original post link

One is unlock time, the other is lock time…

| username: tidb菜鸟一只 | Original post link

In TiDB, Resolve_lock_time and LockKeys_time are two important performance metrics related to transaction locks when executing SQL statements.

Resolve_lock_time refers to the time consumed by TiDB to resolve all conflicting locks involved in a transaction before committing it. When multiple transactions simultaneously request the same resource in TiDB, lock conflicts occur. At this point, TiDB will attempt to resolve these conflicts so that the transaction can be committed smoothly. The longer the Resolve_lock_time, the more lock conflicts there are, which will reduce the system’s concurrency performance.

LockKeys_time refers to the time consumed by TiDB to check and lock transaction locks when executing SQL statements. When TiDB executes an SQL statement, if it needs to modify certain data, it needs to lock this data to ensure data consistency and integrity. The longer the LockKeys_time, the more data is locked, which will reduce the system’s concurrency performance.

In layman’s terms, Resolve_lock_time is the waiting time for your data to be unlocked by others before you execute the SQL, and LockKeys_time is the time your executed SQL locks the data, causing others to wait for you.