JDBC的抓取大小在来自Oracle文档的流类型时重置为1。

huangapple go评论64阅读模式
英文:

JDBC fetch size resets to 1 for streaming types from oracle documentation

问题

从Oracle JDBC文档(https://docs.oracle.com/cd/E11882_01/java.112/e16548/oraperf.htm#JJDBC28782)

> 如果结果集的列属于数据类型LONG、LONG RAW或通过数据接口返回的LOB,即流式类型,则无论您是否实际读取了这些类型中的任何一个的值,JDBC都会将语句的行预提取设置更改为1

如果未为结果集提供获取大小,则默认与语句获取大小相等。

如果我的结果集包含流式类型,那么在下一次访问数据库时,结果集的获取大小是否也会重置?如果是,如何保持结果集大小?

我在一些项目中使用spring-jdbc,Spring会处理这个吗?

英文:

From Oracle JDBC documentation (https://docs.oracle.com/cd/E11882_01/java.112/e16548/oraperf.htm#JJDBC28782)

> If a column of a result set is of data type LONG, LONG RAW or LOBs returned through the data interface, that is, the streaming types, then JDBC changes the statement row-prefetch setting to 1, even if you never actually read a value of either of these types.

If fetch size is not provided for the ResultSet by default equal to the statement fetch size.

if my ResultSet contains the streaming types, does the result set fetch size also reset in the next trip to DB? If yes how can we keep the result set size?

I am using spring-jdbc in few projects does spring handles this?

答案1

得分: 1

如果你检索的列中有一个是 LONG 或 LONG_RAW 类型的,那么无论你使用什么样的获取大小(fetch size),驱动程序都会逐行获取行。如果你想知道,“通过数据接口返回的LOB”是指你使用 defineColumnType 将其定义为 LONG 的 LOB。有一个连接属性叫做 “useFetchSizeWithLongColumn”,如果设置为 “true”,将会改变这种行为,但请记住,LONG 或 LONG_RAW 类型的数据可能大于 1GB,所以如果你获取了 10 个这样的数据,驱动程序将会消耗大量内存。

英文:

If one of the columns you're fetching is a LONG or LONG_RAW then yes the driver will fetch the rows one by one no matter what fetch size you use. In case you're wondering, a "LOB returned through the data interface" is a LOB that you define as a LONG using defineColumnType. There is a connection property called "useFetchSizeWithLongColumn" which, if set to "true", will change this behavior but keep in mind that a LONG or LONG_RAW can be larger than a gigabyte so if you fetch 10 of them you're going to consume a lot of memory in the driver.

huangapple
  • 本文由 发表于 2020年10月22日 02:18:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/64469473.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定