Db::stat API Ref

#include <db_cxx.h>

int Db::stat(DbTxn *txnid, void *sp, u_int32_t flags);

int Db::stat_print(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 DbEnv::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 either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 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 throw DbException, encapsulating one of the following non-zero errors, or 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 DbEnv::set_msgfile method for more information), or passed to an application callback function (see the DbEnv::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 either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

Parameters
flags


Class Db
See Also Databases and Related Methods

APIRef

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