This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
My result set is a huge list. And I want to reduce the data transfered between the Oracle database and my application. If I only retrieve the first few rows from the result set, and then just close the result set. Does all the data rows from the result set already transfered from Oracle to my application regardless that I didn't read these result set? Or is it the other way around, that only the data rows that I read, has actually transfered from Oracle to my application? And does the Oracle database server already generate the full result set in its' memory before I read a single row of result set? Thanks. Liang
For non-scrollable, Oracle will fetch into memory the number of records specified in the fetch size parameter. Once you need more records, the old records are discarded and the number of new records specified by the fetch size are loaded into memory. In general, A higher fetch size means more memory usage, but less calls to the database and vice versa. So at any time, with the ResultSet open or closed, the maximum number of records in memory is the number specified in the fetch size. BEWARE!! Scrollable resultsets work a little differently. They generally work the same as non-scrollable except when you need more records, the old records are NOT discarded and the number of new records specified by the fetch size are loaded into memory. So at any time, with the ResultSet open, the maximum number of records in memory is the number of records you have iterated through rounded up to a multiple of the fetch size. Not exactly sure what happens on Oracle, but I'm pretty sure they just have pointers ( in the general sense ) to the matched rows, the current one being the cursor. Jamie [ November 29, 2002: Message edited by: Jamie Robertson ]