Hi David ,
I have a lot of feeds on my site and the products database is massive. When I show a top ten viewed products it takes a while to load. I was thinking on exporting the top ten to a new table and running the list from there. Can't get any SQL to work though. Can you help please?
Thanks
Ben
Hello Ben,
One thing that is straight forward to do would be to cache the result of the Top 10 query for 24 hours. Then only one page view a day would be "slow", and you could easily work around that by scheduling a CRON job to request your home page (or wherever Top 10 viewed is shown) just after midnight each day.
First, create a folder call "qcache" in your Price Tapestry installation folder, and make sure that it is writable by PHP (easiest way is normally using your FTP program - right-click on the new folder in the remote window and look for Permissions... or maybe Properties.. and then Permissions, and then give WRITE access to all users (Owner/Group/World).
Wit that in place, assuming that your Top 10 display is based on the Featured Products code / select SQL, you'll have the database_querySelect line as follows:
if (database_querySelect($sql,$rows))
...REPLACE that line with:
$qcacheFilename = "qcache/".md5($sql).".dat";
if (filemtime($qcacheFilename) < (time()-86400))
{
database_querySelect($sql,$rows);
$fp = fopen($qcacheFilename,"w");
fwrite($fp,serialise($rows));
fclose($fp);
}
else
{
$rows = unserialize(file_get_contents($qcacheFilename));
}
if (count($rows))
Hope this helps!
Cheers,
David.
--
PriceTapestry.com