Table of Contents
In almost all cases, there is no need for you to directly configure Berkeley DB resources; instead, you can use the same configuration techniques that you always use for SQLite, or use the Berkeley DB PRAGMAs describe Berkeley DB SQL: The Absolute Basics, and Replication PRAGMAs. The Berkeley DB SQL interface will take care of the rest.
However, there are a few configuration activities that some unusually large or busy installations might need to make and for which there is no SQLite equivalent. This chapter describes those activities.
Before continuing with this section, it is necessary for you to have a high-level understanding of Berkeley DB's environments.
In order to manage its resources (data, shared cache, locks, and transaction logs), Berkeley DB often uses a directory that is called the Berkeley DB environment. As used with the BDB SQL interface, environments contain log files and the information required to implement a shared cache and fine-grained locking. This environment is placed in a directory that appears on the surface to be a SQLite rollback file.
That is, if you use BDB SQL interface to create a database called
mydb.db
, then a directory is created
alongside of it called mydb.db-journal
.
Normally, SQLite creates a journal file only when a
transaction is underway, and deletes this file once the
transaction is committed or rolled back. However, that is not
what is happening here. The BDB SQL interface journal directory contains
important Berkeley DB environment information that is meant to
persist between transactions and even between process
runtimes. So it is very important that you do
not delete the contents of your Berkeley DB
journal directory. Doing so will cause improper operation and
could lead to data loss.
Note that the environment directory is also where you put
your DB_CONFIG
file. This file can be used to
configure additional tuning parameters of Berkeley DB, if its
default behavior is not appropriate for your
application. For more information
on the DB_CONFIG
file, see
the next section.
Experienced users of Berkeley DB should be aware
that neither DB_USE_ENVIRON
nor
DB_USE_ENVIRON_ROOT
are
specified to
DB_ENV->open()
. As
a result, the DB_HOME
environment variable is ignored. This means that the
BDB SQL interface will always create a database
in the location defined by the database name given to
the BDB SQL interface.