Subject Re: Optimizer request
Author Virgo Pärna
On Wed, 19 Oct 2016 09:34:32 +0200 (CEST), ehmmm.firebird@... [firebird-support] <firebird-support@yahoogroups.com> wrote:
>
> update orders o
> set o.something = 'something other'
> where o.delivery_date is null
>   and o.partid in (select p.partid from partners p where p.country='Spain')
>
> Would using EXISTS() help?
>

IIRC Firebird will optimize IN to EXISTS anyway, if possible.
Only way to really optimize this kind of update would be with
stored procedure or EXECUTE BLOCK. Like:

execute block as
declare variable partid integer;
begin
for select p.partid
from partners p
where p.country='Spain'
into :partid do
begin
update orders o set o.something = 'something other'
where o.delivery_date is null and o.partid = :partid;
end
end

--
Virgo Pärna
virgo.parna@...