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


i cannot understand example https://www.postgresql.org/docs/9.1/static/explicit-locking.html

where embed lock along select clause select pg_advisory_lock(id) foo id = 12345; -- ok

what selecting foo? understand better if like

select pg_advisory_lock(123); //lock select * foo id = 12345; 

where explicitly locking block. can't seem find explanation on how use advisory lock anywhere explains differnece between both embedding , explicitly on own statement.

doing select pg_advisory_lock(123); create lock on 123, whether valid value or not. doing select pg_advisory_lock(id) foo id = 123; create lock if there entry id 123 in table foo.

let's note line found in pg_locks doc:

the actual meaning of keys user

which tends imply select/from/where syntax associating lock existing row, while lone select syntax broader meaning, application-wide lock.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -