Re: INSERT ... ON CONFLICT DO UPDATE

Поиск
Список
Период
Сортировка
Искать
От
Geoff Winkless
Тема
Re: INSERT ... ON CONFLICT DO UPDATE
Дата
Msg-id
CAEzk6fduUOm6yyiffSoAhqPnZaPrhWxMTm9d8d+E0u5FZrCKrQ@mail.gmail.com
Ответ на
Список
Дерево обсуждения
INSERT ... ON CONFLICT DO UPDATE Rafal Pietrak <rafal@ztk-rp.eu>
Re: INSERT ... ON CONFLICT DO UPDATE "Charles Clavadetscher" <clavadetscher@swisspug.org>
Re: INSERT ... ON CONFLICT DO UPDATE Rafal Pietrak <rafal@ztk-rp.eu>
Re: INSERT ... ON CONFLICT DO UPDATE Geoff Winkless <pgsqladmin@geoff.dj>
Re: INSERT ... ON CONFLICT DO UPDATE Rafal Pietrak <rafal@ztk-rp.eu>
Re: INSERT ... ON CONFLICT DO UPDATE Geoff Winkless <pgsqladmin@geoff.dj>
Re: INSERT ... ON CONFLICT DO UPDATE Rafal Pietrak <rafal@ztk-rp.eu>
Re: INSERT ... ON CONFLICT DO UPDATE Adrian Klaver <adrian.klaver@aklaver.com>
Re: INSERT ... ON CONFLICT DO UPDATE Rafal Pietrak <rafal@ztk-rp.eu>
Re: INSERT ... ON CONFLICT DO UPDATE Adrian Klaver <adrian.klaver@aklaver.com>
Re: INSERT ... ON CONFLICT DO UPDATE Melvin Davidson <melvin6925@gmail.com>
Re: INSERT ... ON CONFLICT DO UPDATE "Daniel Verite" <daniel@manitou-mail.org>
Re: INSERT ... ON CONFLICT DO UPDATE Francisco Olarte <folarte@peoplecall.com>
Re: INSERT ... ON CONFLICT DO UPDATE Deven Phillips <deven.phillips@gmail.com>
Re: INSERT ... ON CONFLICT DO UPDATE "Daniel Verite" <daniel@manitou-mail.org>
Re: INSERT ... ON CONFLICT DO UPDATE Rafal Pietrak <rafal@ztk-rp.eu>
Re: INSERT ... ON CONFLICT DO UPDATE Francisco Olarte <folarte@peoplecall.com>
Re: INSERT ... ON CONFLICT DO UPDATE Rafal Pietrak <rafal@ztk-rp.eu>
Re: INSERT ... ON CONFLICT DO UPDATE Francisco Olarte <folarte@peoplecall.com>
Re: INSERT ... ON CONFLICT DO UPDATE Geoff Winkless <pgsqladmin@geoff.dj>
Re: INSERT ... ON CONFLICT DO UPDATE Francisco Olarte <folarte@peoplecall.com>
Re: INSERT ... ON CONFLICT DO UPDATE Geoff Winkless <pgsqladmin@geoff.dj>
Re: INSERT ... ON CONFLICT DO UPDATE Alvaro Herrera <alvherre@2ndquadrant.com>
Re: INSERT ... ON CONFLICT DO UPDATE Igor Neyman <ineyman@perceptron.com>
Re: INSERT ... ON CONFLICT DO UPDATE Francisco Olarte <folarte@peoplecall.com>
Re: INSERT ... ON CONFLICT DO UPDATE Francisco Olarte <folarte@peoplecall.com>
Re: INSERT ... ON CONFLICT DO UPDATE Geoff Winkless <pgsqladmin@geoff.dj>
Re: INSERT ... ON CONFLICT DO UPDATE John R Pierce <pierce@hogranch.com>
Re: INSERT ... ON CONFLICT DO UPDATE Jeff Janes <jeff.janes@gmail.com>
On 19 July 2015 at 11:30, Rafal Pietrak <rafal@ztk-rp.eu> wrote:
when I have to invent/introduce additional
features/columns/attributes (like a key in addition to a sequence),
which are not required by the design, but necessary for implementation)
is a workaround (almost by definition).

I'm sorry that you feel defensive about this, and apologies for repeating myself, but the fact that the random key can be duplicated means it should not be used as a primary key, so using a sequence as a primary key is not a workaround, it's a correction to the design. 

Notwithstanding that, the reason UPSERT is required is because it's possible that two competing transactions can end up fighting over an INSERT and the workarounds that are required are either highly complex or not 100% successful (eg http://www.depesz.com/2012/06/10/why-is-upsert-so-complicated/). 

Conversely, the workaround in the above case (even if you don't want to change the primary key) is trivial - as you yourself described.

Geoff
В списке pgsql-general по дате отправления
От: Andreas Joseph Krogh
Дата:
Сообщение: IO in constraint trigger
От: Rafal Pietrak
Дата:
FAQ