Connecting Tech Pros Worldwide Help | Site Map

Caching query results: PHP caching vs MySQL caching

Hermann
Guest
 
Posts: n/a
#1: Dec 12 '06
My site is a bit slow showing the main page so I thought caching query
result in PHP will improve performace.
Then I read MySQL documentation and saw that MySQL does have a caching
feature.
So... now I dont know if doing the PHP caching is worth the pain.
Would there be any noticed performace improvement if I cache query
results in PHP, considering that MySQL is already caching the queries?

Thanks

Andy Hassall
Guest
 
Posts: n/a
#2: Dec 12 '06

re: Caching query results: PHP caching vs MySQL caching


On 12 Dec 2006 09:35:00 -0800, "Hermann" <Hermann.Richter@gmail.comwrote:
Quote:
>My site is a bit slow showing the main page so I thought caching query
>result in PHP will improve performace.
>Then I read MySQL documentation and saw that MySQL does have a caching
>feature.
>So... now I dont know if doing the PHP caching is worth the pain.
>Would there be any noticed performace improvement if I cache query
>results in PHP, considering that MySQL is already caching the queries?
It depends. Benchmark it on your system; I have no idea where the bottleneck
on your system is, only you can measure that.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Moot
Guest
 
Posts: n/a
#3: Dec 12 '06

re: Caching query results: PHP caching vs MySQL caching


Hermann wrote:
Quote:
My site is a bit slow showing the main page so I thought caching query
result in PHP will improve performace.
Then I read MySQL documentation and saw that MySQL does have a caching
feature.
So... now I dont know if doing the PHP caching is worth the pain.
Would there be any noticed performace improvement if I cache query
results in PHP, considering that MySQL is already caching the queries?
>
Thanks
MySQL's caching is a start, but only if the queries are your actual
problem.

Do some profiling to see what portions of the code are causing the
slowdown (can be as simple as echoing out microtime() after each
significant logic block).

If the query turns out to be the problem, then verify that your table
schema has any appropriate indexes and check your query to make sure it
is optimized. Only after you've done this should you worry about
caching.

Finally, if the page does not need to be dynamic (ie: something new
every load), then consider caching the entire page as a static version
of itself for a period of time using Smarty or something similar.

- Moot

Hermann
Guest
 
Posts: n/a
#4: Dec 14 '06

re: Caching query results: PHP caching vs MySQL caching


The generation time of the main page is always less than 0.1 seconds.
Nevertheless, the page takes several seconds to load.
I dont know what is slowing down the loading.

Satya
Guest
 
Posts: n/a
#5: Dec 14 '06

re: Caching query results: PHP caching vs MySQL caching



Hermann wrote:
Quote:
The generation time of the main page is always less than 0.1 seconds.
Nevertheless, the page takes several seconds to load.
I dont know what is slowing down the loading.
It can be bad HTML. Please check that using validator like:
http://validator.w3.org/
This may improve your page load and then it can smooth your page load
also.


All Smiles
Satya Prakash

Closed Thread