DB->stat API Ref

#include <db.h>

int DB->stat(DB *db, DB_TXN *txnid, void *sp, u_int32_t flags);

int DB->stat_print(DB *db, u_int32_t flags);


Description: DB->stat

The DB->stat method creates a statistical structure and copies a pointer to it into user-specified memory locations. Specifically, if sp is non-NULL, a pointer to the statistics for the database are copied into the memory location to which it refers.

Parameters
flags txnid

Statistical structures are stored in allocated memory. If application-specific allocation routines have been declared (see DB_ENV->set_alloc for more information), they are used to allocate the memory; otherwise, the standard C library malloc(3) is used. The caller is responsible for deallocating the memory. To deallocate the memory, free the memory reference; references inside the returned memory need not be individually freed.

If the DB_FAST_STAT flag has not been specified, the DB->stat method will access some of or all the pages in the database, incurring a severe performance penalty as well as possibly flushing the underlying buffer pool.

In the presence of multiple threads or processes accessing an active database, the information returned by DB->stat may be out-of-date.

If the database was not opened read-only and the DB_FAST_STAT flag was not specified, the cached key and record numbers will be updated after the statistical information has been gathered.

The DB->stat method may not be called before the DB->open method is called.

The DB->stat method returns a non-zero error value on failure and 0 on success.

Hash Statistics

In the case of a Hash database, the statistics are stored in a structure of type DB_HASH_STAT. The following fields will be filled in:


u_int32_t hash_magic; u_int32_t hash_version; u_int32_t hash_nkeys; u_int32_t hash_ndata; u_int32_t hash_pagecnt; u_int32_t hash_pagesize; u_int32_t hash_ffactor; u_int32_t hash_buckets; u_int32_t hash_free; u_int32_t hash_bfree; u_int32_t hash_bigpages; u_int32_t hash_big_bfree; u_int32_t hash_overflows; u_int32_t hash_ovfl_free; u_int32_t hash_dup; u_int32_t hash_dup_free;
Btree and Recno Statistics

In the case of a Btree or Recno database, the statistics are stored in a structure of type DB_BTREE_STAT. The following fields will be filled in:


u_int32_t bt_magic; u_int32_t bt_version; u_int32_t bt_nkeys; u_int32_t bt_ndata; u_int32_t bt_pagecnt; u_int32_t bt_pagesize; u_int32_t bt_minkey; u_int32_t bt_re_len; u_int32_t bt_re_pad; u_int32_t bt_levels; u_int32_t bt_int_pg; u_int32_t bt_leaf_pg; u_int32_t bt_dup_pg; u_int32_t bt_over_pg; u_int32_t bt_empty_pg; u_int32_t bt_free; u_int32_t bt_int_pgfree; u_int32_t bt_leaf_pgfree; u_int32_t bt_dup_pgfree; u_int32_t bt_over_pgfree;
Queue Statistics

In the case of a Queue database, the statistics are stored in a structure of type DB_QUEUE_STAT. The following fields will be filled in:


u_int32_t qs_magic; u_int32_t qs_version; u_int32_t qs_nkeys; u_int32_t qs_ndata; u_int32_t qs_pagesize; u_int32_t qs_extentsize; u_int32_t qs_pages; u_int32_t qs_re_len; u_int32_t qs_re_pad; u_int32_t qs_pgfree; u_int32_t qs_first_recno; u_int32_t qs_cur_recno;

Errors

The DB->stat method may fail and return one of the following non-zero errors:


DB_REP_HANDLE_DEAD

DB_REP_LOCKOUT

EINVAL

Description: DB->stat_print

The DB->stat_print method displays the database statistical information, as described for the DB->stat method. The information is printed to a specified output channel (see the DB_ENV->set_msgfile method for more information), or passed to an application callback function (see the DB_ENV->set_msgcall method for more information).

The DB->stat_print method may not be called before the DB->open method is called.

The DB->stat_print method returns a non-zero error value on failure and 0 on success.

Parameters
flags


Class DB
See Also Databases and Related Methods

APIRef

Copyright (c) 1996,2008 Oracle. All rights reserved.