Berkeley DB Reference Version 2026.09.11

db_stat

db_stat -d file [-fN] [-h home] [-P password] [-s database]

db_stat [-acEelmNrtVxZ] [-C Aclop] [-h home] [-L A] [-M Ah] [-R A] 
        [-X A] [-P password]  

The db_stat utility displays statistics for Berkeley DB environments.

The options are as follows:

Values normally displayed in quantities of bytes are displayed as a combination of gigabytes (GB), megabytes (MB), kilobytes (KB), and bytes (B). Otherwise, values smaller than 10 million are displayed without any special notation, and values larger than 10 million are displayed as a number followed by "M".

Deployment health lines

The -c (locking), -t (transaction), and -x (mutex) outputs each end with a Deployment health (alarm on these): block. These are the lines to monitor for shared-region resource exhaustion — a failure that otherwise surfaces only as a bare ENOMEM from a later, unrelated operation:

$ db_stat -h ENV -c | tail -5
Deployment health (alarm on these):
194/4000    Locker slots in use (4% utilized)
11/4000     Lock object slots in use (0% utilized)
194/4000    Lock slots in use (4% utilized)
194/300     SSI committed-reader SIREAD markers live (64% utilized)

$ db_stat -h ENV -t | grep -A3 'Deployment health'
Deployment health (alarm on these):
0/2000      Active transaction slots in use (0% utilized)
213/2000    Snapshot txn details retained (MVCC/SSI) (10% utilized)

$ db_stat -h ENV -x | grep -A2 'Deployment health'
Deployment health (alarm on these):
845/10000   Mutex slots in use (8% utilized)

Each line reports in-use/maximum followed by the utilization percentage. A resource for which no maximum has been configured reports <n>/unlimited ... (no maximum configured): it will grow until the region itself is exhausted, so no meaningful ratio exists. Configuring the maxima is a prerequisite for alarming on these numbers.

The same values are available programmatically, without parsing this output, through DB_ENV->lock_stat(), DB_ENV->txn_stat(), and DB_ENV->mutex_stat(). Note that -Z (DB_STAT_CLEAR) resets the high-water marks these alarms rely on; monitoring should not use it.

For the recommended thresholds, what each signal means, and the remedy for each, see the Deployment health: what to alarm on section of the Berkeley DB Programmer's Reference Guide.

The db_stat utility may be used with a Berkeley DB environment (as described for the -h option, the environment variable DB_HOME, or because the utility was run in a directory containing a Berkeley DB environment). In order to avoid environment corruption when using a Berkeley DB environment, db_stat should always be given the chance to detach from the environment and exit gracefully. To cause db_stat to release all environment resources and exit cleanly, send it an interrupt signal (SIGINT).

The db_stat utility exits 0 on success, and >0 if an error occurs.

For information on the statistics feature for Berkeley DB SQL interface, see Command Line Features Unique to dbsql.

Environment Variables

DB_HOME

If the -h option is not specified and the environment variable DB_HOME is set, it is used as the path of the database home, as described in the DB_ENV->open() method.