Symas OpenLDAP Knowledge Base

Using mdb_stat

The mdb_stat manpage:

MDB_STAT(1)                 General Commands Manual                MDB_STAT(1)

NAME
       mdb_stat - LMDB environment status tool

SYNOPSIS
       mdb_stat [-V] [-e] [-f[f[f]]] [-n] [-r[r]] [-a | -s subdb]  envpath

DESCRIPTION
       The mdb_stat utility displays the status of an LMDB environment.

OPTIONS
       -V     Write  the  library  version  number to the standard output, and
              exit.

       -e     Display information about the database environment.

       -f     Display information about the environment freelist.  If  -ff  is
              given, summarize each freelist entry.  If -fff is given, display
              the full list of page IDs in the freelist.

       -n     Display the status of an LMDB database which does not use subdi‐
              rectories.

       -r     Display  information  about the environment reader table.  Shows
              the process ID, thread ID, and transaction ID  for  each  active
              reader  slot.  The process ID and transaction ID are in decimal,
              the thread ID is in hexadecimal. The transaction ID is displayed
              as  "-" if the reader does not currently have a read transaction
              open.  If -rr is given, check for stale entries  in  the  reader
              table and clear them. The reader table will be printed again af‐
              ter the check is performed.

       -a     Display the status of all of the subdatabases  in  the  environ‐
              ment.

       -s subdb
              Display the status of a specific subdatabase.

DIAGNOSTICS
       Exit  status  is  zero if no errors occur.  Errors result in a non-zero
       exit status and a diagnostic message being written to standard error.

SEE ALSO
       mdb_copy(1)

AUTHOR
       Howard Chu of Symas Corporation <http://www.symas.com>

Typical Output

root@symas-ldap0:~# mdb_stat -f /var/symas/openldap-data/symas/
Freelist Status
  Tree depth: 1
  Branch pages: 0
  Leaf pages: 1
  Overflow pages: 0
  Entries: 26
  Free pages: 179
Status of Main DB
  Tree depth: 1
  Branch pages: 0
  Leaf pages: 1
  Overflow pages: 0
  Entries: 24

From this we can derive the “size” of the data in the Main DB and the Freelist. Mdb pages are 4K (4096 bytes) in size. So the Main DB has 24x4Kb or 96Kb and the FreeList has 26x4Kb or 104Kb.