From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | mark(at)mark(dot)mielke(dot)cc |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Csaba Nagy <nagy(at)ecircle-ag(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Zeugswetter Andreas DCP SD <ZeugswetterA(at)spardat(dot)at>, Dann Corbit <DCorbit(at)connx(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Rick Gigger <rick(at)alpinenetworking(dot)com>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, josh(at)agliodbs(dot)com, pgsql-hackers(at)postgresql(dot)org, Jaime Casanova <systemguards(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net> |
Subject: | Re: MERGE vs REPLACE |
Date: | 2005-11-18 02:30:43 |
Message-ID: | 200511180230.jAI2Uh406548@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
mark(at)mark(dot)mielke(dot)cc wrote:
> On Thu, Nov 17, 2005 at 10:15:30AM -0500, Stephen Frost wrote:
> > REPLACE/INSERT ON DUPLICATE UPDATE appears to essentially be a
> > transaction which is supposed to not fail but instead do locking to
> > ensure that it doesn't fail. This requires predicate locking to be
> > efficient because you want to tell the concurrent transaction "if you
> > have the same key as me, just wait a second and you can do an update
> > 'cause I'm going to create the key if it doesn't exist before I'm done".
>
> Is the requirement for predicate locking, over and above a unique
> constraint on an index that involves the record key, to deal with
> the scenario of two inserts executing at the same time, both before
> commit?
No. If you have a primary key you can easily prevent duplicates. You
need a table lock or predicate locking to prevent duplicates if you do
not have a primary key.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Javier Soltero | 2005-11-18 02:33:39 | Re: Call for sample databases |
Previous Message | Bruce Momjian | 2005-11-18 02:18:25 | Re: MERGE vs REPLACE |