MySQL Forums
Forum List  »  French

Re: Requetes trop longue à exécuter
Posted by: Sarah QULORE
Date: December 07, 2018 06:29AM

Bonjour Jean, désolé du temps de réponse.

Les tables sont toutes en InnoDB.

Et concernant les requètes testé en voici une pour exemple (la plus compliqué étant qu'elle utilise un substring au passage sur divers éléments) :

select id_ame,ifnull(Demontage_Ame,0),a.id_produit,id_HP_Gauche,ifnull(Demontage_HPG,0),iG.valeur Lot_Coque_Gauche,iG.date_and_time Date_Coque_Gauche,
id_HP_Droite,ifnull(Demontage_HPD,0),iD.valeur Lot_Coque_Droite,iD.date_and_time Date_Coque_Droite,b.date_and_time date_130,c.date_and_time date_140 from
(select id_produit, id_produit_enfant id_ame from association) a join
(select id_produit, id_produit_enfant id_HP_Gauche, a.date_and_time from association a join produit p on a.id_produit_enfant=p.id where type = 'HP_Gauche') b on a.id_produit=b.id_produit join
(select id_produit, id_produit_enfant id_HP_Droite, a.date_and_time from association a join produit p on a.id_produit_enfant=p.id where type = 'HP_Droite') c on a.id_produit=c.id_produit left outer join
(select * from information where op = 120 order by date_and_time desc) iG on iG.id_produit = id_HP_Gauche left outer join
(select * from information where op = 120 order by date_and_time desc) iD on iD.id_produit = id_HP_Droite left outer join
(select substring(valeur,7,13) id,count(*) Demontage_Ame from information where nom = 'Dissociation_Parent_Enfant' group by substring(valeur,7,13)) iAme on id_ame=iAme.id left outer join
(select substring(valeur,7,13) id,count(*) Demontage_HPG from information where nom = 'Dissociation_Parent_Enfant' group by substring(valeur,7,13)) iHPG on id_HP_Gauche=iHPG.id left outer join
(select substring(valeur,7,13) id,count(*) Demontage_HPD from information where nom = 'Dissociation_Parent_Enfant' group by substring(valeur,7,13)) iHPD on id_HP_Droite=iHPD.id
where id_ame in ('','nom1','nom2','nom3','nom4') /*;
/*Analyse "fuite" produits déjà démontés*/
union
select id_ame,ifnull(Demontage_Ame,0),a.id_produit,id_HP_Gauche,ifnull(Demontage_HPG,0),iG.valeur Lot_Coque_Gauche,iG.date_and_time Date_Coque_Gauche,
id_HP_Droite,ifnull(Demontage_HPD,0),iD.valeur Lot_Coque_Droite,iD.date_and_time Date_Coque_Droite,s130.date_and_time date_130,s140.date_and_time date_140
from
(select a.id_produit, a.id_ame
from (select id_produit,substring(valeur,7,13) id_ame,date_and_time from information where nom = 'Dissociation_Parent_Enfant') a join
(select substring(valeur,7,13) id_ame,max(date_and_time) max_date from information where nom = 'Dissociation_Parent_Enfant' group by substring(valeur,7,13)) b
on a.id_ame=b.id_ame and date_and_time=max_date) a left outer join
(select id_produit, p.id id_HP_Gauche from information i join produit p on substring(i.valeur,7,13)=p.id where type = 'HP_Gauche' and nom = 'Dissociation_Parent_Enfant') b on a.id_produit=b.id_produit left outer join
(select id_produit, p.id id_HP_Droite from information i join produit p on substring(i.valeur,7,13)=p.id where type = 'HP_Droite' and nom = 'Dissociation_Parent_Enfant') c on a.id_produit=c.id_produit left outer join
(select * from information where op = 120 order by date_and_time desc) iG on iG.id_produit = id_HP_Gauche left outer join
(select * from information where op = 120 order by date_and_time desc) iD on iD.id_produit = id_HP_Droite left outer join
suivi s130 on a.id_produit=s130.id_produit and s130.op=130 left outer join
suivi s140 on a.id_produit=s140.id_produit and s140.op=140 left outer join
(select substring(valeur,7,13) id,count(*)-1 Demontage_Ame from information where nom = 'Dissociation_Parent_Enfant' group by substring(valeur,7,13)) iAme on id_ame=iAme.id left outer join
(select substring(valeur,7,13) id,count(*)-1 Demontage_HPG from information where nom = 'Dissociation_Parent_Enfant' group by substring(valeur,7,13)) iHPG on id_HP_Gauche=iHPG.id left outer join
(select substring(valeur,7,13) id,count(*)-1 Demontage_HPD from information where nom = 'Dissociation_Parent_Enfant' group by substring(valeur,7,13)) iHPD on id_HP_Droite=iHPD.id
where id_ame in ('','nom1','nom2','nom3','nom4');

Options: ReplyQuote


Subject
Views
Written By
Posted
214
October 30, 2018 02:52AM
Re: Requetes trop longue à exécuter
79
December 07, 2018 06:29AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.