开发者

Read a large result set in chunks from mysql

开发者 https://www.devze.com 2022-12-16 03:57 出处:网络
I am trying to read a huge result set from mysql. Reading them in a straight-forward manner didn\'t work, as mysql tries to return all results together, which times out.

I am trying to read a huge result set from mysql. Reading them in a straight-forward manner didn't work, as mysql tries to return all results together, which times out.

I found the following piece of code which tells mysql to read the results back one at a time:

stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.Re开发者_开发百科sultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);

Can I read a chunk at a time instead of one by one? I've tried setting fetch size to a different value, but it doesn't work.


In your query use pagination by setting limit and offset.

0

精彩评论

暂无评论...
验证码 换一张
取 消