Subject RE: [firebird-support] FOR SELECT .. DO .. UPDATE is slow
Author Epstein, Ed
>>FOR SELECT int_mov_id,
mny_credit,
mny_debit,
mny_balance
from TB_MOV
where BLN_CALC = 'N'
into :MovID , :Credit, :Debit, :Balance
DO BEGIN
NewBalance = OldBalance + Credit - Debit;

update TB_MOV set
mny_balance = :NewBalance,
bln_calc = 'S'
where int_mov_id = :MovID;

OldBalance = NewBalance;
END;
>>

If the update has been removed and it is still slow the only thing I can
think about is the WHERE BLN-CAL = 'N' condition on your select statement.
Is that field indexed? That could affect speed.

Also, if your update is changing an indexed field that will take longer
since to my knowledge, and others can correct me please, an indexed field is
recalculated for every commited transaction that updates the field.
Disabling the index before the update and then reactivating it afterwards
could speed up the process.


[Non-text portions of this message have been removed]