Lock know almost summarized https://zhuanlan.zhihu.com/p/29150809
use
RC隔离级别
精心设计索引
Opportunity, and try to use the index to access the data, so that locking more and more precise, thus reducing lock conflictsSelect
合理的事务大小
a small lock transaction occurs less chance of conflictWhen set to the recording explicit lock,
最好⼀次性请求足够级别的锁
. ⽐ example, to modify the data, preferably directly apply row
locks, not to apply for a shared lock, an exclusive lock when requested again modified so prone to deadlocksDifferent programs access ⼀ group table, should be
约定以相同的顺序访问各表
, in terms of ⼀ table, as far as possible in a fixed
sequence access table rows. This can greatly reduce the chance of deadlockAs far as possible
用相等条件访问数据
, to avoid influence of the gap concurrent lock insert除非必须,查询时不要显式加锁
. MySQL's MVCC transaction will not be used queries can be achieved with a lock, optimize transaction
performance; MVCC in COMMITTED READ (read committed) and REPEATABLE READ (repeatable read) only two kinds of separated
work from ⼯ next level