N
N
nuclear_kote2018-04-13 15:33:20
Java
nuclear_kote, 2018-04-13 15:33:20

Will jvm die or not without pagination?

PreparedStatement ps = db.preparedStatement("select * from tbl");
ResultSet rs = ps.executeQuery();
while(rs.next) {
 ...
    process(...);
...
}

will jvm die if there are over 1,000,000,000 lines in tbl? Or does it subtract line by line from the base?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
forspamonly2, 2018-04-13
@nuclear_kote

zhdbts-shnye rezaltsets read records by the cursor line by line. if you don't store what you get in memory inside your process, then the fetch size can be arbitrarily large.

S
Sergey Gornostaev, 2018-04-13
@sergey-gornostaev

It depends on what you have in the lines, what resources the host has, what garbage collector is used, how the JVM is configured, etc. etc. There are Java programs that work with terabyte heaps.

R
Ruslan Masgutov, 2018-04-14
@nectar92

It all depends on the specific situation (which database, the driver used, the amount of data).
The last time I processed a large table, I initialized statement like this:

PreparedStatement preparedStatement = connection.prepareStatement(query,
                ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        preparedStatement.setFetchSize(fetchSize);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question