db_stat.html   [plain text]


<!--$Id: db_stat.html,v 1.1.1.1 2003/02/15 04:55:50 zarzycki Exp $-->
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
<!--All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: Db.stat</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
</head>
<body bgcolor=white>
<a name="2"><!--meow--></a>
<table width="100%"><tr valign=top>
<td>
<h1>Db.stat</h1>
</td>
<td align=right>
<a href="../api_java/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
</td></tr></table>
<hr size=1 noshade>
<tt>
<h3><pre>
import com.sleepycat.db.*;
<p>
public Object stat(int flags)
    throws DbException;
</pre></h3>
<h1>Description</h1>
<p>The Db.stat method creates a statistical structure and
fills it with statistics for the database.
<p>The <b>flags</b> value must be set to 0 or
one of the following values:
<p><dl compact>
<p><dt><a name="Db.DB_FAST_STAT">Db.DB_FAST_STAT</a><dd>Return only the values which do not require traversal of the database.
Fields returned when this flag is set are noted with an asterisk (*)
below.
<p>Among other things, this flag makes it possible for applications to
request key and record counts without incurring the performance penalty
of traversing the entire database.  If the underlying database is of
type Recno, or of type Btree and the database was created with the
<a href="../api_java/db_set_flags.html#DB_RECNUM">Db.DB_RECNUM</a> flag, the count of keys will be exact.  Otherwise,
the count of keys will be the value saved the last time the database
was traversed, or 0 if no count of keys has ever been made.  If the
underlying database is of type Recno, the count of data items will be
exact, otherwise, the count of data items will be the value saved the
last time the database was traversed, or 0 if no count of data items
has ever been done.
</dl>
<p>If the Db.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.
<p>In the presence of multiple threads or processes accessing an active
database, the information returned by Db.stat may be out-of-date.
<p>If the database was not opened read-only and the Db.DB_FAST_STAT
flag was not specified, the cached key and record numbers will be
updated after the statistical information has been gathered.
<p>The Db.stat method cannot be transaction-protected.  For this reason,
it should be called in a thread of control that has no open cursors or
active transactions.
<p>The Db.stat method throws an exception that encapsulates a non-zero error value on
failure.
<h3>Hash Statistics</h3>
<p>In the case of a Hash database,
the statistics are returned in an instance of DbHashStat.  The data
fields are available from DbHashStat:
<p><dl compact>
<p><dt>public int hash_magic*<dd>Magic number that identifies the file as a Hash file.
<dt>public int hash_version*<dd>The version of the Hash database.
<dt>public int hash_nkeys*<dd>The number of unique keys in the database.  If Db.DB_FAST_STAT was
specified the count will be the last saved value unless it has never
been calculated, in which case it will be 0.
<dt>public int hash_ndata*<dd>The number of key/data pairs in the database.  If Db.DB_FAST_STAT
was specified the count will be the last saved value unless it has never
been calculated, in which case it will be 0.
<dt>public int hash_pagesize*<dd>The underlying Hash database page (and bucket) size, in bytes.
<dt>public int hash_ffactor*<dd>The desired fill factor (number of items per bucket) specified at
database-creation time.
<dt>public int hash_buckets*<dd>The number of hash buckets.
<dt>public int hash_free<dd>The number of pages on the free list.
<dt>public int hash_bfree<dd>The number of bytes free on bucket pages.
<dt>public int hash_bigpages<dd>The number of big key/data pages.
<dt>public int hash_big_bfree<dd>The number of bytes free on big item pages.
<dt>public int hash_overflows<dd>The number of overflow pages (overflow pages are pages that contain items
that did not fit in the main bucket page).
<dt>public int hash_ovfl_free<dd>The number of bytes free on overflow pages.
<dt>public int hash_dup<dd>The number of duplicate pages.
<dt>public int hash_dup_free<dd>The number of bytes free on duplicate pages.
</dl>
<h3>Btree and Recno Statistics</h3>
<p>In the case of a Btree or Recno database,
the statistics are returned in an instance of DbBtreeStat.  The data
fields are available from DbBtreeStat:
<p><dl compact>
<p><dt>public int bt_magic*<dd>Magic number that identifies the file as a Btree database.
<dt>public int bt_version*<dd>The version of the Btree database.
<dt>public int bt_nkeys*<dd>For the Btree Access Method, the number of unique keys in the database.
If Db.DB_FAST_STAT was specified and the database was created with
the <a href="../api_java/db_set_flags.html#DB_RECNUM">Db.DB_RECNUM</a> flag, the count will be exact, otherwise, the
count will be the last saved value unless it has never been calculated,
in which case it will be 0.
<p>For the Recno Access Method, the exact number of records in the
database.
<dt>public int bt_ndata*<dd>For the Btree Access Method, the number of key/data pairs in the
database.  If Db.DB_FAST_STAT was specified the count will be the
last saved value unless it has never been calculated, in which case it
will be 0.
<p>For the Recno Access Method, the exact number of records in the
database. If the database has been configured to not renumber records
during deletion, the count of records will only reflect undeleted
records.
<dt>public int bt_pagesize*<dd>Underlying database page size, in bytes.
<dt>public int bt_minkey*<dd>The minimum keys per page.
<dt>public int bt_re_len*<dd>The length of fixed-length records.
<dt>public int bt_re_pad*<dd>The padding byte value for fixed-length records.
<dt>public int bt_levels<dd>Number of levels in the database.
<dt>public int bt_int_pg<dd>Number of database internal pages.
<dt>public int bt_leaf_pg<dd>Number of database leaf pages.
<dt>public int bt_dup_pg<dd>Number of database duplicate pages.
<dt>public int bt_over_pg<dd>Number of database overflow pages.
<dt>public int bt_free<dd>Number of pages on the free list.
<dt>public int bt_int_pgfree<dd>Number of bytes free in database internal pages.
<dt>public int bt_leaf_pgfree<dd>Number of bytes free in database leaf pages.
<dt>public int bt_dup_pgfree<dd>Number of bytes free in database duplicate pages.
<dt>public int bt_over_pgfree<dd>Number of bytes free in database overflow pages.
</dl>
<h3>Queue Statistics</h3>
<p>In the case of a Queue database,
the statistics are returned in an instance of DbQueueStat.  The data
fields are available from DbQueueStat:
<p><dl compact>
<p><dt>public int qs_magic*<dd>Magic number that identifies the file as a Queue file.
<dt>public int qs_version*<dd>The version of the Queue file type.
<dt>public int qs_nkeys*<dd>The number of records in the database.  If Db.DB_FAST_STAT was
specified the count will be the last saved value unless it has never
been calculated, in which case it will be 0.
<dt>public int qs_ndata*<dd>The number of records in the database.  If Db.DB_FAST_STAT was
specified the count will be the last saved value unless it has never
been calculated, in which case it will be 0.
<dt>public int qs_pagesize*<dd>Underlying database page size, in bytes.
<dt>public int qs_extentsize*<dd>Underlying database extent size, in pages.
<dt>public int qs_pages<dd>Number of pages in the database.
<dt>public int qs_re_len*<dd>The length of the records.
<dt>public int qs_re_pad*<dd>The padding byte value for the records.
<dt>public int qs_pgfree<dd>Number of bytes free in database pages.
<dt>public int qs_first_recno*<dd>First undeleted record in the database.
<dt>public int qs_cur_recno*<dd>Next available record number.
</dl>
<p>The Db.stat method throws an exception that encapsulates a non-zero error value on
failure.
<h1>Errors</h1>
<p>The Db.stat method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods.
If a catastrophic error has occurred, the Db.stat method may fail and
throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>,
in which case all subsequent Berkeley DB calls will fail in the same way.
<h1>Class</h1>
<a href="../api_java/db_class.html">Db</a>
<h1>See Also</h1>
<a href="../api_java/db_list.html">Databases and Related Methods</a>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<a href="../api_java/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
</td></tr></table>
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
</body>
</html>