There are a few different issues to consider when tuning the performance of Berkeley DB transactional applications. First, you should review Access method tuning, as the tuning issues for access method applications are applicable to transactional applications as well. The following are additional tuning issues for Berkeley DB transactional applications:
Consider decreasing the level of isolation of transaction using the DB_READ_UNCOMMITTED, or DB_READ_COMMITTED flags for transactions or cursors or the DB_READ_UNCOMMITTED flag on individual read operations. The DB_READ_COMMITTED flag will release read locks on cursors as soon as the data page is nolonger referenced. This is also called degree 2 isolation. This will tend to block write operations for shorter periods for applications that do not need to have repeatable reads for cursor operations.
The DB_READ_COMMITTED flag will allow read operations to potentially return data which has been modified but not yet committed, and can significantly increase application throughput in applications that do not require data be guaranteed to be permanent in the database. This is also called degree 1 isolation, or dirty reads.
During configuration, Berkeley DB selects a mutex implementation for the architecture. Berkeley DB normally prefers blocking-mutex implementations over non-blocking ones. For example, Berkeley DB will select POSIX pthread mutex interfaces rather than assembly-code test-and-set spin mutexes because pthread mutexes are usually more efficient and less likely to waste CPU cycles spinning without getting any work accomplished.
For some applications and systems (generally highly concurrent applications on large multiprocessor systems), Berkeley DB makes the wrong choice. In some cases, better performance can be achieved by configuring with the --with-mutex argument and selecting a different mutex implementation than the one selected by Berkeley DB. When a test-and-set spin mutex implementation is selected, it may be useful to tune the number of spins made before yielding the processor and sleeping. For more information, see the DB_ENV->mutex_set_tas_spins() method.
Finally, Berkeley DB may put multiple mutexes on individual cache lines. When tuning Berkeley DB for large multiprocessor systems, it may be useful to tune mutex alignment using the DB_ENV->mutex_set_align() method.