Re: most idiomatic way to "update or insert"? - Mailing list pgsql-general

From Richard Huxton
Subject Re: most idiomatic way to "update or insert"?
Date
Msg-id 41127EF1.70507@archonet.com
Whole thread Raw
In response to Re: most idiomatic way to "update or insert"?  (Ron St-Pierre <rstpierre@syscor.com>)
List pgsql-general
Ron St-Pierre wrote:
> Okay, this simple example really exists, but the simple table also
> includes a date that the stock was last traded, so we have:
> stock symbol, stock exchange, high, low, open, close, volume, date, plus
> a few more fields
[snip more details]
> BTW these updates do take longer than we'd like so I would appreciate
> more input on how this setup could be redesigned.

Well, I'd probably make the primary key (stock_id, trading_date) and
just insert into a log table. From there I'd update into a summary
table, or use a view.

Of course, that might make things slower in your case.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Greg Stark
Date:
Subject: Re: most idiomatic way to "update or insert"?
Next
From: Geoff Caplan
Date:
Subject: Re: Correct escaping of untrusted data