Improve PHP Performance by Caching Database Results

June 19, 2006

[From OTN]

As is well known, caching the results of database queries can dramatically improve script execution time and minimize the load on the database server. This technique can be especially effective if the data you are dealing with is quite static. This is because many data requests to a remote database may be eventually satisfied from the local cache, thus avoiding the need to make a connection to the database, execute the query, and fetch the results.

While caching database result sets is generally a good idea when the database you are using does not reside on the same machine as the Web server, determining the best caching strategy for your situation may be a challenge. For example, a time triggered caching approach, which is commonly used in caching systems and assumes that the cache is regenerated each time an expiry timestamp is reached, may not be a satisfactory solution for the application where using up-to-date database result sets is crucial. In this case, you need to employ a mechanism that will notify your application each time a change occurs to the database data the application is interested in caching, so that the application can reconcile cached, out-of-date data with the database. This is where Database Change Notification – a new Oracle Database 10g Release 2 feature – can come in very handy.

The article continues at http://www.oracle.com/technology/pub/articles/vasiliev-php-dcn.html?rssid=rss_otn_articles