• 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

SESSION vs Database trip

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an application where I have to list 30 records per JSP page. There can be any number of records in the database.
Which of the methods is faster and consumes less resources?
-use session object to store all the records and the display them on the pages (30 at a time)
-go to the database for each page and get all records and display 30 per page
Any reply will be appreciated.
Thanks
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
It is usually a compromise between a "faster" RESPONSE and "lesser" storage (read memory). You will not be able to have both of them at the same time.
Going to your question, it is better to go for Method 2) which reads the records off the database for every page since you do not know about the number of records in the database. This carries an overhead of a database access for every page access. But, you can work with limited memory (30 records)
Or you could read more than 30 records (say 5 * 30) and store them in the session object. Thus, you will be able to show 5 pages without a db access. Again, that number depends on your application and it's needs.
Hope this helps.
Ashwin.

 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a topic which has been discussed here many times, so it may well be worth a few searches on past messages. You should find some quite detailed discussions and code samples both here and in the JDBC forum.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Frank Carver:
This is a topic which has been discussed here many times, so it may well be worth a few searches on past messages. You should find some quite detailed discussions and code samples both here and in the JDBC forum.


 
Revati Pathak
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check this out:
http://www.jspinsider.com/beans/snippets/database/HashTables.txt
Frank ;-)
 
Acetylsalicylic acid is aspirin. This could be handy too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic