• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hitting the database or Creating a session???

 
Hrithik Roshan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m confused now!
i have developed a web application based on MVC pattern.
i have 8000 records to show;
and per page i have to show only 10 records;
wht am i suppose to do..
hit the database for every next 10 records
or get the result set into vector and put the vector int session;
i m currently putting the whole thing into session and iterating thought the session;
works fine;
but i m not satisfied!!!
please someone help me!!!
 
Al Green
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well that depends on your requirements. If your resultset is guaranteed to be small, or never go over a certain limit, and you have a "close"/"fast" connection from your servlet engine to your DB (transfer of large resultset can hinder network perf) you can stick w/ your current easy solution. Also consider the size of the machine the servlet engine is running on, the memory that is. You don't want for every user to pull back 8000 records and stuff them into a session, it just doesn't scale and you could get the dreadful "java.lang.OutOfMemoryException"
However, if the size of your resultset is to grow and/or you don't have the best connection between your servlet engine and your db then you need to implement a paging pattern as you have already indicated. I would recommend looking at the sun petstore for a complete implementation of the paged list pattern. I would recommend this approach. It allows you to fine-tune the size of your "pages" if you will. So if you are running your servlet engine on a smaller box, with an extremely high user load then you can use smaller page size, say 100 records, with more roundtrips to the db. However, if you are running on a heavyweight machine then you can use large page sizes.
Hope this helps,
Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!