Hibernating giant optimization queries

I just received an instruction for the application, the purpose of which is to extract a large amount of data (up to 100,000 rows from a table containing 10,000,000 rows). Unfortunately, the extraction is written in Java + Hibernate, and the performance is relatively small. Retrieving 100,000 rows using Java + Hibernate takes approximately 1 minute and 30 seconds. The same extraction using Talend takes about 30 seconds (3 times less).

Here is an example of what the code looks like:

Launcher.initStatelessSession();
Launcher.beginStatelessTransaction();

//Creation of the Criteria crit, no join, only a single table is read.
int fetchSize = 1000;
crit.setFetchSize(fetchSize);
crit.setCacheable(false);
crit.setReadOnly(true);

ScrollableResults result = crit.scroll(ScrollMode.FORWARD_ONLY);
// Most of the time is spent from HERE ...
while (result.next()) {
   // Some code but insignificant time compared to the result.next().
   // I replaced this code with continue; and the speed did not really change.
}
// ... to HERE

Any optimization idea that could speed up this query? There is currently no plan to abandon Hibernate for anything else.

+3
source share
1 answer

, , , - gui ?

, , , , , , (, ).

, ,

, sql. , select.

0

All Articles