Bonjour,
j'ai un soucis de perf avec un Select que je n'arrive pas à solutionner :
Ce 1er script tourne bien (env 7 secondes) :
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
Select 
        Distinct
        D.DistrictName as "District"
        , D.District_i as "No District"
        , T.Township   as "Commune"
        , T.Township_i as "No Commune"
        , PC.PopulationCount as "Pop Totale Commune"
        , Count(P0.Requester_i) over (partition by T.Township_i) as "Nb RA Commune"
From 
        Township        T
        , District      D
        , TownshipPopulationCount   PC
        , (
            Select
                    Requester_i
                    , ActualLodge_i
                    , SocialCategoryLabel
                    , Utility.FGetTownshipIDFromLodge(ActualLodge_i) as Township_i
            From
                    PopulationDetail   
          )             P0
Where
                T.District_i = D.District_i
        And     T.Township_i = PC.Township_i
        And     PC.Township_i = P0.Township_i (+)
Order by D.District_i, T.Township_i
Celui-ci également (env 2 secondes) :
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
Select 
        Distinct
        D.DistrictName as "District"
        , D.District_i as "No District"
        , T.Township   as "Commune"
        , T.Township_i as "No Commune"
        , PC.PopulationCount as "Pop Totale Commune"
        , Count(P1.Requester_i) over (partition by T.Township_i) as "Nb RA Commune"
From 
        Township        T
        , District      D
        , TownshipPopulationCount   PC
        , (
            Select
                    Requester_i
                    , ActualLodge_i
                    , SocialCategoryLabel
                    , Utility.FGetTownshipIDFromLodge(ActualLodge_i) as Township_i
            From
                    PopulationDetail 
            Where   SocialCategoryLabel = 'AUTONOME'  
          )             P1
Where
                T.District_i = D.District_i
        And     T.Township_i = PC.Township_i
        And     PC.Township_i = P1.Township_i (+)
Order by D.District_i, T.Township_i
La différence entre les 2 est seulement l'ajout d'une clause where dans le inline-view.

maintenant, lorsque j'aimerais LES DEUX résultats dans deux colonne séparées, je regroupe les deux scripts comme ceci :
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
32
33
34
35
36
37
38
Select 
        Distinct
        D.DistrictName as "District"
        , D.District_i as "No District"
        , T.Township   as "Commune"
        , T.Township_i as "No Commune"
        , PC.PopulationCount as "Pop Totale Commune"
        , Count(P0.Requester_i) over (partition by T.Township_i) as "Nb RA Commune"
        , Count(P1.Requester_i) over (partition by T.Township_i) as "Nb RA Autonomes"
From 
        Township        T
        , District      D
        , TownshipPopulationCount   PC
        , (
            Select
                    Requester_i
                    , ActualLodge_i
                    , SocialCategoryLabel
                    , Utility.FGetTownshipIDFromLodge(ActualLodge_i) as Township_i
            From
                    PopulationDetail   
          )             P0
        , (
            Select
                    Requester_i
                    , ActualLodge_i
                    , SocialCategoryLabel
                    , Utility.FGetTownshipIDFromLodge(ActualLodge_i) as Township_i
            From
                    PopulationDetail  
            Where   SocialCategoryLabel = 'AUTONOME' 
          )             P1
Where
                T.District_i = D.District_i
        And     T.Township_i = PC.Township_i
        And     PC.Township_i = P0.Township_i (+)
        And     PC.Township_i = P1.Township_i (+)
Order by D.District_i, T.Township_i
et là le Select tourne plus de 20 minutes sans me donner de résultat (je flingue le process au bout de 20 minutes)...
Est-ce que quelqu'un vois un soucis qui m'aurais échappé ?

Pour info, la base tourne sous Oracle 9.2.0.6 sous Solaris, client 9.2.0.7 sous XP Pro, script exécuté avec TOAD, même soucis sous SQLPlus...

merci d'avance pour toutes vos suggestions !