If the query is to populate a select list, you can always use javascript
as your cache.
Create a dynamic .js file which contains all records from the database
in a JSON array or similar - assuming of course the supplier table isn't
gigantic. If new stuff is added to the database, regenerate the .js file
by linking to it with a new querystring variable eg
contacts.js.php?version=1234. As the search criteria changes, have some
code in a <script> tag which remakes/resorts the list.
This way you get minimal database load, and you can use one of those
nice javascript autocomplete select list widgets which populates from
the .js file instead of requiring an AJAX request or page reload.
Maybe this would work for your situation? I have used this approach
before and it's often a good way to go.
Harvey.
On 2/02/2010 10:24 p.m., Todd Martin wrote:
Hi Richard
Part of the reason for the complexity of the query is that the supplier list
is reduced based on relevance for the type of search, typically I'd guess
that there'd be 10 to 20 suppliers.
So why not just cache the query?
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Todd Martin
Sent: 02 February 2010 22:08
To: [email protected]
Subject: Re: [phpug] PHP session variables vs database cache
Hi Todd,
....and another thing.
If your "supplier" list is large, it can't be a pleasant experience for
the user to have to scan through a huge drop down list until he/she
finds the right supplier. Also the data populating your select list must
be pulled across the internet, which is going to be far slower than
pulling that data across your server network. So caching the query
results on the server won't give you nearly as much performance gain as
paginating the "supplier" data.
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.
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]
--
Harvey Kane
New Zealand:
-Office: +64 9 950 4133
-Mobile: +6421 811 951
Email: [email protected]
If you need to contact me urgently, please read my email policy
www.ragepank.com/email/
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]