i have db fetch call spring jdbctemplate
, rows fetched around 1 millions. takes time iterating in result set. after debugging behavior found process rows batch , waits time , again takes batch of rows , process them. seems row processing not continuous overall time going minutes. have used default configuration data source. please help.
[edit]
here sample code
this.prestojdbctempate.query(query, new rowmapper<someobject>() { @override public someobject maprow(final resultset rs, final int rownum) throws sqlexception { system.out.println(rownum); someobject obj = new someobject(); obj.setprop1(rs.getstring(1)); obj.setprop2(rs.getstring(2)); .... obj.setprop8(rs.getstring(8)); return obj; } });
as of comments tell you, 1 mllion records useless , unrealistic shown in ui - if real business requirement, need educate customer.
network traffic application , database server key factor in performance in scenarios this. there 1 optional parameter can in scenario : fetch size - extent
example :
connection connection = //get connection statement statement = connection.createstatement(); statement.setfetchsize(1000); // configure fetch size
most of jdbc database drivers have low fetch size default , tuning can in situation. **but beware ** of following.
- make sure jdbc driver supports fetch size
- make sure jvm heap setting ( -xmx) wide enough handle objects created result of this.
- finally, select columns need reduce network overhead.
in spring, jdbctemplate
lets set fetchsize
Comments
Post a Comment