Category: MySQL

  • [MySql] Transaction Isolation level

    [MySql] Transaction Isolation level

    1. Intro When dealing with atomic operations in databases, it’s essential to use transactions effectively. However, simply processing transactions in a First-In-First-Out (FIFO) order can lead to serious logical inconsistencies. Imagine a scenario where Transaction A interrupts and updates data that Transaction B has already read and is relying on. Or consider a case where…

  • [Mysql] ID jumps when using UPSERT

    [Mysql] ID jumps when using UPSERT

    You might have noticed that the PRIMARY KEY ID jumps even when no new record is inserted. This behavior commonly occurs when using the UPSERT operation. In MySQL, where the ID column is set to AUTO_INCREMENT, the increment key is consumed whenever you perform an UPSERT (INSERT … ON DUPLICATE KEY UPDATE). This happens because…