1

I am using jdbi with postgres. And as i am running application in multiple instances locking is not an option on application code level. So i am using row level locking on database. So i am using select for update. But ideally i don't need any update to the row but i am going a head due to for update. So everytime to release a lock i fire an update query to update last updated time field, Can i just lock it and once the transaction is done release the lock without any update. DO we have such an option?

1 Answer 1

1

When you commit or rollback your transaction the lock is automatically released, regardless whether you actually updated the row or not.

There is absolutely no need to UPDATE the row in order for the lock to be released.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.