IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JDBC Java Discussion :

plan d'execution oracle sur java


Sujet :

JDBC Java

  1. #1
    Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mai 2019
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2019
    Messages : 5
    Points : 4
    Points
    4
    Par défaut plan d'execution oracle sur java
    Bonjour,

    Je souhaite afficher le MVPP (Multiple View Processing Plan) : Le MVPP est une représentation de la charge de requête avec la fusion de leur arbre d’exécution, est souvent utilisé pour des raisons de recherche et d’optimisation.
    Mais ça marche pas avec moi.

    Voici mon code :
    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
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    // pour le traitement de noeuds:
     
    import java.sql.*;
    import java.util.Arrays;
    import java.util.Objects;
     
     
     
    class traitementNoeuds {
     
     
     
        // on met les requêtes dans un tableau
      public static  String[] mesReq= {"SELECT sum(lo_extendedprice*lo_discount) as revenue from lineorder,"
                    + " dates where lo_orderdate = d_datekey and d_year = 1997 and lo_discount "
                    + "between 1 and 3 and lo_quantity < 24",
             "select sum(lo_revenue), d_year, p_name from lineorder, dates, part, supplier"
                + " where lo_orderdate = d_datekey and lo_partkey = p_partkey and lo_suppkey = s_suppkey "
                + "and p_category = 'MFGR#12' and s_region = 'ASIA' group by d_year, p_name order by d_year, p_name",
             "select c_city, s_city, d_year, sum(lo_revenue) as revenue  "
                + "from customer, lineorder, supplier, dates where lo_custkey = c_custkey "
                + "and lo_suppkey = s_suppkey and lo_orderdate = d_datekey and (c_city='UNITED KI1' "
                + "or c_city='UNITED KI5') and (s_city='UNITED KI1' or s_city='UNITED KI5') "
                + "and d_yearmonth = 'Dec1997' group by c_city, s_city, d_year order by d_year asc, revenue desc ",
             "select c_city, s_city, d_year, sum(lo_revenue) as revenue "
                 + "from customer, lineorder, supplier, dates where lo_custkey = c_custkey and lo_suppkey = s_suppkey "
                 + "and lo_orderdate = d_datekey and c_nation = ’UNITED STATES’ and s_nation = ’UNITED STATES' "
                 + "and d_year >= 1992 and d_year <= 1995 "
                 + "group by c_city, s_city, d_year order by d_year asc, revenue desc"};
     
     
    //pour les requetes:
     
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Statement;
     
     
    class Requete {
     
     
     
     
     
     
     
          private String sqlReq ;
          private static String[] ensembleAtt=new String []{"ID","Depth","PARENT_ID","Operation",
              "Statement_ID","Cost","Bytes","Cardinality","CPU_Cost","IO_Cost","Object_Name",
              "Object_alias","ACCESS_PREDICATES"}; 
         private final String[][] planExe , tablesKey;
     
     
     
        public Requete(String sqlReq) throws SQLException {
            this.sqlReq = sqlReq;
            planExe=recupInfoExecution();
            tablesKey = generateTablesKey();
     
        }
        public static String[] getEnsAtt() {
            return ensembleAtt ;
        }
     
     
        public static String attributs (){
        String s ;
        if(ensembleAtt.length==0) return null;
        s=ensembleAtt[0];
            for (int i = 1; i < ensembleAtt.length; i++) {
                s+=","+ensembleAtt[i];
            }
        return s ;
        }
     
        public static int getColumnId(String column){
            int n=ensembleAtt.length;
            for (int i = 0; i <n; i++) {
                if(ensembleAtt[i].equalsIgnoreCase(column)) return i ;
            }
     
        return -1 ;
        }
     
        public String[][] getPlanExe() {
            return planExe;
        }
     
        public String getSqlReq() {
            return sqlReq;
        }
     
     
        public void setSqlReq(String sqlReq) {
            this.sqlReq = sqlReq;
        }
     
        public int countTables()
        {   int nbr=0;
                for (int i = 0; i < planExe.length; i++) {
                if(planExe[i][getColumnId("Operation")].equalsIgnoreCase("TABLE ACCESS")) nbr++ ;
            }
            return nbr; 
        }
     
     
     private String[][] recupInfoExecution() throws SQLException
    {
        ResultSetMetaData resultMeta;
        ResultSet monResultat;//=(ResultSet) resultaReq();
        Statement statement ;
        Connection maConnexion =ConnexionDataBase.getConnection();
        statement = maConnexion.createStatement();
        statement.executeUpdate("explain plan for "+sqlReq); 
        monResultat = statement.executeQuery("select count(*) from PLAN_TABLE");
        monResultat.next();
        int nbrLignes = monResultat.getInt(1);
        monResultat = statement.executeQuery("select "+attributs()+" from PLAN_TABLE");
         //On recupere les MetaData
        resultMeta = monResultat.getMetaData();
         //On affiche le nom des colonnes
        int nbrCol=resultMeta.getColumnCount() ;
        String[][] infoReq = new String[nbrLignes][nbrCol];
     
        int ligne =0 ;
        System.out.println("nbr lignes"+nbrLignes+" nbr col "+nbrCol);
        while (monResultat.next()) {
                for(int i = 1; i <=  nbrCol; i++)
                {
                    infoReq [ligne][i-1]=  monResultat.getString(i);
     
                    System.out.print( monResultat.getString(i)+"\t |");}
                    System.out.println("");
                    ligne ++ ;
                }
     
        monResultat.close();
        statement.close();
        return infoReq;
    }  
     
        private String[][] generateTablesKey() throws SQLException
    {      String[][] matRec=new String[countTables()][3];
        int nbTable= countTables();
        /* 0 :  "ID"    1 : "TableName"     2 : "Alias" */ 
        int tableName = getColumnId("Object_Name");
        int alias =getColumnId("Object_Alias");
        System.out.println("Table : "+tableName+"\n Alias :"+alias);
        int k =0;
        for(int i=0;i<planExe.length; i++)
        {   
            if(planExe[i][getColumnId("Operation")].equalsIgnoreCase("TABLE ACCESS")){ // id = j
                matRec[k][0]= Integer.toString(i); 
                matRec[k][1]=planExe[i][tableName];
                matRec[k][2]=planExe[i][alias].split("@")[0] ;
                k++;
            }
        }
        return matRec;
    }  
    }

  2. #2
    Membre régulier Avatar de openlowcode
    Homme Profil pro
    Développeur Java
    Inscrit en
    Juin 2019
    Messages
    40
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2019
    Messages : 40
    Points : 94
    Points
    94
    Par défaut
    Bonjour,

    pour en dire plus, il faudrait connaître l'erreur. Il faut aussi exécuter strictement la procédure explain plan d'oracle, y compris dans certains cas créer la table provisoire qui stocke le résultat de l'explain plan.

    La notice de l'explain plan est ici (site Oracle)
    Open Lowcode Applications sur mesure, résultats rapides et à coûts réduits (repo Github)

Discussions similaires

  1. plan d'execution oracle
    Par miloon dans le forum Administration
    Réponses: 3
    Dernier message: 24/03/2009, 10h19
  2. plan d'execution oracle
    Par miloon dans le forum Administration
    Réponses: 4
    Dernier message: 03/03/2009, 08h40
  3. plan d'execution oracle via visual c++
    Par miloon dans le forum Oracle
    Réponses: 0
    Dernier message: 24/02/2009, 13h30
  4. Réponses: 2
    Dernier message: 15/02/2008, 12h19
  5. [Oracle 10.2] Plan d'execution fonction PL/SQL
    Par pegase06 dans le forum PL/SQL
    Réponses: 6
    Dernier message: 13/02/2007, 12h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo