Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

design issue...

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
I have a search page where the user can provide search criteria. If the result is too large say 10,000 records, I wish to display only 20 records per page. When the usr clicks the next button, he gets the next 20.
My question is is it better to connect to DB and retrive values every time user clicks next or is it better to have all the values stored in ur servlet at one time ? In later case, if 10 users are asking for the data, there is 100,000 records memory is used in the server.
PL advice.
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hit the datbase each time. This is by far the most common method. One thing you can do is store a reference to the id of the items so that you don't to redo the search, just look up the item requested. Even better (and this is the slickest way I've figured out) is this method.
1) Search for the items and return the first 10 you wish to view.
2) When you do the search for the ten to display, figure out and also return the previous and next ten and store them in the search result object you are using.
3) Now, when you get the next or prev 10 you repeat step two.
This way you always know what the next/prev ten are and can even make your prev/next links "smart" because when you display a set of ten item you know whether or not to show a prev/next link. This also works well if you want to 'step' through the detail pages with a prev/next except you only keep a single reference instead of the prev/next ten. Hope this helps.
Sean
 
You've gotta fight it! Don't give in! Read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic