"INSERT ON CONFLICT UPDATE" - Use of indexes ?

Started by Laura Smithalmost 6 years ago4 messagesgeneral
Jump to latest
#1Laura Smith
n5d9xq3ti233xiyif2vp@protonmail.ch

Hi,

What'st the current state of play with indexes and ON CONFLICT ?  The docs seem to vaguely suggest it is possible, but this SO question (https://stackoverflow.com/questions/38945027/) seems to suggest it is not.

I've got a unique named index on a table (i.e. "create unique index xyz...") but I cannot seem to be able to refer to it in a function ?
ON CONFLICT (index_name) .... : does not work
ON CONFLICT ON CONSTRAINT index_name....: does not work

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Laura Smith (#1)
Re: "INSERT ON CONFLICT UPDATE" - Use of indexes ?

On 6/8/20 5:42 AM, Laura Smith wrote:

Hi,

What'st the current state of play with indexes and ON CONFLICT ?  The docs seem to vaguely suggest it is possible, but this SO question (https://stackoverflow.com/questions/38945027/) seems to suggest it is not.

I've got a unique named index on a table (i.e. "create unique index xyz...") but I cannot seem to be able to refer to it in a function ?
ON CONFLICT (index_name) .... : does not work
ON CONFLICT ON CONSTRAINT index_name....: does not work

The above is going to need more information:

1) Table definition.

2) Actual index definition

3) Complete ON CONFLICT definition

4) Error message returned.

--
Adrian Klaver
adrian.klaver@aklaver.com

#3Thomas Kellerer
shammat@gmx.net
In reply to: Laura Smith (#1)
Re: "INSERT ON CONFLICT UPDATE" - Use of indexes ?

Laura Smith schrieb am 08.06.2020 um 14:42:

Hi,

What'st the current state of play with indexes and ON CONFLICT ?  The docs seem to vaguely suggest it is possible, but this SO question (https://stackoverflow.com/questions/38945027/) seems to suggest it is not.

I've got a unique named index on a table (i.e. "create unique index xyz...") but I cannot seem to be able to refer to it in a function ?
ON CONFLICT (index_name) .... : does not work
ON CONFLICT ON CONSTRAINT index_name....: does not work

If c1 and c2 make up a unique index, then

ON CONFLICT (c1, c2)

works

#4David Rowley
dgrowleyml@gmail.com
In reply to: Laura Smith (#1)
Re: "INSERT ON CONFLICT UPDATE" - Use of indexes ?

On Tue, 9 Jun 2020 at 00:42, Laura Smith
<n5d9xq3ti233xiyif2vp@protonmail.ch> wrote:

What'st the current state of play with indexes and ON CONFLICT ? The docs seem to vaguely suggest it is possible, but this SO question (https://stackoverflow.com/questions/38945027/) seems to suggest it is not.

I've got a unique named index on a table (i.e. "create unique index xyz...") but I cannot seem to be able to refer to it in a function ?
ON CONFLICT (index_name) .... : does not work
ON CONFLICT ON CONSTRAINT index_name....: does not work

Creating a unique index does not create a unique constraint. If you
create a unique constraint, it'll create a unique index to enforce the
constraint. ON CONSTRAINT requires a constraint name, not an index
name.

David