J'ai une table "OFICIAL3" avec 500k lignes. et 30 colonnes. et table INSIS avec 150k lignes et 20 colonnes. OFICIAL3.NUMERO_TITULO a un index. INSIS.NumeroDocumento a aussi un index. mettre à jour la phrase prend beaucoup de temps. ce processus prendra 9 heures dans ma machine ma machine est un core 2 duo 2.GHZ et 2 Go de RAMproblème de performance SQL Server 2005 mise à jour phrase
ALTER PROCEDURE [dbo].[CompletarDatos] AS
declare @cantidad int;
declare @CONTADOR int;
declare @NRO_TITULO VARCHAR(600);
declare @POYECTO VARCHAR(200);
DECLARE @I_PROYECTO VARCHAR(500);
DECLARE @I_AREA_INT VARCHAR(500);
SET NOCOUNT ON
BEGIN
SET @cantidad =(select count(*) from OFICIAL3)
SET @CONTADOR=1
declare CURSORITO cursor for
select NUMERO_TITULO from OFICIAL3
open CURSORITO
fetch next from CURSORITO
into @NRO_TITULO
while @@fetch_status = 0
begin
SET @[email protected]+1
PRINT 'ROW='+CONVERT(NVARCHAR(30),@CONTADOR)+' NRO TITULO='[email protected]_TITULO
SET @I_PROYECTO = (SELECT PROYECTO FROM INSIS WHERE [email protected]_TITULO)
SET @I_AREA_INT = (SELECT I_AREA_INTERVENCION FROM INSIS WHERE [email protected]_TITULO)
UPDATE OFICIAL3 SET [email protected]_PROYECTO , [email protected]_AREA_INT WHERE [email protected]_TITULO
fetch next from CURSORITO into @NRO_TITULO
end
-- cerramos el cursor
close CURSORITO
deallocate CURSORITO
END
Vous avez vraiment besoin de trouver une approche qui n'implique pas de curseur. C'est probablement le problème. – DOK