Question

J'ai actuellement les tableaux ci-dessous représentant un réseau de bus cartographié en veille prolongée, accessible à partir d'un planificateur d'itinéraire de bus en fonction Spring MVC Je suis en train de faire ma demande de planificateur d'itinéraire effectuer plus rapidement, je charge tous les tableaux ci-dessus dans des listes pour effectuer la logique du planificateur d'itinéraire.

J'apprécierait si quelqu'un a des idées sur la façon d'accélérer mon performace Ou des suggestions d'une autre méthode pour aborder ce problème de la manipulation d'un grand ensemble de données

    Coordinate Connections Table (INT,INT,INT)( Containing 50,000 Coordinate Connections)
    ID, FROMCOORDID, TOCOORDID
    1   1               2       
    2   1               17      
    3   1               63      
    4   1               64      
    5   1               65      
    6   1               95      

    Coordinate Table (INT,DECIMAL, DECIMAL) (Containing 4700 Coordinates)
    ID ,  LAT,       LNG
    0   59.352669   -7.264341
    1   59.352669   -7.264341
    2   59.350012   -7.260653
    3   59.337585   -7.189798
    4   59.339221   -7.193582
    5   59.341408   -7.205888

    Bus Stop Table (INT, INT, INT)(Containing 15000 Stops)
    StopID    RouteID COORDINATEID
    1000100001  100     17  
    1000100002  100     18  
    1000100003  100     19  
    1000100004  100     20  
    1000100005  100     21  
    1000100006  100     22  
    1000100007  100     23  

Ceci est le temps qu'il faut pour charger toutes les données de chaque table:

    stop.findAll  = 148ms,  stops.size: 15670
    Hibernate: select coordinate0_.COORDINATEID as COORDINA1_2_, coordinate0_.LAT as LAT2_, coordinate0_.LNG as LNG2_ from COORDINATES coordinate0_
    coord.findAll =  51ms , coordinates.size: 4704
    Hibernate: select coordconne0_.COORDCONNECTIONID as COORDCON1_3_, coordconne0_.DISTANCE as DISTANCE3_, coordconne0_.FROMCOORDID as FROMCOOR3_3_, coordconne0_.TOCOORDID as TOCOORDID3_ from COORDCONNECTIONS coordconne0_
    coordinateConnectionDao.findAll  = 238ms ; coordConnectioninates.size:48132

Hibernate Annotations

    @Entity
    @Table(name = "STOPS")
    public class Stop implements Serializable {

        @Id
        @GeneratedValue
        @Column(name = "COORDINATEID")
        private Integer CoordinateID;


        @Column(name = "LAT")
        private double latitude;


        @Column(name = "LNG")
        private double longitude;

    }




    @Table(name = "COORDINATES")
    public class Coordinate {

        @Id
        @GeneratedValue
        @Column(name = "COORDINATEID")
        private Integer CoordinateID;


        @Column(name = "LAT")
        private double latitude;


        @Column(name = "LNG")
        private double longitude;
    }

    @Entity
    @Table(name = "COORDCONNECTIONS")
    public class CoordConnection {

        @Id
        @GeneratedValue
        @Column(name = "COORDCONNECTIONID")
        private Integer CoordinateID;

        /**
         * From Coordinate_id value
         */
        @Column(name = "FROMCOORDID", nullable = false)
        private int fromCoordID;

        /**
         * To Coordinate_id value
         */
        @Column(name = "TOCOORDID", nullable = false)
        private int toCoordID;
        //private Coordinate toCoordID;
    }

HashMap -> CoodinateID à Coordinate code

private void setupCoordinateIDToCoordinate() {
    HashMap<Integer, Coordinate> coordinateIDToCoordinate = new HashMap<Integer, Coordinate>();
    List<Coordinate> coordinates = coordinateDao.findAll();
    Iterator <Coordinate> itr = coordinates.iterator();
    Coordinate c;
    while(itr.hasNext()) {
        c = itr.next();
        coordinateIDToCoordinate.put(c.getCoordinateID(),c);
    }
}
Était-ce utile?

La solution 2

Mise en œuvre ehcache avec Hibernate m'a aidé à améliorer la performance

Autres conseils

Jetez un oeil à l'aide de la commande expliquer dans une base MySQL pour vous donner une idée de l'endroit où il serait préférable de mettre les index.

Le lien ci-dessous explique très bien.

http://forums.spry.com/howtos /1345-using-mysqls-explain-command.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top