INSERT locking order
Matthew Woodcraft <[email protected]> Thu, 09 Jan 2020 20:50:29 +0000
| Newsgroups | gmane.comp.db.postgresql.general |
|---|---|
| Message-ID | <[email protected]> |
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-
=