Basically with Zend DB you should cache the MetaData lookup, as this can be an expensive process.

Firstly in your application.ini you should have already set up your Cache settings, I now use the cachemanager default resource plugin provided by Zend


;; RESOURCE CACHE SETUP ;;
resources.cachemanager.database.frontend.name = Core
resources.cachemanager.database.frontend.options.lifetime = 7200
resources.cachemanager.database.frontend.options.automatic_serialization = true
resources.cachemanager.database.backend.name = File
resources.cachemanager.database.backend.options.cache_dir = ROOT_DIR "/tmp/cache"

Next add the following code to your bootstrap to set the metadata cache.


protected function _initDbCache()
{
// Bootstrap DB
$this->bootstrap('db');

// Bootstrap cache
$this->bootstrap('cachemanager');
$cache = $this->getResource('cachemanager');

// Set DB metadata cache
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache->getCache('database'));
}