Results 1 to 4 of 4

Thread: Possible to reuser a command object between submits?

  1. #1

    Default Possible to reuse a command object between submits?

    Is it possible to reuse a command object between submits? I know that I can reuse a command object between the original GET and the subsequent POST (via the sessionForm bean attribute), but what I want to is reuse it between POSTs. The reason for this is because I have a paginated search page, whereby the search criteria appears above a paged table of results. When the user navigates between the result pages, I obviously don't want to requery the database. In order to achieve this I'm currently having to cache the results in the session once they've beeen retrieved, and then adding them to the new command object when the user navigated between pages.

    Nick
    Last edited by nickcodefresh; Aug 30th, 2006 at 03:40 AM.

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    I would think carefully about caching data in the middle tier. By retrieving all the data once you have the following consequences:

    - DB is doing a lot of work loading all the rows (e.g. 32000)
    - network bandwith is increased
    - CPU is gobbled up while ORM tool rehydrates all those rows
    - memory footprint on the server is increased
    - data might be stale

    whereas if you query each time:

    - DB is only loading what it needs to satisfy each query (e.g. 10 rows)
    - server is stateless between requests (no server affinity etc.)
    - data cannot be stale

    Now, of course each request is going to make the DB do the "expensive" query, but that is what DBs are designed to do How many times do your users actually click through to the next page, then the next page etc.? For example, google often returns 100s of 1000s or rows, but I hardly ever go past page 2 or 3, so storing all that data on the server side is pointless.

    If your users *are* likely to hit page 2,3,4 etc. then maybe a better solution would be to send all the data to the client and use JavaScript to paginate it.

    Just my opinion, but in my experience it is always better to do the DB on every request.
    Colin Yates
    SpringSource - http://www.springsource.com - Spring Training, Consulting, and Support - "From the Source"
    Please read http://www.springframework.org/documentation
    Co-Author of Expert Spring MVC + Web Flow.

  3. #3

    Default

    Ahhh good point, but I was actually simplifying my situation a little in order to make it easier to explain. What actually happens is that the search results is made up of two tabs. The first tab is the results, whist the second is a drill-down of more information regarding one of the result rows. Clicking on the second tab causes a database hit to get more information. After examining the drill-down the user will click back to the first tab. When clicking between these tabs I don't want to re-run the DB search. Hence I have to cache the current search results so that clicking between tabs is nice and fast.

    Hope this clears things up

    Nick

  4. #4
    Join Date
    Oct 2006
    Posts
    27

    Default

    Hi,
    By anychance do you have the solution for this issue,I am facing the similar scenario,where I want to come back to search result page from the details page.
    Any help would be appreciated.

    Thanks
    Shaiju

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •