Results stored in a session - good idea?

Posted by Nick on Programmers See other posts from Programmers or by Nick
Published on 2012-11-14T10:06:37Z Indexed on 2012/11/14 11:18 UTC
Read the original article Hit count: 230

Filed under:
|

To give a bit of background, lets say it's a generic results page, which is paginated so there are X results per page.

Generally to do this, I have two queries on the page:

  1. to get the total number of results
  2. to get the results, limiting by the correct page's resultset

However, recently I've been trying to cut down on the queries the site is making, and I thought one way to do this would be to only do the query if any parameters to the page have changed (except of course the page number)?
This would then cache all the result id's in a session, which can be sliced when I need to return the correct resultset for that page.

I was trying to look around the net to see if there are downsides of this method, but I've found very little information about it.

Has anyone done this before? Is it a good idea?

© Programmers or respective owner

Related posts about php

Related posts about session