Re: update/insert, delete/insert efficiency WRT vacuum and

From: "Zeugswetter Andreas DCP SD" <ZeugswetterA(at)spardat(dot)at>
To: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Zdenek Kotala" <Zdenek(dot)Kotala(at)Sun(dot)COM>
Cc: "Mark Woodward" <pgsql(at)mohawksoft(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: update/insert, delete/insert efficiency WRT vacuum and
Date: 2006-07-04 12:53:54
Message-ID: E1539E0ED7043848906A8FF995BDA579011F0970@m0143.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> > >Is there a difference in PostgreSQL performance between these two
> > >different strategies:
> > >
> > >
> > >if(!exec("update foo set bar='blahblah' where name = 'xx'"))
> > > exec("insert into foo(name, bar) values('xx','blahblah'"); or

In pg, this strategy is generally more efficient, since a pk failing
insert would create
a tx abort and a heap tuple. (so in pg, I would choose the insert first
strategy only when
the insert succeeds most of the time (say > 95%))

Note however that the above error handling is not enough, because two
different sessions
can still both end up trying the insert (This is true for all db systems
when using this strategy).

Andreas

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-07-04 13:23:01 Re: [HACKERS] PQescapeIdentifier
Previous Message paolo romano 2006-07-04 10:41:11 Re: MultiXactID Wrap-Around