In PostgreSQL, do multiple UPDATEs to different rows in the same table have a conflicting locks?

后端 未结 2 671
野趣味
野趣味 2021-01-20 08:07

I\'m wondering about an update I am making to a large table, and whether I need to worry about locks.

I have a table looking like this:

CREATE TABLE          


        
2条回答
  •  隐瞒了意图╮
    2021-01-20 08:27

    You are missing a couple of things.

    First, PostgreSQL does not offer a LIMIT option for update. See the docs for UPDATE.

    Second, note that ROW EXCLUSIVE does not conflict with itself, it conflicts with SHARE ROW EXCLUSIVE which is different. So, your UPDATE statements can safely run concurrently from multiple workers. You still will want your update times to be low. However, you already have a built-in way to tune that by lowering your batchSize if you run into problems.

提交回复
热议问题