PostgreSQL - Behavior of SELECT FOR UPDATE - Deepstash
PostgreSQL - Behavior of SELECT FOR UPDATE

PostgreSQL - Behavior of SELECT FOR UPDATE

Curated from: postgresql.org

Ideas, facts & insights covering these topics:

1 idea

·

6 reads

SELECT FOR UPDATE locks all joined tables by default

SELECT FOR UPDATE locks all joined tables by default

FOR UPDATE locks selected rows to prevent concurrent modifications. If you don’t want to wait for locked rows, use NOWAIT to fail immediately or SKIP LOCKED to skip them, which is useful for queue-like tables.

By default, it locks rows from all queried tables, but you can limit it to specific ones using FOR UPDATE OF table_name. In a JOIN, only the rows that appear in the final result set are locked. If applied to a view, FOR UPDATE locks all underlying tables.

With LIMIT, locking stops once enough rows are fetched, but rows skipped by OFFSET still get locked.

1

6 reads

IDEAS CURATED BY

ocpodariu

Alt account of @ocp. I use it to stash ideas about software engineering

Read & Learn

20x Faster

without
deepstash

with
deepstash

with

deepstash

Personalized microlearning

100+ Learning Journeys

Access to 200,000+ ideas

Access to the mobile app

Unlimited idea saving

Unlimited history

Unlimited listening to ideas

Downloading & offline access

Supercharge your mind with one idea per day

Enter your email and spend 1 minute every day to learn something new.

Email

I agree to receive email updates