使用JDBC for Oracle迭代ResultSet需要花费大量时间大约16秒? [英] Iterating a ResultSet using the JDBC for Oracle takes a lot of time about 16s?
问题描述
while( result_set.next() )
{
...
}
我使用 System.nanoTime()
并计算时间,每次迭代所用的时间是毫秒,但整个循环大约需要16秒。我正在考虑条件测试花费大量时间的可能原因, next()
函数。
I have use System.nanoTime()
and calculated the time, for each iteration the time taken is in milliseconds but the overall loop takes about 16s. I am considering a possible reason that the condition test is taking a lot of time, the next()
function.
仅供参考我正在连接到远程数据库服务器,并且我使用上述方法再次计算完成的选择查询(以毫秒为单位)。
有关为什么会发生这种情况以及如何将结果集迭代到最多秒的任何理由?
FYI I am connecting to a remote database server and the select query that I make is completed in milliseconds again calculated using the above mentioned method. Any reasons about why it's happening and how I can bring the time to iterate the resultset down to at max a second?
编辑:
我正在处理大约4000条记录,每条记录包含大约10列,每列大小约为10个字符
I am dealing with about 4000 records and each record contians about 10 columns each having a size of about 10 chars
EDIT2
感谢setFetchsize()做了神奇,棒极了,真棒
EDIT2 Thanks setFetchsize() did the magic, awesome, awesome
推荐答案
尝试更改ResultSet提取大小。默认情况下,Oracle JDBC驱动程序一次只从数据库游标接收结果集10行。它可能不会显着提高性能,但还有许多其他选项可以让驱动程序更快地运行。
Try to change ResultSet fetch size. By default, Oracle JDBC driver receives the result set only 10 rows at a time from the database cursor. It may not significantly improve performance but there arent many other options to make driver work faster.
这篇关于使用JDBC for Oracle迭代ResultSet需要花费大量时间大约16秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!