Subject | Re: [firebird-support] FOR SELECT .. DO .. UPDATE is slow |
---|---|
Author | Alexandre Benson Smith |
Post date | 2004-07-19T18:40:24Z |
clementdoss wrote:
Teh table has only 7701 records or you are updating 7701 of a million
(billion) records ?
Try to execute the same query direct with any sql tool and look at the
plan and for how long it executes.
SELECT int_mov_id,
mny_credit,
mny_debit,
mny_balance
from TB_MOV
where BLN_CALC = 'N'
Any search on a 7701 records table should be really fast !
see you !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
>Hi,Hi, Clément !
>
>I'm using WI-V6.3.0.436 Firebird 1.5
>
>I am building a small stored procedure, and I need to update some
>records (7701). And I believe it's taking too much time. 10+ minutes.
>I don't know if this is the best way.
>This is the code I'm using:
>
>OLDBalance = 0;
>
>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;
>
>
>I have commented out the "update TB_MOV ..." code out of it. And
>it's still very slow, so I guess that the update is not the issue,
>but this FOR SELECT is slow. Am I correct? Can a FOR SELECT be that
>slow?
>What would be the correct way to implement this code in FB?
>
>TIA,
>Clément
>
>
>
Teh table has only 7701 records or you are updating 7701 of a million
(billion) records ?
Try to execute the same query direct with any sql tool and look at the
plan and for how long it executes.
SELECT int_mov_id,
mny_credit,
mny_debit,
mny_balance
from TB_MOV
where BLN_CALC = 'N'
Any search on a 7701 records table should be really fast !
see you !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br