Oracle Database JDBC driver, versions prior to 12:
The driver allocates the maximum size for each column times the number of rows in the fetchSize
prior to executing the query.
For example for a VARCHAR(4000)
column it will allocate 8k bytes times the fetchSize
.
versions 12 (and later):
It allocates approximately 15 bytes per column per row in the fetchSize
prior to executing the query. After execution, the driver in version 12 allocates only as much as needed to store the actual row data.
As a result, version 12 drivers typically use substantially less memory than the earlier versions' drivers.
Your example:
In your example a VARCHAR(20)
can be as big as 40 bytes, a NUMBER
can be as big as 22 bytes and a VARCHAR(100)
as big as 100 bytes. With the fetchSize
set to 100 the older drivers would allocate (40 + 22 + 100) * 100 = 16k
. The version 12 driver would allocate 3 * 15 * 100 = 4.5k
. There is additional overhead in both drivers that I am ignoring.