I have a Database and a table with about 200 mb data. (Product descriptions, and a lot of values)
I need this values to display some Detail-Pages. So I plan to use a little cache-system to speed things up. I think serialize is the better way to go with php.
Now I wonder how to save my data best, to get the best speed.
Every product as one file, one file with all products or chunks (lets say 100 products per file)?
I want to store the informations in an object like this, serialize it and save it:
class saveObj
{
$sql = "SELECT * FROM products LIMIT 0,100"
$time;
$data;
};
filename: sql_products_0_100.data
Will my plan be efficient or does anyone know a way to optimize?
(I would create all data files once per day)
This is hard to say without writing some test code and doing some profiling.
If you go down the 100 products per file route, are all the 100 products going be used to generate the page?
Having 1 file per product means that the disk will need to seek alot if you need data about 100 files per page.
Having 100 products per file means that if your page only requires 1 product, then it needs to read all the data in and then search for the appropriate product to extract.
My suggestion would be to investigate APC. The cache is stored in memory, so access is extremely fast and you can store 1 product per key, which should simplify retrival and storage.
If load increases and you are load balancing across multiple servers, then you can look at memcached, which is a distributed memory caching system.