• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Statement.setMaxRows

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a few doubts.
I have some sql queries which fetch a lot of data from a oracle DB.
I wish to use the statement object's setMaxRows() method to restrict
the number of records fetched.
I wish to know the following.
If the query fetches more than say 200 records set through the
setMaxRows method,will the truncation of the excess records happen
at the database server or the java application/app server ???
Also,will the query fetch more than the no of records set ???
(of course the query fetches more than 200 records in oracle )
Pls reply to this asap.
Thanks in advance.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All thats doing is (potentially) reducing the size of the ResultSet object. It won't affect the speed of the query. setMaxRows doesn't change the actual SQL - using top/limit/rownum e.g. - so it doesn't change the work the DB does. The query will return more results than your limit if there are more results to return, then truncate them to fit your ResultSet. This is also how top/limit/rownum work anyway.
 
N Naveen
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.
Where does the truncation happen ?
Does it happen at the Application/App Server
or at the database server ?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its of the ResultSet object. So it its done in your Java application.
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was just curious...
Why doesn't it happen at the database level....
ie what does ResultSet stand to gain by fetching all the records and then truncating to maxRows, isn't it better that it changes the sql and modifies its rownum and gets only those number of records which are fetched...
 
reply
    Bookmark Topic Watch Topic
  • New Topic