Row Lock
•
Mysql은 인덱스에 락을 건다.
•
특정 값을 업데이트 하는 경우에 where 절에 들어간 컬럼이 인덱스가 있다면 해당 row에 모두 락이 걸림.
•
적당한 인덱스가 없다면 모든 테이블의 레코드에 락을 걸고, 테이블을 풀 스캔하면서 작업을 처리함.
◦
If you have no indexes suitable for your statement and MySQL must scan the entire table to process the statement, every row of the table becomes locked, which in turn blocks all inserts by other users to the table. It is important to create good indexes so that your queries do not scan more rows than necessary.
◦
적절한게 없으면 insert가 안되게끔 막는다.
Gap Lock
•
인덱스에 거는 것 때문에 범위에 대한 락킹을 하는 경우, 해당 범위가 다 걸린다.
•
Like 문도 포함함
Next Key Lock
•
레코드락과 갭 락을 합친 것
•
bin log에 기록되는 쿼리가 레플리카 서버에서 실행될 때 소스 서버에서 만들어낸 결과와 동일한 결과를 만들어내는 것이 주목적