Bonjour,
tout est dans le titre. La requete ci dessous s'execute en 6 minutes
La table Demande compte 7500 entree et la table Salarie environ 20 000 entrees.
Merci d'avance

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
 
Select ....
From Demande Dmd, Corp Crp, Salarie Sal, Structure Str
Where 
Dmd.col1 = 9999
And Dmd.kode In (0,1)
And Dmd.cree = 
(
    Select Max(dmd2.cree) 
    From Demande Dmd2 
    Where Dmd2.col1 = Dmd.col1
    And Dmd2.numsal = Dmd.numsal
    And Dmd2.kode In (0,1)
    And Current Date >= Dmd2.ddebvlt 
)
And Sal.col1 = Dmd.col1
And Sal.numsal = Dmd.numsal
And Crp.col1 = Dmd.col1
And Crp.idcrp = 7777
And Str.col1 = Sal.col1
And Str.refstr = Sal.refstr
 
And Exists
(
    Select 1
    From Corpstr Crpstr
    Where Crpstr.col1 = Crp.col1
    And Crpstr.idcrp = Crp.idcrp
    And Fonction1(crp.col1,sal.refstr,crpstr.refstr) = 1
)