SuperX

KontaktMail für InfosSuchenLogin

Beschleunigung von Updates

statt

update ${tabellenname} set ${cifx_key.name}=(select min(apnr) from trans_cifx Z
where Z.key=${cifx_key.key}
and Z.systeminfo_id=${systeminfo_id}
and  Z.sourcesystem_id=${tabellenname}.${cifx_key.name}
and Z.sourcesystem=${Quellsystem_var} --hisinone
);

schneller

with tmp_${cifx_key.key} (${cifx_key.name}, apnr) as (
select S.${cifx_key.name}, min(apnr) as apnr
from trans_cifx Z inner join ${tabellenname} S
on Z.sourcesystem_id=S.${cifx_key.name}
where Z.key=${cifx_key.key}
and Z.systeminfo_id=${systeminfo_id}
and Z.sourcesystem=${Quellsystem_var}
group by S.${cifx_key.name}
update ${tabellenname} set ${cifx_key.name}=(select apnr from tmp_${cifx_key.key}
where ${tabellenname}.${cifx_key.name} = tmp_${cifx_key.key}.${cifx_key.name})
where ${tabellenname}.${cifx_key.name} in (select ${cifx_key.name} from tmp_${cifx_key.key})

evtl noch schneller:

with...
update ${tabellenname} set ${cifx_key.name}=tmp_${cifx_key.key}.apnr
from tmp_${cifx_key.key} where ${tabellenname}.${cifx_key.name} = tmp_${cifx_key.key}.${cifx_key.name}
and ${tabellenname}.${cifx_key.name} in (select ${cifx_key.name} from tmp_${cifx_key.key})

Beispiel:

create index ix_tmp_erg1 on tmp_erg (buchungsab_fb);
with tmp_fb (buchungsab_fb, ktobez) as (
select F.buchungsab_fb, max(ktobez) as ktobz
from fin_buchab_fb F inner join tmp_erg T
on T.buchungsab_fb=F.buchungsab_fb
where F.jahr=<>

group by 1)
update tmp_erg T set buchungsab_fb_bez=tmp_fb.ktobez
from tmp_fb where T.buchungsab_fb = tmp_fb.buchungsab_fb;