Bonjour,

Voici ma procedure stockee, qui ma pris pas mal de temp a develloper et qui me renvoiles information que je veux. Le probleme , c'est que la performance de cette procedure est tres mauvaise et tres longue.

Merci pour vos idee afin de l'optimiser.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
SELECT DISTINCT dateend,active,Tparts.idpart,TParts.Namepart, 
COALESCE( (SELECT     SUM(nb)  FROM   TEChart   WHERE      TEChart.part = TParts.idpart and qc=0  and DateInsp>=@start and DateInsp<=@end),0)  AS review 
,COALESCE((SELECT     SUM(nb)
                            FROM          TEChart
                            WHERE      TEChart.part = TParts.idpart and TEchart.qc = @concern   and DateInsp>=@start and DateInsp<=@end),0) AS reject,
                     COALESCE
                          ((SELECT     - DATEDIFF(day, GETDATE(), MAX(DateInsp))
                              FROM         TEchart
                              WHERE     TEchart.QC <> 0 AND TEchart.part = TParts.idPart
                              GROUP BY TEchart.part),
                          (SELECT     - DATEDIFF(day, GETDATE(),
                                                       (SELECT     datestart
                                                         FROM          Tproject
                                                         WHERE      idproject= @project)))) AS jour
FROM Tparts,TPartQC
WHERE Tparts.project=@project and TPartQC.qc=@concern  and TPartQC.part=Tparts.idpart 
order by reject DESC,active DESC,review DESC