MySQL Forums
Forum List  »  InnoDB

Re: Two updates deadlocking because where clause chooses the wrong index
Posted by: Vinod Sugur
Date: November 03, 2008 02:28AM

Hi Deron,

We can have one more master table which has only status of latest records for example:

Create table latest_row
(section integer not null primary key,
as_of datetime not null);

Insert into latest_row
Select section,as_of
from t
where is_current ='Y';

The below update will only work on section and won't have any locking issue.

Update t, latest_row lr
set t.is_current ='N'
where t.section = lr.section and
t.as_of = lr.as_of
and lr.section =1;

~Vinod

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Two updates deadlocking because where clause chooses the wrong index
1561
November 03, 2008 02:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.