Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Not a Bug
-
2.2.1
-
None
Description
I am using the following
- AWS Aurora MySQL 5.6
- mariadb-java-client 2.2.1
- springframework 4.3.16
I am currently using fetchsize of 1000 in JdbcTemplate. For large size tables, when using select queries, I am experiencing OOM. I could confirm that Spring is able to propagate the fetchSize to the driver.
When I started debugging, I found the following observation in SelectResultSet in the driver code. When fetchSize > 0, the execution flow proceeds like
- nextStreamingValue
- addStreamingValue
- readNextValue
- growDataArray
So essentially, SelectResultSet data variable keeps growing when next is called on the ResultSet. So OOM is ought to happen eventually. BTW, I am using the default TYPE_FORWARD_ONLY scroll type.
Could anyone confirm if my understanding is correct? Is there a way to query large datasets without OOM?
Attachments
Issue Links
- relates to
-
CONJ-276 java.lang.OutOfMemoryError: Java heap space
-
- Closed
-
>So essentially, SelectResultSet data variable keeps growing when next is called on the ResultSet. So OOM is ought to happen eventually
This is right, until data size reach fetchsize limit.
Using a fetch size of 1000 means having a maximum of 1000 rows in memory at a time.
If rows are huge, this can cause OOM. Then better set fetchsize to a lower value.
could you send query and associate DDL to check row size ?
To explain by code :
rows are stored in an array (variable is `data`) with an initial size of 10, but this array will grow to reach fetchsize if > 10.
but data maximum size will be limited to fetchsize.