I have a Java ResultSet
which contains a big data amount (but still may be stored in RAM), retrieved from the database. I'm going to work with this data. From the performance point of view, should I copy result set content to some data structure in order to be able to close the result set as soon as possible and to work with the data from a new container or it's better to do not waste a time on copy the content and work with the data directly from the result set?
ResultSet's fetch a specified number of rows at a time, dependent on the JDBC driver and database being used. So if your query has a million rows returned, not all million are resident in memory, unless you iterate over the ResultSet and put them in memory of course. To answer your question directly, you close the ResultSet when you are finished reading the rows you need, usually when the ResultSet.next() returns false.