IamIC
IamIC

Reputation: 18269

Lightest lock for exclusive inserts in PostgreSQL

I want to limit INSERTs to whichever transaction gets the lock (with the others waiting in line, not failing) while allowing concurrent reads, updates, and deletes (but obviously not of the data being inserted, which is impossible in PG anyway).

What is the lightest LOCK to achieve this?

Upvotes: 0

Views: 38

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 248125

Yes, if you want to lock a table against all concurrent modifications, SHARE ROW EXCLUSIVE is the cheapest lock.

I'm not going to ask why you want to restrict concurrency in that way...

Upvotes: 1

Related Questions