[TYPO3-dev] Get a quicker DBAL

Xavier Perseguers typo3 at perseguers.ch
Tue Aug 24 22:30:21 CEST 2010


Hi,

With the upcoming release of TYPO3 4.5 alpha1, prepared queries are 
starting to be used in Core.

If you are currently using DBAL, you are encouraged to checkout the 
QueryCache branch:

https://svn.typo3.org/TYPO3v4/Extensions/dbal/branches/QueryCache

(save it to typo3conf/ext/dbal to override the system extension version)

You will already get a slightly quicker TYPO3.

The idea is simple, for each prepared query DBAL sees, it caches it! 
This means that once a prepared query has been seen previously, the 
parsed and remapped prepared query is used instead resulting in a 
performance gain! Straightforward, isn't it?

The DBAL caching framework works either with TransientMemory or with 
Memcached. In fact, it may use another backend for caching but it would 
then make no real sense I guess.


When using TransientMemory (default option when nothing else is 
configured), queries are cached for the current request, allowing 
prepared queries that are issued more than once to be reused. When using 
Memcache, best option, queries are cached from one request to the other, 
making it much better.


To use it, edit localconf.php:

$TYPO3_CONF_VARS['SYS']['useCachingFramework'] = 1;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['dbal'] = array(
         'backend' => 't3lib_cache_backend_TransientMemoryBackend',
         'options' => array(
         ),
);

Note: you may omit the configuration at all, as long as 
useCachingFramework is active, caching will default to 
t3lib_cache_backend_TransientMemoryBackend

For memcached, use:

$TYPO3_CONF_VARS['SYS']['useCachingFramework'] = 1;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['dbal'] = array(
         'backend' => 't3lib_cache_backend_MemcachedBackend',
         'options' => array(
                 'servers' => array('localhost:11211', 
'otherhost:11211', 'thirdhost:11211'), // port is mandatory!
         )
);

You need to have memcached installed as a daemon and also as a PHP 
extension!


Remember that prepared queries are the key for a quicker DBAL. As such 
you are both encouraged to provide prepared query patches for the Core 
and of course review the upcoming RFCs on that topic.

And above all, do not hesitate to report success or failure you have 
with this enhanced DBAL.

Cheers
Xavier




More information about the TYPO3-dev mailing list