Re: INSERT ... ON CONFLICT DO UPDATE

Поиск
Список
Период
Сортировка
От Geoff Winkless
Тема Re: INSERT ... ON CONFLICT DO UPDATE
Дата
Msg-id CAEzk6fduUOm6yyiffSoAhqPnZaPrhWxMTm9d8d+E0u5FZrCKrQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: INSERT ... ON CONFLICT DO UPDATE  (Rafal Pietrak <rafal@ztk-rp.eu>)
Ответы Re: INSERT ... ON CONFLICT DO UPDATE  (Rafal Pietrak <rafal@ztk-rp.eu>)
Список pgsql-general
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
Дата:
Сообщение: Re: INSERT ... ON CONFLICT DO UPDATE