Subject | Re: Optimizer request |
---|---|
Author | Virgo Pärna |
Post date | 2016-10-26T13:14Z |
On Wed, 19 Oct 2016 09:34:32 +0200 (CEST), ehmmm.firebird@... [firebird-support] <firebird-support@yahoogroups.com> wrote:
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@...
>IIRC Firebird will optimize IN to EXISTS anyway, if possible.
> 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?
>
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@...