From: | Oleg Bartunov <oleg(at)sai(dot)msu(dot)su> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Performance question |
Date: | 2003-07-02 08:07:36 |
Message-ID: | Pine.GSO.4.56.0307021205230.4628@ra.sai.msu.su |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 2 Jul 2003, Tom Lane wrote:
> Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp> writes:
> > I have suggested that their current INSERT INTO t VALUES() be changed to:
>
> > INSERT INTO
> > T
> > SELECT 'v1', 'v2'
> > WHERE
> > NOT EXISTS (
> > SELECT NULL FROM t WHERE pk='v1'
> > )
>
> That doesn't really buy anything in safety terms: if two backends
> execute this sort of command concurrently, it's perfectly likely
> that both sub-SELECTS will find no row matching 'v1', and so they'll
> both try the INSERT anyway.
>
> IMO the best way to do this (assuming that you have a unique index
> defined on the primary key column) is to just go ahead and try the
> INSERT, but be prepared to roll back your transaction and retry
> if you get a failure.
>
> You might find it useful to read the slides from my talk at last
> year's O'Reilly conference about this and related concurrency
> problems:
> http://conferences.oreillynet.com/cs/os2002/view/e_sess/2681
>
I'd like to see all presentations in one collections. It'd be nice
addition to documentation.
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>
Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83
From | Date | Subject | |
---|---|---|---|
Next Message | Jean-Christian Imbeault | 2003-07-02 08:09:50 | Re: Duplicate key insert question |
Previous Message | Shridhar Daithankar | 2003-07-02 08:05:20 | Re: Duplicate key insert question |