Hi Richard > The query produces a list of contacts that have characteristics specific to > that particular search screen, eg suppliers, and is used to populate a drop > down list. The query to populate the drop down list won't change during the > search, however the query that produces the search results will, for example > the user may select a different supplier from the search list or may narrow > the price range or some other search criteria that is on the search page.
I see the problem now. The concept of caching DB data in a session goes against the grain in my mind. You've now got the same data stored in more than one place, so you've introduced a new problem, data concurrency. Not to mention determining when to clear the cache. I can certainly see there could be performance improvements by not pulling the same data through the bottleneck of a network, every time you refresh the page, but it seems that this problem can be greatly alleviated by reducing the size of your result set in the first place. ie. via pagination. Also, is your session caching data in a folder on your webserver? What happens, if you want to utilize load balancing across multiple web servers. This requires you to store the session data in a database table. In which case the same "serialized" data would still need to be pulled across the network. > > Regards > > Richard > > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On Behalf > Of Todd Martin > Sent: 02 February 2010 21:10 > To: [email protected] > Subject: Re: [phpug] PHP session variables vs database cache > > Hi Richard > > >> I have a fairly complex query that runs against 3 MySQL tables to >> produce a list of contacts that are used to populate a select list. > >> The select list may need to be rebuilt a number of times as the user >> refines their search. The query won't vary and the likelihood that the >> results will vary are low enough that saving the results in a session >> variable is acceptable. I'd expect that the user would peruse the >> results for 10 to 60 seconds before refining their search. > > What do you mean, "the query won't vary?" Surely, everytime the user > refines the search, the query changes. Doesn't it? > >> My question is: should I save the query results in a session variable >> for reuse or is the database efficient enough to cache the query results? >> >> >> >> Thanks and regards >> >> >> >> Richard >> >> -- >> NZ PHP Users Group: http://groups.google.com/group/nzphpug >> To post, send email to [email protected] >> To unsubscribe, send email to >> [email protected] >> >> -- >> NZ PHP Users Group: http://groups.google.com/group/nzphpug >> To post, send email to [email protected] >> To unsubscribe, send email to >> [email protected] > -- NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected]
