hi , I got two procedures like below :
PART A :
foreach curPhysDel with hold for
select state into v_state
from test
where state = 72
and lastUpdate < v_dateMin
update test
set state = 99,
lastupdate = v_lastupdate
where current of curPhysDel;
end foreach
PART B :
foreach curPurge with hold for
select state into v_state
from teste
where state = 99
and creationDate < v_dateMin
delete from test where current of curPurge;
end foreach
A set lock mode wait to 5 was set before launch theses two procedures.
I launch the part A one hour early than part B.
In the table test there are more than millions records.
No index on state, neither on creationdate.
As long as I launch part B, i got error like below :
(SQL exception ) -244 Could not do a physical-order read to fetch next row
(SQL exception) ISAM ERROR : Lock timeout expired
I got suggestion from eric that i should create index base on state and creationdate. The problem is, for more than millions records each day (creationdate), the state actually only have 6 possible values, so is it worthy to create index ? will it decrease the performance due to this extra index?
Could anybody explain to me? Thanks.