3

Related to previous question here

From the pg_locks documentation, row level lock information is not available when FOR UPDATE is used in a SELECT statement.

Is there any way to check for row level lock when FOR UPDATE is used in a SELECT statement? If yes, how can I do so with Postgres 11?

Thank you

asked Jan 7, 2021 at 12:34

1 Answer 1

6

Row locks are not permanently stored in the shared lock table, but on the row itself, so you cannot simply query for them.

To figure out which rows in a table are locked by concurrent transactions, you could run

SELECT id FROM mytable
WHERE id NOT IN (SELECT id FROM mytable
 FOR UPDATE SKIP LOCKED);
answered Jan 7, 2021 at 13:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.