Notes
=====

Frequently asked questions
--------------------------

This section lists frequently asked questions.

#) How is Dobbin different from ZODB?

   There are other object databases available for Python, most notably
   `ZODB <http://www.zodb.org/>`_ from Zope Corporation.

   Key differences:

   - Dobbin is written 100% in Python. The persistence layer in ZODB
     is written in C. ZODB also comes with support for B-Trees; this
     is also written in C.

   - Dobbin is available on Python 3 (but requires a POSIX-system).

   - ZODB comes with support for B-Trees which allows processes to
     load objects on demand (because of the implicit weak
     reference). Dobbin currently loads all data at once and keeps it
     in memory.

   - Dobbin uses a persistence model that tries to share data in
     active objects between threads, but relies on an explicit
     operation to put an object in a mode that allows making changes
     to it. ZODB shares only inactive object data.

   - ZODB comes with ZEO, an enterprise-level network database layer
     which allows processes on different machines to connect to the
     same database.

   - ZODB comes with a memory management system that evicts object
     data from memory based on usage. Dobbin does not attempt to
     manage memory consumption, but calls upon the virtual memory
     manager to swap inactive object data to disk.

#) What is the database file format?

   The default storage option writes transactions sequentially to a
   single file.

   Each transaction consists of a number of records which consist of a
   Python pickle and sometimes an attached payload of data (in which
   case the pickle contains control information). Finally, the
   transaction ends with a transaction record object, also a Python
   pickle.

#) Can I connect to a single database with multiple processes?

   Yes.

   The default storage option writes transactions to a single file,
   which alone makes up the storage record. Multiple processes can
   connect to the same file and share the same database,
   concurrently. No further configuration is required; the database
   uses POSIX file-locking to ensure exclusive write-access and
   processes automatically stay synchronized.

#) How can I limit memory consumption?

   To avoid memory thrashing, limit the physical memory allowance of
   your Python processes and make sure there is enough virtual memory
   available (at least the size of your database) [#]_.

   You may want to compile Python with the ``--without-pymalloc`` flag to
   use native memory allocation. This may improve performance in
   applications that connect to large databases due to better paging.

.. [#] On UNIX the ``ulimit`` command can be used limit physical memory
 usage; this prevents thrashing when working with large databases.

