postgresqlsql-merge

Lock level on MERGE statement


Does anyone know what is the lock level (row, table) on PostgreSQL MERGE command? I tried to dig deep on the documentation but I couldn't find anything that could clarify my mind. If anyone have a clue and would be kind to share, that would be very appreciated.


Solution

  • From the manual:

    ROW EXCLUSIVE Conflicts with the SHARE, SHARE ROW EXCLUSIVE, EXCLUSIVE, and ACCESS EXCLUSIVE lock modes.

    The commands UPDATE, DELETE, INSERT, and MERGE acquire this lock mode on the target table (in addition to ACCESS SHARE locks on any other referenced tables). In general, this lock mode will be acquired by any command that modifies data in a table.