From: | Geoff Winkless <pgsqladmin(at)geoff(dot)dj> |
---|---|
To: | Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: INSERT ON CONFLICT and RETURNING |
Date: | 2020-08-24 10:37:40 |
Message-ID: | CAEzk6feT1NXSqvdYffg0jDJT+wPRLekH=2LuNn50KyQ6Zw2PsA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, 22 Aug 2020 at 08:16, Konstantin Knizhnik
<k(dot)knizhnik(at)postgrespro(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Christoph Berg | 2020-08-24 11:33:25 | Re: deb repo doesn't have latest. or possible to update web page? |
Previous Message | Bharath Rupireddy | 2020-08-24 10:36:27 | Avoid displaying unnecessary "Recheck Cond" in EXPLAIN ANALYZE output if the bitmap is non-lossy |