Bonjour,

Dans ma base access, j'ai une requête dont l'exécution est particulièrement longue:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
SELECT DT.Numéro_dt, DT.Problème_signalé, DT.Nom_opérateur_prob, DT.Problème_signalé, DT.Date_prob, Organe.Organe, Machine.Machine, Section.Section, Organe.Numero_organe
FROM ([Section] INNER JOIN (Machine INNER JOIN Organe ON Machine.Machine = Organe.Machine) ON Section.Section = Machine.Section) INNER JOIN DT ON Organe.Numero_organe = DT.Num_org
GROUP BY DT.Numéro_dt, DT.Problème_signalé, DT.Nom_opérateur_prob, DT.Problème_signalé, DT.Date_prob, Organe.Organe, Machine.Machine, Section.Section, Organe.Numero_organe
HAVING (((DT.Numéro_dt) In (SELECT [Action].[Num_DT] FROM [Action] WHERE Action.Num_DT NOT IN (SELECT Action.Num_DT FROM [Action] WHERE [Action].[Etat]<>"Terminé" GROUP BY Action.Num_DT) GROUP BY [Action].[Num_DT])) AND ((Machine.Machine)=IIf([Tri_machine] Is Not Null,[Tri_machine],[Machine].[Machine])) AND ((Section.Section)=IIf([Tri_section] Is Not Null,[Tri_section],[Section].[Section])) AND ((Organe.Numero_organe)=IIf([Tri_organe] Is Not Null,[Tri_organe],[Organe].[Numero_organe])))
ORDER BY DT.Numéro_dt DESC;
Je cherche donc à l'optimiser. Or en y regardant de plus près, il me semble que la partie en gras est superflue. Si je la supprime, la requête devient:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
SELECT DT.Numéro_dt, DT.Problème_signalé, DT.Nom_opérateur_prob, DT.Problème_signalé, DT.Date_prob, Organe.Organe, Machine.Machine, Section.Section, Organe.Numero_organe
FROM ([Section] INNER JOIN (Machine INNER JOIN Organe ON Machine.Machine = Organe.Machine) ON Section.Section = Machine.Section) INNER JOIN DT ON Organe.Numero_organe = DT.Num_org
GROUP BY DT.Numéro_dt, DT.Problème_signalé, DT.Nom_opérateur_prob, DT.Problème_signalé, DT.Date_prob, Organe.Organe, Machine.Machine, Section.Section, Organe.Numero_organe
HAVING (((DT.Numéro_dt) Not In (SELECT Action.Num_DT FROM [Action] WHERE [Action].[Etat]<>"Terminé" GROUP BY Action.Num_DT)) AND ((Machine.Machine)=IIf([Tri_machine] Is Not Null,[Tri_machine],[Machine].[Machine])) AND ((Section.Section)=IIf([Tri_section] Is Not Null,[Tri_section],[Section].[Section])) AND ((Organe.Numero_organe)=IIf([Tri_organe] Is Not Null,[Tri_organe],[Organe].[Numero_organe])))
ORDER BY DT.Numéro_dt DESC;
Pensez-vous que ce soit équivalent?

NOTE: Pour info ma base est une MAO (Maintenance Assistée par Ordinateur). Cette requête sert à trier les Demandes de Travail (DT) soldées c'est à dire dont toutes les actions ont été soldées (1 DT = plusieurs actions)

D'avance merci de votre aide