What is the benefit of embedding pg_advisory_lock inside SELECT vs explicitly using another statement?

Viewed 746

I cannot really understand the example from https://www.postgresql.org/docs/9.1/static/explicit-locking.html

where they embed the lock along with the SELECT clause SELECT pg_advisory_lock(id) FROM foo WHERE id = 12345; -- ok

What is it selecting from FOO? I would understand better if it is like

SELECT pg_advisory_lock(123); //lock
SELECT * FROM foo WHERE id = 12345;

where it is explicitly locking the block. I can't seem to find explanation on how to really use advisory lock anywhere that explains the differnece between both Embedding and Explicitly on its own statement.

1 Answers
Related