加速大数据集休眠查询的数据库设计

发布于 2024-08-30 20:31:16 字数 3427 浏览 6 评论 0原文

我目前有下表代表在休眠中映射的公交网络,可从基于 Spring MVC 的公交路线规划器访问 我试图让我的路线规划器应用程序执行得更快,我将上述所有表格加载到列表中以执行路线规划器逻辑。

如果有人对如何提高我的表现有任何想法,我将不胜感激 或者有任何其他方法来解决处理大量数据的问题

    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  

这是从每个表加载所有数据所需的时间:

    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 到坐标代码

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);
    }
}

I currently have the below tables representing a bus network mapped in hibernate, accessed from a Spring MVC based bus route planner
I'm trying to make my route planner application perform faster, I load all the above tables into Lists to perform the route planner logic.

I would appreciate if anyone has any ideas of how to speed my performace
Or any suggestions of another method to approach this problem of handling a large set of data

    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  

This is how long it takes to load all the data from each 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 to 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);
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

纵情客 2024-09-06 20:31:16

看看如何使用 mysql 中的解释命令,让您了解最好将索引放在哪里。

下面的链接很好地解释了这一点。

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

Take a look at using the explain command in mysql to give you some idea of where it would be best to put indexes.

The link below explains it quite well.

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

南风几经秋 2024-09-06 20:31:16

使用 Hibernate 实现 EhCache 帮助我提高了性能

Implementing EhCache with Hibernate helped me improve the performance

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文