Mejorar la velocidad de esta consulta

hola amigos de SAP tengo esta consulta que se demora mas de 1 min y medio en ejecutarse alguien me puede ayudar a mejorarla por favor para que se ejecute mas rápido gracias

SELECT DISTINCT 
                         T1.Project AS Proyecto, 
					CONVERT(int, T2.DocNum) AS numFactura, 
					T2.DocDate AS Fecha, 
					T2.DocStatus AS Estado,
					T2.CardCode AS [Cod Cliente],
					T2.CardName AS [Nom Cliente], 
                         T5.SlpName AS [Empleado Ventas],
					T2.BaseAmnt AS valorSinImp, 
					T2.PaidSum AS valorConImp, 
					T2.DocTotal AS Totalfactura, 
					ISNULL(T6.LocTotal, 0) AS Pagado, 
					ISNULL(t55.SUMA_ingreso, 0) AS Ingreso, 
                         ISNULL(t33.Suma_Gasto, 0) + ISNULL(t44.Suma_costoOper, 0) + ISNULL(t22.Suma_costoperso, 0) AS Gasto_Costo, (ISNULL(t55.SUMA_ingreso, 0) - ISNULL(t25.Sum_Gasto_Costo, 0)) 
                         / t55.SUMA_ingreso * 100 AS Rentabilidad, T2.BaseAmnt * 0.0043 AS ValorComision
FROM            dbo.OJDT AS T0 INNER JOIN
                         dbo.JDT1 AS T1 ON T0.TransId = T1.TransId LEFT OUTER JOIN
                         dbo.OINV AS T2 ON T0.TransId = T2.TransId LEFT OUTER JOIN
                             (SELECT       TA.DocEntry, TA.Project
                               FROM            dbo.INV1 AS TA) AS T3 ON T2.DocEntry = T3.DocEntry AND T0.Project = T3.Project LEFT OUTER JOIN
                         dbo.ITR1 AS T4 ON T0.TransId = T4.TransId LEFT OUTER JOIN
                         dbo.OSLP AS T5 ON T2.SlpCode = T5.SlpCode LEFT OUTER JOIN
                         dbo.ORCT AS T7 ON T0.TransId = T7.TransId LEFT OUTER JOIN
                         dbo.vista_pruebas_Comiciones AS t55 ON T1.Project = t55.Project LEFT OUTER JOIN
                         dbo.vistaCostoIngresos AS t33 ON T1.Project = t33.Project LEFT OUTER JOIN
                         dbo.vistaCostoOpera AS t44 ON T1.Project = t44.Project LEFT OUTER JOIN
                         dbo.vistaCostoPersonal AS t22 ON T1.Project = t22.Project LEFT OUTER JOIN
                         dbo.SumaGastoCosto AS t25 ON T1.Project = t25.Project LEFT OUTER JOIN
                             (SELECT DISTINCT TA.DocNum, TB.LocTotal, TC.TransId, TC.ReconNum
                               FROM            dbo.ORCT AS TA INNER JOIN
                                                         dbo.OJDT AS TB ON TA.TransId = TB.TransId INNER JOIN
                                                         dbo.ITR1 AS TC ON TB.TransId = TC.TransId) AS T6 ON T4.ReconNum = T6.ReconNum
WHERE        (YEAR(T2.DocDate) >= 2021) AND (T1.Project IS NOT NULL)
GROUP BY T1.Project, T2.DocNum, T2.DocDate, T6.DocNum, T2.CardCode, T2.CardName, T5.SlpName, T2.BaseAmnt, T2.PaidSum, T2.DocTotal, T2.DocStatus, T6.LocTotal, t55.SUMA_ingreso, t33.Suma_Gasto, 
                         t44.Suma_costoOper, t22.Suma_costoperso, t25.Sum_Gasto_Costo

Hola @jtriana6591
Creo que es difícil optimizar una consulta que no sabemos que muestra u objetivo tiene y adicionalmente que llama a vistas que no conocemos.
Te recomiendo crear un procedimiento almacenado ya que estos elementos son precompilados y tiene tiempos de ejecución mas cortos

Andres Ramirez Jaramillo :colombia:

Este tema se cerró automáticamente 7 días después de la última publicación. No se permiten nuevas respuestas.