我有一个如下代码,
try (Connection connection = this.getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement(sqlQuery);) {
try {
statement.setFetchSize(10000); // Set fetch size
resultSet = statement.executeQuery();
while (true) {
resultSet.setFetchSize(10000);
boolean more = resultSet.next();
if (! more) {
break;
}
// populating an arraylist from the value from resultSet
}
}
catch (Exception e) {
LOGGER.error("Exception : "+e);
}
} catch (SQLException e) {
LOGGER.error("Exception : "+e);
}
Run Code Online (Sandbox Code Playgroud)
我的理解如下,
语句提取大小为10000.当执行statement.executeQuery()时,它返回ResultSet游标.它将在内存中有10000行.当调用resultSet.next时,它从内存缓冲区中获取一行.(每次通话一排).当内存中没有更多行时,将再次触发查询,并再次从数据库中提取10000行并将其存储在缓冲区中.这将继续,直到没有要从DB获取的行
因此,如果我的理解是正确的,那么总行数为210000的实际数据库调用数量是多少?是21岁吗?(210000/10000)
当调用DB时(当缓冲区中的行都被读取时)获取更多行(在我的情况下为10000)并存储在缓冲区中.缓冲区什么时候清除?
如果我的理解错了,请纠正我.
我需要在Oracle数据库中处理数百万个数据.
感谢任何指针/信息
问候,
SD
任何人都可以建议一个测试GWT UI的好工具.关于使用Selenium和Webdriver有什么看法?欢迎提出任何建议和建议.
谢谢,SD