Re: what is the PostgreSQL idiom for "insert or update"? - Mailing list pgsql-novice

From Robert Poor
Subject Re: what is the PostgreSQL idiom for "insert or update"?
Date
Msg-id AANLkTinEFDKH20fZ5x6feNHpqg9ORE+VZMzLP1Q_v5FJ@mail.gmail.com
Whole thread Raw
In response to Re: what is the PostgreSQL idiom for "insert or update"?  (Richard Broersma <richard.broersma@gmail.com>)
Responses Re: what is the PostgreSQL idiom for "insert or update"?  (Richard Broersma <richard.broersma@gmail.com>)
List pgsql-novice
Richard:

On Wed, Mar 16, 2011 at 08:45, Richard Broersma
<richard.broersma@gmail.com> wrote:
> How about:
>
> INSERT INTO weather (station_id, date, temperature )
>  SELECT A.station_id, A.date, A.temperature
>   FROM ( VALUES(2257, '2001-01-01', 22.5),
>              (2257, '2001-01-02', 25.3) ) AS A ( station_id, date, temperature)
> LEFT JOIN weather AS B
>    ON ( A.station_id, A.date ) = ( B.station_id, B.date )
> WHERE B.station_id IS NULL;

That would work, though I was hoping there'd be some mechanism that
used the key to determine if the incoming record was unique or not
(rather than writing a custom query).

Are there limits to the size of the VALUES sub-query?  I'm processing
about 500 records at a time, and each record is fairly wide (about 350
characters without the field names).

pgsql-novice by date:

Previous
From: Robert Poor
Date:
Subject: Re: what is the PostgreSQL idiom for "insert or update"?
Next
From: Richard Broersma
Date:
Subject: Re: what is the PostgreSQL idiom for "insert or update"?