INSERT locking order - Mailing list pgsql-general

From Matthew Woodcraft
Subject INSERT locking order
Date
Msg-id 1578602959.23rey5xcjc.astroid@golux.woodcraft.me.uk
Whole thread Raw
Responses Re: INSERT locking order
List pgsql-general
In an INSERT, are the rows guaranteed to be inserted in the order that
the source query returns its rows, for locking purposes?

For example, if have

  CREATE TABLE foo (
    foo_id INTEGER,
    PRIMARY KEY (foo_id)
  );

and I run two concurrent copies of

  INSERT INTO foo (SELECT n FROM ... ORDER BY n);

is there any guarantee that I'll get a unique constraint violation
rather than a deadlock?

-M-



pgsql-general by date:

Previous
From: github kran
Date:
Subject: Re: Upgrade PostgreSQL 9.6 to 10.6
Next
From: Peter
Date:
Subject: Re: 12.1 not useable: clientlib fails after a dozen queries (GSSAPI?)