Subject Re: [firebird-support] update with subselect, speed / optimization (data repair)
Author unordained
Thanks to both of you,

I actually tried out the temp table of id's to update. Running a similar query with -that- table
being used took about 12 minutes. Not fast, but ... faster than untold hours. Is the lack of use of
the index part of a larger problem fixed in 1.5, that might cause some of my other difficulties?
Can you describe the "root cause" of the index only being picked up for half the statement? Might
help me get around other cases with similar symptoms.

-philip

> Hi SET and Philip,
>
> > >update transactions set transactions.tax_entity_id = (select
> > >bills.actual_tax_id from bills where
> > >bills.id = transactions.bill_id) where transactions.tax_entity_id =
> > >(select bills.provider_tax_id
> > >from bills where bills.id = transactions.bill_id);
> >
> > I'll assume this SQL executes correctly. Try changing to
> >
> > update transactions
> > set transactions.tax_entity_id =
> > (select B1.actual_tax_id from bills B1
> > where B1.id = transactions.bill_id)
> > where EXISTS
> > (select * from bills B2
> > where transactions.tax_entity_id = B2.provider_tax_id
> > AND B2.id = transactions.bill_id);
>
> Using a EXISTS wouldn't help here. This is a problem for every IB and
> FB1.0.x version. The only workaround is using a Stored Procedure or waiting
> for FB1.5-final/using FB 1.5-RC4 (it's fixed in FB1.5).
>
> Regards,
> Arno Brinkman
> ABVisie