Lock and optimization recommendations on matters

Lock know almost summarized https://zhuanlan.zhihu.com/p/29150809

  • useRC隔离级别

  • 精心设计索引 Opportunity, and try to use the index to access the data, so that locking more and more precise, thus reducing lock conflicts

  • Select 合理的事务大小a small lock transaction occurs less chance of conflict

  • When 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 deadlocks

  • Different 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 deadlock

  • As 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

Guess you like

Origin www.cnblogs.com/oklizz/p/11454358.html