Re: [EXTERNAL]: Re: [EXTERNAL]: Re: UPSERT in Postgres

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: [EXTERNAL]: Re: [EXTERNAL]: Re: UPSERT in Postgres
Date: 2023-04-10 07:41:15
Message-ID: CA+bJJbxS8RWt=5ru9ax779Hj3Or=vnmMHni89c+UH14tSp4XYA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Rob:

On Mon, 10 Apr 2023 at 04:16, Rob Sargent <robjsargent(at)gmail(dot)com> wrote:
> > An UPSERT checks whether a row exists, if so, it does an update, if not it does an insert. This is the literal definition.
> This the part that's always eluded me: How does the client, the
> UPSERTer, come to hold an id and not know whether or not it's already in
> the database.

This is extremely easy to do if you have natural instead of surrogate keys.

I work in telephony, upserting the last incoming call timestamp for a
phone number will be exactly that.

Francisco Olarte.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Allan Nielsen 2023-04-10 09:07:26 Re: Patroni vs pgpool II
Previous Message Francisco Olarte 2023-04-10 07:37:08 Re: [EXTERNAL]: Re: [EXTERNAL]: Re: UPSERT in Postgres