我目前有下表代表總線網絡映射在休眠,訪問從基於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註解
@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);
}
}
你有相關的指標? 你使用了哪個數據庫? – Damo 2010-04-29 00:59:59
我正在使用一個MySQL數據庫,我不確定你的意思是相關的索引?我已經對上面的代碼做了一些小的更改,包括使用散列表來快速訪問CoordinateID的座標 – patrickandroid 2010-04-29 01:47:47