This is being used in the context of a transaction as opposed to just lock the DB. This lock prevents two concurrent transactions. Perhaps there is a room to optimize it.