-
@andreas
Im Prinzip klar, aber im konkreten Bsp sehe ich keine Optimierung
Die View:
Code:
create view hissc#v01 as(
-- wieviele Monate?
with xx as (select dec(substr(inhacd, 1, 2), 2, 0) as mon
from cbuchp01
where finrcd = 0 and sprccd = 'D' and sakzcd = '6' and
sartcd = 'FORMMK' and rkeycd = 'BONCNT'),
-- aktuellste Satz?
yy as (
-- aktuelle Score Daten, deren 'normaler' Score nicht älter als 24Monate ist
-- wobei die 24 aus dem codebuch kommt
select max(dajjmt) as dd, hcsunr, hcsun2, hcsu22, hcdejj, hcdemm, hcdett
from datump
inner join hisscp on hcdejj = dajjjj and hcdemm = damm and hcdett = datt
where dadate>=(current_date-(select mon from xx) Months) and hcklas='K10'
group by hcsunr, hcsun2, hcsu22, hcdejj, hcdemm, hcdett
-- having max(dadate) >= (current_date - (select mon from xx) Months)),
),
-- hisscp satz da ich ja den Score brauche
a as (
select dd as d, a.hcsunr, a.hcsu22, a.hcsun2, hckate as maxscore
from hisscp a
inner join yy on yy.hcsunr = a.hcsunr and yy.hcsun2 = a.hcsun2 and
yy.hcsu22 = a.hcsu22 and yy.hcdejj = a.hcdejj and
yy.hcdemm = a.hcdemm and yy.hcdett = a.hcdett
where a.hcklas = 'K10')
-- hisscp verknüpft mit aktenp und mandap und makesp
select azkey1, azkey2, azkey3, d, maxscore, dec(case when azsun2 = 3 then 2
else 1 end, 1, 0) as cnt,
azmk, azmst, makzfo, azdwit, azdwim, azdwij, azfonr,
dec(azdwij*10000+azdwim*100+azdwit, 8, 0) as dawivo, mkform
from aktenp, a, mandap, makesp
where a.hcsu22 = azsun2 and a.hcsunr = azsunr and azmaan = maaunr and
azmanr = mamdnr and azmk = mkkett and azmst = mkstuf and
mkmkgr = mamkgr and azmk <> 99 and azmk <> 999
-- und nun noch die, die keinen gültigen score haben
union all
select azkey1, azkey2, azkey3, dec(20491231, 8, 0) as d,
'00000' as maxscore, dec(1, 1, 0) as cnt,
azmk, azmst, makzfo, azdwit, azdwim, azdwij, azfonr,
dec(azdwij*10000+azdwim*100+azdwit, 8, 0) as dawivo, mkform
from aktenp left outer join a on azsunr = a.hcsunr and azsun2 = a.hcsun2
inner join mandap on azmanr = mamdnr and azmaan = maaunr
inner join makesp on azmk = mkkett and azmst = mkstuf and mkmkgr = mamkgr
where a.hcsunr is null and azmk <> 99 and azmk <> 999
);
und die Abfrage im Pgm
Code:
C/EXEC SQL
C+ SET :AMSFO_E =(SELECT COUNT(*) FROM HISSC#V01 WHERE
C+ (AZFONR = :MASN OR MKFORM = :MASN)
C+ AND DAWIVO <= :DTV AND MAKZFO = 1 AND
C+ MAXSCORE <> '00000' AND AZFONR <> 712)
C/END-EXEC
umgebaut auf
with a as (sELECT dec(COUNT(*), 8, 0) as c FROM HISSC#V01 WHERE
AZFONR = :masn AND DAWIVO <= :DTV AND MAKZFO = 1 AND
MAXSCORE <> '00000' AND AZFONR <> 712),
b as (sELECT dec(COUNT(*), 8, 0) as c FROM HISSC#V01 WHERE
mkform = :masn AND DAWIVO <= 20151022 AND MAKZFO = 1 AND
MAXSCORE <> '00000' AND AZFONR <> 712)
select a.c+b.c from a, b
braucht deutlich länger
@Baldur
na ja
Decimal (gepackt) und Numeric (Zoned)
ist hier bunt durcheinander
Das kann ich nochmal versuchen.
Bin z.Zt. knapp unter 4 Minuten und habe von den insgesamt 26 empfohlen indices nur 5 angelegt.
@cbe
hilft hier wahrscheinlich nicht,
view in pf,
mehrere Lf auf pf
count
lf löschen
pf löschen
Die View hat um die 1,15 Mio Sätze
allein der count(*) ohne jeden Where dauert mehrere Minuten
Danke und Gruß
Robi
Das Notwendige steht über dem technisch machbaren.
(klingt komisch, funktioniert aber!)
Similar Threads
-
By dschroeder in forum NEWSboard Programmierung
Antworten: 14
Letzter Beitrag: 04-04-14, 08:32
-
By NEWSolutions Redaktion in forum NEWSolutions artikel
Antworten: 0
Letzter Beitrag: 02-11-13, 11:53
-
By Newbie in forum IBM i Hauptforum
Antworten: 3
Letzter Beitrag: 04-07-02, 09:19
-
By Kent in forum IBM i Hauptforum
Antworten: 4
Letzter Beitrag: 19-06-01, 11:45
-
By becama in forum IBM i Hauptforum
Antworten: 3
Letzter Beitrag: 07-04-01, 10:08
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- You may not post attachments
- You may not edit your posts
-
Foren-Regeln
|
Erweiterte Foren Suche
Google Foren Suche
Forum & Artikel Update eMail
AS/400 / IBM i
Server Expert Gruppen
Unternehmens IT
|
Kategorien online Artikel
- Big Data, Analytics, BI, MIS
- Cloud, Social Media, Devices
- DMS, Archivierung, Druck
- ERP + Add-ons, Business Software
- Hochverfügbarkeit
- Human Resources, Personal
- IBM Announcements
- IT-Karikaturen
- Leitartikel
- Load`n`go
- Messen, Veranstaltungen
- NEWSolutions Dossiers
- Programmierung
- Security
- Software Development + Change Mgmt.
- Solutions & Provider
- Speicher – Storage
- Strategische Berichte
- Systemmanagement
- Tools, Hot-Tips
Auf dem Laufenden bleiben
|
Bookmarks