Re: Implementing replace function - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Implementing replace function
Date
Msg-id 20101102171404.GA2789@svana.org
Whole thread Raw
In response to Re: Implementing replace function  (Matthieu Huin <matthieu.huin@wallix.com>)
List pgsql-general
On Tue, Nov 02, 2010 at 10:46:42AM +0100, Matthieu Huin wrote:
> Hello,
>
> If you expect your data to reach some kind of "critical size" at some
> point ( ie updates will be more likely than inserts at that point ), you
> can optimize your UPSERT code by trying to UPDATE before INSERTing.
> Otherwise trying to INSERT first should decrease the average UPSERT
> execution time in the long run, since you are less likely to hit the
> exception and do some extra work on the table.

You'd almost think of using some kind of branch prediction techniques.
You could track what happened the last two times and use that to
predict which would be better. There's always pathelogical cases, but
it could work well for normal workloads.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patriotism is when love of your own people comes first; nationalism,
> when hate for people other than your own comes first.
>                                       - Charles de Gaulle

Attachment

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Feature request for this mail list
Next
From: hernan gonzalez
Date:
Subject: pg_migrator segfault