Bonjour ,
Je doit optimiser les procédures utilisées par une application qui utilise une requête bourine

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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
UPDATE hist_chemin T1 
SET
 
T1.cout_degr_pal1_init= (SELECT T2.cout1_init
  FROM hist_chemin_plan_transport T2
  WHERE t2.hist_date = dateLastHistDATE
  AND T2.seq_chemin   = T1.seq_chemin
  ) ,
 
 T1.cout_degr_pal2_init= (SELECT T2.coutl2_init
  FROM hist_chemin_plan_transport T2
  WHERE t2.hist_date = dateLastHistDATE
  AND T2.seq_chemin   = T1.seq_chemin
  )   ,
 
   T1.cout_degr_pal3_init= (SELECT T2.cout3_init
  FROM hist_chemin_plan_transport T2
  WHERE t2.hist_date = dateLastHistDATE
  AND T2.seq_chemin   = T1.seq_chemin
  )   ,
 
   T1.cout_degr_pal4_init= (SELECT T2.cout4_init
  FROM hist_chemin_plan_transport T2
  WHERE t2.hist_date = dateLastHistDATE
  AND T2.seq_chemin   = T1.seq_chemin
  )   ,
   T1.cout_degr_pal5_init= (SELECT T2.coutal5_init
  FROM hist_chemin_plan_transport T2
  WHERE t2.hist_date = dateLastHistDATE
  AND T2.seq_chemin   = T1.seq_chemin
  )   ...
Comme vous vous en doutez, sur une table de 2 millions de lignes ça prend 2 heures, je cherche une piste d'optimisation.
J'ai trouvé avec les curseurs, j’aimerais savoir si cette solution est idéale, car il ne faut pas que je me trompe

Cordialement