Re: A Question of design.
- From: "Rik" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Tue, 24 Oct 2006 18:56:32 +0200
Chung Leong wrote:
Create an array of what to add, capture all existing items inThen you end up with a race condition, I think even if a transaction
another array , then it's a simple question of array_diff() for
items that are invalid.
Then create an array of already owned items, array_intersect() will
tell you what to update, the rest will have to be added.
is used. If there are two threads trying to insert the same data
running simultaneously, a transaction would not block the second
thread from fetching the same result set as the first. Thus both
threads could
think that a particular record doesn't exist and both would insert it.
You would need to lock the table for the duration of the entire
operation, which is pretty lousy.
My solution was purely to give him back the information he wants (he not
only wants to reject invalids, update already existing, and insert new, but
he wants to know which ones they are).
The actual updating can still be done with the previous simple replace
into, avoiding race condition.
--
Grtz,
Rik Wasmus
.
- Follow-Ups:
- Re: A Question of design.
- From: Daz
- Re: A Question of design.
- From: Chung Leong
- Re: A Question of design.
- References:
- A Question of design.
- From: Daz
- Re: A Question of design.
- From: Chung Leong
- Re: A Question of design.
- From: Daz
- Re: A Question of design.
- From: Chung Leong
- Re: A Question of design.
- From: Daz
- Re: A Question of design.
- From: Jerry Stuckle
- Re: A Question of design.
- From: Daz
- Re: A Question of design.
- From: Jerry Stuckle
- Re: A Question of design.
- From: Daz
- Re: A Question of design.
- From: Rik
- Re: A Question of design.
- From: Chung Leong
- A Question of design.
- Prev by Date: Re: A Question of design.
- Next by Date: Re: A Question of design.
- Previous by thread: Re: A Question of design.
- Next by thread: Re: A Question of design.
- Index(es):
Relevant Pages
|
Loading