Skip to Content
0
Feb 14, 2017 at 12:43 PM

Question about table locks during SELECT...FOR UPDATE query.

289 Views

Hell,

I have observed that doing a SELECT...FOR UPDATE query on an empty table will actually acquire an "intention exclusive" lock on the table being queried. This lock will be held for the duration of the transaction, which will prevent the table from being dropped.

Is this expected behaviour? I would not expect any locks to be acquired unless (a) there are rows in the table, and (b) at least one of those rows is returned by my query.

Thank you!

scott