
Envoyé par
Pol63
!?
qu'une sous requete se base sur une valeur de la requete de base je veux bien croire que c'est à éviter mais ce n'est pas ton cas
si tu arrives à constater une différence de performances entre
select * from table where a = ? and b = ?
et
select * from table where a = b and b = ?
change de sgbdr tout de suite !
select FACT.ACTACT, bchld,IIM2.iityp type_enfant, IIM2.iclas classe_enfant, FACT2.ACTACT activite_enfant, sum(tqty) quantite, sum(tqty*(cftlvl+cfplvl)*bqreq) valeur from bpcs61usrf.mbmhst inner join bpcs61usrf.iimhst IIM on (IIM.iprod = bprod and IIM.imois = mmois and IIM.iannee = mannee and IIM.iid = 'IM') inner join bpcs61usrf.iimhst IIM2 on (IIM2.iprod = bchld and IIM2.imois = mmois and IIM2.iannee = mannee and IIM2.iid = 'IM') inner join bpcs61usrf.ftyp FTYP on IIM.iityp = FTYP.typtyp inner join bpcs61usrf.ftyp FTYP2 on IIM2.iityp = FTYP2.typtyp inner join bpcs61usrf.fact FACT on SUBSTR(FACT.actcen, 1, 1) = case when FTYP.typact = 0 then SUBSTR(IIM.iclas, 1, 1) else CHAR(FTYP.typact) end inner join bpcs61usrf.fact FACT2 on SUBSTR(FACT2.actcen, 1, 1) = case when FTYP2.typact = 0 then SUBSTR(IIM2.iclas, 1, 1) else CHAR(FTYP2.typact) end inner join bpcs61f.ithl01 on (bprod = tprod and thcntr = '201110' and ttype = 'PR') LEFT JOIN bpcs61usrf.cmfhst on (cfprod = bchld and cffac = 'F1' and cfcset = 2 and cfcbkt = 0 and cfmnth = mmois and cfyear = mannee and cfid = 'CF') where bid = 'BM' and mmois = 10 and mannee = 2011 group by FACT.ACTACT, bchld,IIM2.iityp, IIM2.iclas, FACT2.ACTACT having bchld in ( select bchld from bpcs61usrf.mbmhst inner join bpcs61usrf.iimhst on (iprod = bprod and iid = 'IM' and imois = mmois and iannee = mannee) inner join bpcs61usrf.ftyp on iityp = typtyp inner join bpcs61usrf.fact on SUBSTR(actcen, 1, 1) = case when typact = 0 then SUBSTR(iclas, 1, 1) else CHAR(typact) end where bid = 'BM' and mmois = 10 and mannee = 2011 group by bchld having count (distinct actact) >1 ) and FACT.actact <> FACT2.actact order by bchld, fact.actact
Statement ran successfully (123154 ms)
> select FACT.ACTACT, bchld,IIM2.iityp type_enfant, IIM2.iclas classe_enfant, FACT2.ACTACT activite_enfant, sum(tqty) quantite, sum(tqty*(cftlvl+cfplvl)*bqreq) valeur from bpcs61usrf.mbmhst inner join bpcs61usrf.iimhst IIM on (IIM.iprod = bprod and IIM.imois = 10 and IIM.iannee = 2011 and IIM.iid = 'IM') inner join bpcs61usrf.iimhst IIM2 on (IIM2.iprod = bchld and IIM2.imois = 10 and IIM2.iannee = 2011 and IIM2.iid = 'IM') inner join bpcs61usrf.ftyp FTYP on IIM.iityp = FTYP.typtyp inner join bpcs61usrf.ftyp FTYP2 on IIM2.iityp = FTYP2.typtyp inner join bpcs61usrf.fact FACT on SUBSTR(FACT.actcen, 1, 1) = case when FTYP.typact = 0 then SUBSTR(IIM.iclas, 1, 1) else CHAR(FTYP.typact) end inner join bpcs61usrf.fact FACT2 on SUBSTR(FACT2.actcen, 1, 1) = case when FTYP2.typact = 0 then SUBSTR(IIM2.iclas, 1, 1) else CHAR(FTYP2.typact) end inner join bpcs61f.ithl01 on (bprod = tprod and thcntr = '201110' and ttype = 'PR') LEFT JOIN bpcs61usrf.cmfhst on (cfprod = bchld and cffac = 'F1' and cfcset = 2 and cfcbkt = 0 and cfmnth = 10 and cfyear = 2011 and cfid = 'CF') where bid = 'BM' and mmois = 10 and mannee = 2011 group by FACT.ACTACT, bchld,IIM2.iityp, IIM2.iclas, FACT2.ACTACT having bchld in ( select bchld from bpcs61usrf.mbmhst inner join bpcs61usrf.iimhst on (iprod = bprod and iid = 'IM' and imois = 10 and iannee = 2011) inner join bpcs61usrf.ftyp on iityp = typtyp inner join bpcs61usrf.fact on SUBSTR(actcen, 1, 1) = case when typact = 0 then SUBSTR(iclas, 1, 1) else CHAR(typact) end where bid = 'BM' and mmois = 10 and mannee = 2011 group by bchld having count (distinct actact) >1 ) and FACT.actact <> FACT2.actact order by bchld, fact.actact
Statement ran successfully (8344 ms)
N'ayant trouvé aucune solution à mon problème de base, tampis je passerai autant de fois que demandé le paramètre mois, et le paramètre année.
Merci pour toutes vos propositions et votre aide
Partager