From: | Peter Geoghegan <pg(at)heroku(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | hlinnaka <hlinnaka(at)iki(dot)fi>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: INSERT ... ON CONFLICT UPDATE/IGNORE 4.0 |
Date: | 2015-05-05 22:00:56 |
Message-ID: | CAM3SWZTU8FgwoMb-vKZv_LsQb75nH=NP9+dCdTj9S4GScMtk=A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-hackers |
On Tue, May 5, 2015 at 8:40 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> One additional thing I'm wondering about is the following: Right now
> INSERT ... ON CONFLICT NOTHING does not acquire a row level lock on the
> 'target' tuple. Are we really ok with that? Because in this form ON
> CONFLICT NOTHING really doesn't guarantee much, the conflicting tuple
> could just be deleted directly after the check. ISTM we should just
> acquire the lock in the same way ExecOnConflictUpdate does. In the
> majority of the cases that'll be what users actually expect
> behaviourally.
Locking the row is not "nothing", though. If you want to lock the row,
use an UPSERT with a tautologically false WHERE clause (like "WHERE
false").
This is how other similar "ignore" features work in other systems,
including MySQL, SQLite, and Oracle (which surprisingly has a hint
that does this - surprising only because hints don't usually change
the meaning of statements). It could make a big difference with a
large bulk loading session, because just locking the rows will
generate WAL and dirty pages. ETL is really the use-case for DO
NOTHING.
--
Peter Geoghegan
From | Date | Subject | |
---|---|---|---|
Next Message | phuongnh2 | 2015-05-06 09:44:21 | Import csv file error with double newline |
Previous Message | Scott Ribe | 2015-05-05 19:03:24 | Re: display to_timestamp in quotas or convert to char ? |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-05-05 22:50:13 | Re: Manipulating complex types as non-contiguous structures in-memory |
Previous Message | Peter Geoghegan | 2015-05-05 21:51:41 | Re: INSERT ... ON CONFLICT syntax issues |