From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Matthew Woodcraft <matthew(at)woodcraft(dot)me(dot)uk> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: INSERT locking order |
Date: | 2020-01-09 21:27:06 |
Message-ID: | 14928.1578605226@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Matthew Woodcraft <matthew(at)woodcraft(dot)me(dot)uk> writes:
> In an INSERT, are the rows guaranteed to be inserted in the order that
> the source query returns its rows, for locking purposes?
I dunno that we "guarantee" that, but it's hard to see why the
code would behave any differently, at present.
> 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?
Well, the issue there is not about the physical insertion order
but the order in which the uniqueness checks happen. I think
you'd be all right with a traditional-style PG index, but maybe
not with a deferrable unique constraint.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-01-09 21:31:44 | Re: 12.1 not useable: clientlib fails after a dozen queries (GSSAPI ?) |
Previous Message | Peter | 2020-01-09 20:53:19 | Re: 12.1 not useable: clientlib fails after a dozen queries (GSSAPI ?) |