Re: Implementing replace function

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Matthieu Huin <matthieu(dot)huin(at)wallix(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Implementing replace function
Date: 2010-11-02 17:14:04
Message-ID: 20101102171404.GA2789@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message hernan gonzalez 2010-11-02 17:21:45 pg_migrator segfault
Previous Message Tom Lane 2010-11-02 17:10:13 Re: Feature request for this mail list