• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

query regarding getFetchSize

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On ne of the websites - it is written to improve performance one should set the "fetchSize" of the prepared statement and ResultSet.

1 >Lets say if I set a fetch size of 10 and my query returns 20 records - are all records held in memory or only 10 are in memory and when I iterate to the 11th record - then the remaining are fetched from database ?

Regards,
-anagha
 
author & internet detective
Posts: 39341
755
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anagha,
That would result in two trips to the database. Sometimes tuning the fetch size is advisable as it results in less network trips.
 
Jeanne Boyarsky
author & internet detective
Posts: 39341
755
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgot to mention: I would advise against making the fetch size smaller than the default.
 
anagha patankar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne for your replies .

So when you say there will be two trips to the database :
1 >Where is the resultset stored - is that stored in SGA ( In case of Oracle )
2 >If we are using a resultset - then believe all the data is anyway on the server side ( not like disconnected rowset )

So are you saying that after query execution ( results obtained = 20 rows & fetchSize = 10 ) that 20 rows will be stored in SGA

So where are the first 10 records read / picked from

What happens when we access the 11th record ?

Too many questions and too much confusion at my end .

Any answers will be greatly appreciated .

Regards,
-anagha
 
Jeanne Boyarsky
author & internet detective
Posts: 39341
755
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about what is stored in SGA. That is within Oracle, so I don't need to think about it as an app developer.

> If we are using a resultset - then believe all the data is anyway on the
> server side ( not like disconnected rowset )
It's on the client side too. When you call rs.next(), the data is transfered to the client side. We wouldn't want this to happen on every call to rs.next() so fetch size tells the driver how often to go to the server to get more data.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!