Subject Re: [firebird-support] FOR SELECT .. DO .. UPDATE is slow
Author Milan Babuskov
Epstein, Ed wrote:
>>>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;

Strange thing... Variable "Balance" isn't used at all?

> 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.

It would brobably slow it down since it has low selectivity.

My ideas:

create index on TB_MOV.int_mov_id if it doesn't exists.
remove index on TB_MOV.bln_cals it it does exists.


--
Milan Babuskov
http://fbexport.sourceforge.net