Re: Re: how to implement add using upsert and trigger?

From: "yin(dot)zhb(at)163(dot)com" <yin(dot)zhb(at)163(dot)com>
To: "Dominique Devienne" <ddevienne(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Re: how to implement add using upsert and trigger?
Date: 2022-11-28 12:57:58
Message-ID: 202211282057577060707@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

em, which is does not matter

yin(dot)zhb(at)163(dot)com

From: Dominique Devienne
Date: 2022-11-28 20:47
To: yin(dot)zhb(at)163(dot)com
CC: pgsql-general
Subject: Re: how to implement add using upsert and trigger?
On Mon, Nov 28, 2022 at 1:37 PM yin(dot)zhb(at)163(dot)com <yin(dot)zhb(at)163(dot)com> wrote:
> on conflict(itemid) do update
> set value = excluded.value + new.value, cnt = excluded.cnt +1 where excluded.itemid = new.itemid;

OT, but isn't `where excluded.itemid = new.itemid` redundant, given
`on conflict(itemid)`?
I'm asking more because I'm not sure, for my own education. Thanks, --DD

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Anna B. 2022-11-28 13:09:08 Re[2]: Index-only scan not working when IN clause has 2 or more values
Previous Message Dominique Devienne 2022-11-28 12:47:37 Re: how to implement add using upsert and trigger?