Subject Re: FOR SELECT .. DO .. UPDATE is slow
Author clementdoss
--- In firebird-support@yahoogroups.com, "Epstein, Ed"
<eepstein@c...> 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;
> >>
>
> think about is the WHERE BLN-CAL = 'N' condition on your select
statement.
> Is that field indexed? That could affect speed.

No. BLN_CALC is not indexed because the only values allowed are S/N
(YES/NO)

>
> Also, if your update is changing an indexed field that will take
longer

Neither of those fields are indexed :-(
and int_mov_id is a primary key field.
The update should be very fast.


Clément