Using the JdbcTemplate queryForList method, the return is particularly slow, and the more than 400,000 result set takes more than 6 minutes. Dual-core CPU, the occupancy rate is always at 50%, the memory gradually increases to about 2G.
Debug follow up to see, see JdbcTemplate call JDBC returned resultset only 30 seconds or so, and then have been consumed in the Extractdata method. The method is to use the default RowMapper, first get metadata and then based on this to generate map.
Comparison method:
1. Using pure JDBC contrast, manual code codes, directly call map put method to generate map and populate data. The same SQL, which takes more than 40 seconds, the last memory 2G, which generates list<map<string according to ResultSet, object>> process does not exceed 10s.
2. Use JdbcTemplate's public <T> list<t> query (String sql, Rowmapper<t> RowMapper) method, T fill in map<string, Object>, this is the same as the queryForList method return value, and then implement the rowmapper yourself, and directly populate the data with the map's put method. The experimental results are the same as that of pure JDBC directly.
3. Using pure JDBC, write an entity class yourself and put the data in the ResultSet into the list by filling in the object. It takes more than 40 seconds and the last memory is 1.5G. The explanation still saves a bit of memory. But performance gains are limited.
Conclusion:
At present, it is advisable to use the public <T> list<t> query (String sql, rowmapper<t> RowMapper) method instead of the Qeuryforlist method when the result set is large. This will improve efficiency.
Future estimates of JdbcTemplate's queryforlist efficiency will also rise to similar levels.
A performance issue that is encountered with spring JDBC