Java – resulset – cursor: rs.next() takes a lot of time

The cursor I returned from the database executes in 31 MS (milliseconds)

But when I use this cursor to get more than 1500 lines

ResultSet rs = (ResultSet)cstm.getObject(6);

  while(rs.next()){
     system.out.println("...");
  }

Simply traverse each line of cursor, taking more than 40 seconds (40000 MS)

What can I do

Thank you in advance

Solution

In fact, by default, JDBC uses a value size of 10 Therefore, if you do not set a larger value, you can call the database for the next record, exactly 150 times

All you need to do is test the performance by setting fetchsize to 100, for example:

statement.setFetchSize(100);

You can use this number to improve performance according to your environment

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>