The BDB backend ("back-bdb") uses a lot of special features of Sleepycat'sOracle's Berkeley DB library, and there are a lot of details that must be set correctly to get the best results from it. Even though the LDBM backend ("back-ldbm") can use the BerkeleyDB library, the BDB and LDBM backends have some very important differences, as already noted in What are the different backends? What are their differences?.

Because back-bdb is transaction-based and uses write-ahead logging to ensure data consistency, it has much heavier I/O demands than back-ldbm. Also, the transaction log files accumulate as data is written to the directory, and these log files must be cleaned out periodically. Otherwise the log files will consume enormous amounts of disk space. The cleanup procedures are described in
How to maintain Berkeley DB (logs etc.) ?.

You should read the entire slapd-bdb(5) manpage before proceeding.
The only mandatory keyword is "directory" for setting the location of the database files. The other keywords control tradeoffs between data reliability, performance, and memory use. To ensure that committed transactions actually get flushed to disk, you should use the "checkpoint" keyword, otherwise your data is vulnerable to loss due to system failures. See the BerkeleyDB documentation
for more information about checkpoints. (In fact, you should read all of chapter 9 "Berkeley DB Transactional Data Store Applications" in the BerkeleyDB reference manual. At least, read sections 1-3 and 13-24.)

The "dbnosync" keyword is provided for compatibility with back-ldbm; the preferred method of setting this is to use the BDB DB_CONFIG file option set_flags DB_TXN_NOSYNC. The "lockdetect" keyword is also deprecated, you
should instead use the BDB DB_CONFIG file set_lk_detect keyword. (It's safe to leave this at the default setting.)

A number of important items must be configured in the BDB DB_CONFIG file and not in slapd.conf. You should, at least, read about these items:

The BDB library maintains its own cache separate from the back-bdb entry cache. You must set this cache to a size appropriate for your database and physical memory size. Note that this is a persistent setting - after you set it the first time, further changes will be ignored until you recreate the environment using db_recover.

Set the buffer size for the transaction log. Larger is better, but it doesn't have much effect unless you're also using the DB_TXN_NOSYNC option. With a default log file size of 10MB I usually set this to 2MB. The default is only 32K, which is too small for back-bdb.

On a very busy system you might see error messages talking about running out of locks, lockers, or lock objects. Usually the default values are plenty, and in older versions of the BDB library the errors were more likely due to library bugs than actual system load. However, it is possible that you have actually run out of lock resources due to heavy system usage. If this happens, you should read about Configuring Locking and the set_lk_max_lockers, set_lk_max_locks, and set_lk_max_objects keywords.