Optimisation requête jointure NOT IN
Bonjour,
J'ai actuellement une requête avec 5 jointures, dont une qui pose des problèmes de performance. La voici :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
SELECT DISTINCT
commande.montant,
commande.objet as objet,
commande2.commande_num as numCommandeSpeciale
FROM ref.commande as commande
LEFT OUTER JOIN ref.commande as commande2 ON commande.commande_num = commande2.commande_num
AND commande.colonne1 ='O'
AND commande.statut IN ('XXX', 'YYY', 'ZZZ')
AND commande2.commande_num NOT IN (SELECT DISTINCT commande_num FROM ref.table2 WHERE colonne1 IS NOT NULL)
WHERE commande.client = '000001' |
Comment puis-je améliorer cela d'un point de vue performances sachant qu'il y a déjà les index adéquats.
Merci pour votre aide