pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: SuperPat45 (@SuperPat45) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #2861: setFetchSize is ignored?
Date: Tue, 21 Mar 2023 15:48:48 +0000
Message-ID: <[email protected]> (raw)
Please read https://stackoverflow.com/help/minimal-reproducible-example
**Describe the issue**
Due to a bug, I have a query that returned 1 million rows instead of 10000....
I specified that I wanted the database to return only 100 rows at a time.
I noticed that the memory was full before the executeQuery() function returned the ResultSet...
Looking with JVisualVM I saw hundreds of thousands instances of the org.postgresql.core.Tuple class
So, It seem that all rows are fetched ignoring the fetchSize limit.
**Driver Version?**
42.5.0
**Java Version?**
17.0.4
**OS Version?**
Windows 10
**PostgreSQL Version?**
14.5
**To Reproduce**
```
Statement statement = connection.createStatement();
statement.setFetchSize(100);
ResultSet resultSet = statement.executeQuery("select * from one_million_row_table");
System.out.println("OK");
```
**Expected behaviour**
The result set should have been returned by the executeQuery() function without exploding the memory as I specified to only fetch 100 rows at a time.
I use the result set to write data in a text file so, in this case, the memory should never have been filled completely.
**Logs**
java.lang.OutOfMemoryError: Java heap space
view thread (10+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] issue #2861: setFetchSize is ignored?
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox