Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/04/2011, 18:08
sicum1
 
Fecha de Ingreso: abril-2011
Mensajes: 1
Antigüedad: 13 años, 8 meses
Puntos: 0
Pregunta Problema de lentitud en store procedure

declare @Fecha1 DateTime
declare @Fecha2 DateTime
declare @Turno nvarchar(50)
declare @PartNumber nvarchar(50)
set @Fecha1 = '01/01/2001'
set @Fecha2 = '01/01/2100'
set @Turno = '%'
set @PartNumber = '%'
SELECT PartNumber, Descripcion,
(SELECT SUM(Cantidad) AS Expr1
FROM dbo.PartNoIn
WHERE (FECHAPROD BETWEEN @fecha1 AND @fecha2) AND (PARTNUMBER = FinishGood1.PartNumber) AND (TURNO LIKE N'%' + @Turno + N'%'))
AS Entradas,
(SELECT SUM(Cantidad) AS Expr2
FROM dbo.PartNoOut
WHERE (FECHAPROD BETWEEN @fecha1 AND @fecha2) AND (PARTNUMBER = FinishGood1.PartNumber) AND (TURNO LIKE N'%' + @Turno + N'%'))
AS Salidas,
(SELECT SUM(Cantidad) AS Expr3
FROM dbo.PartNoReq1
WHERE (FECHAPROD BETWEEN @fecha1 AND @fecha2) AND (PARTNUMBER = FinishGood1.PartNumber) AND (TURNO LIKE N'%' + @Turno + N'%'))
AS Requerimiento1,
(SELECT SUM(Cantidad) AS Expr4
FROM dbo.PartNoReq2
WHERE (FECHAPROD BETWEEN @fecha1 AND @fecha2) AND (PARTNUMBER = FinishGood1.PartNumber) AND (TURNO LIKE N'%' + @Turno + N'%'))
AS Requerimiento2,
(SELECT SUM(Cantidad) AS Expr5
FROM dbo.PartNoRec
WHERE (FECHAPROD BETWEEN @fecha1 AND @fecha2) AND (PARTNUMBER = FinishGood1.PartNumber) AND (TURNO LIKE N'%' + @Turno + N'%'))
AS Recibos,
(SELECT SUM(Cantidad) AS Expr6
FROM dbo.Final
WHERE (FECHAPROD BETWEEN @fecha1 AND @fecha2) AND (PARTNUMBER = FinishGood1.PartNumber) AND (TURNO LIKE N'%' + @Turno + N'%'))
AS Total
FROM dbo.FinishGood1
WHERE (PartNumber LIKE N'%' + @PartNumber + N'%') And (Total <>0)

Tengo este store procedure que tarda aprox 50 segundos lo que ocaciona que mi pagina me marque time out necesito encontrar la forma de acelerarlo no importa si tengo que modificarlo o cualquier cosa que se requiera hacer