Re: INSERT ON CONFLICT and RETURNING

Поиск
Список
Период
Сортировка
От Geoff Winkless
Тема Re: INSERT ON CONFLICT and RETURNING
Дата
Msg-id CAEzk6feT1NXSqvdYffg0jDJT+wPRLekH=2LuNn50KyQ6Zw2PsA@mail.gmail.com
обсуждение исходный текст
Ответ на INSERT ON CONFLICT and RETURNING  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
Ответы Re: INSERT ON CONFLICT and RETURNING  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
Список pgsql-hackers
On Sat, 22 Aug 2020 at 08:16, Konstantin Knizhnik
<k.knizhnik@postgrespro.ru> wrote:
> It is possible to do something like this:
>
>    with ins as (insert into jsonb_schemas (schema) values (obj_schema)
> on conflict(schema) do nothing returning id) select coalesce((select id
> from ins),(select id from jsonb_schemas where schema=obj_schema));
>
> but it requires extra lookup.

But if

INSERT INTO jsonb_schemas (schema) VALUES (obj_schema)
  ON CONFLICT (schema) DO NOTHING RETURNING id

were to work then that would _also_ require a second lookup, since
"id" is not part of the conflict key that will be used to perform the
existence test, so the only difference is it's hidden by the syntax.

Geoff



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bharath Rupireddy
Дата:
Сообщение: Avoid displaying unnecessary "Recheck Cond" in EXPLAIN ANALYZE output if the bitmap is non-lossy
Следующее
От: Christoph Berg
Дата:
Сообщение: Re: deb repo doesn't have latest. or possible to update web page?