Message-ID: From: "SuperPat45 (@SuperPat45)" To: "pgjdbc/pgjdbc" Date: Tue, 21 Mar 2023 15:48:48 +0000 Subject: [pgjdbc/pgjdbc] issue #2861: setFetchSize is ignored? List-Id: X-GitHub-Author-Id: 7791600 X-GitHub-Author-Login: SuperPat45 X-GitHub-Issue: 2861 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: open X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/2861 Content-Type: text/plain; charset=utf-8 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