~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/docs/api_c/db_stat.html

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--$Id: db_stat.so,v 10.48 2001/05/05 01:49:12 bostic Exp $-->
 
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
 
3
<!--All rights reserved.-->
 
4
<html>
 
5
<head>
 
6
<title>Berkeley DB: DB-&gt;stat</title>
 
7
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
 
8
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
 
9
</head>
 
10
<body bgcolor=white>
 
11
<a name="2"><!--meow--></a>
 
12
<table width="100%"><tr valign=top>
 
13
<td>
 
14
<h1>DB-&gt;stat</h1>
 
15
</td>
 
16
<td align=right>
 
17
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
 
18
</td></tr></table>
 
19
<hr size=1 noshade>
 
20
<tt>
 
21
<h3><pre>
 
22
#include &lt;db.h&gt;
 
23
<p>
 
24
int
 
25
DB-&gt;stat(DB *db, void *sp, u_int32_t flags);
 
26
</pre></h3>
 
27
<h1>Description</h1>
 
28
<p>The DB-&gt;stat function creates a statistical structure and
 
29
copies a pointer to it into user-specified memory locations.
 
30
Specifically, if <b>sp</b> is non-NULL, a pointer to the statistics
 
31
for the database are copied into the memory location to which it refers.
 
32
<p>Statistical structures are created in allocated memory.  If application-specific allocation
 
33
routines have been declared (see <a href="../api_c/env_set_alloc.html">DB_ENV-&gt;set_alloc</a> for more
 
34
information), they are used to allocate the memory; otherwise, the
 
35
library function <b>malloc</b>(3) is used.  The caller is
 
36
responsible for deallocating the memory.  To deallocate the memory, free
 
37
the memory reference; references inside the returned memory need not be
 
38
individually freed.
 
39
<p>The <b>flags</b> value must be set to 0 or
 
40
one of the following values:
 
41
<p><dl compact>
 
42
<p><dt><a name="DB_CACHED_COUNTS">DB_CACHED_COUNTS</a><dd>Return a cached count of the keys and records in a database.
 
43
<b>The DB_CACHED_COUNTS flag has been deprecated in
 
44
favor of the DB_FAST_STAT flag.  Please update your
 
45
applications.</b>
 
46
<p><dt><a name="DB_FAST_STAT">DB_FAST_STAT</a><dd>Return only the values which do not require traversal of the database.
 
47
Fields returned when this flag is set are noted with an asterisk (*)
 
48
below.
 
49
<p>Among other things, this flag makes it possible for applications to
 
50
request key and record counts without incurring the performance penalty
 
51
of traversing the entire database.  If the underlying database is of
 
52
type Recno, or of type Btree and the database was created with the
 
53
<a href="../api_c/db_set_flags.html#DB_RECNUM">DB_RECNUM</a> flag, the count of keys will be exact.  Otherwise,
 
54
the count of keys will be the value saved the last time the database
 
55
was traversed, or 0 if no count of keys has ever been made.  If the
 
56
underlying database is of type Recno, the count of data items will be
 
57
exact, otherwise, the count of data items will be the value saved the
 
58
last time the database was traversed, or 0 if no count of data items
 
59
has ever been done.
 
60
<p><dt><a name="DB_RECORDCOUNT">DB_RECORDCOUNT</a><dd>Return a count of the records in a Btree or Recno Access Method
 
61
database.  <b>The DB_RECORDCOUNT flag has been
 
62
deprecated in favor of the DB_FAST_STAT flag.  Please update
 
63
your applications.</b>
 
64
</dl>
 
65
<p>If the DB_FAST_STAT flag has not been specified, the
 
66
DB-&gt;stat function will access some of or all the pages in the database,
 
67
incurring a severe performance penalty as well as possibly flushing the
 
68
underlying buffer pool.
 
69
<p>In the presence of multiple threads or processes accessing an active
 
70
database, the information returned by DB-&gt;stat may be out-of-date.
 
71
<p>If the database was not opened read-only and the DB_FAST_STAT
 
72
flag was not specified, the cached key and record numbers will be
 
73
updated after the statistical information has been gathered.
 
74
<p>The DB-&gt;stat function cannot be transaction-protected.  For this reason,
 
75
it should be called in a thread of control that has no open cursors or
 
76
active transactions.
 
77
<p>The DB-&gt;stat function returns a non-zero error value on failure and 0 on success.
 
78
<h3>Hash Statistics</h3>
 
79
<p>In the case of a Hash database,
 
80
the statistics are stored in a structure of type DB_HASH_STAT.  The
 
81
following fields will be filled in:
 
82
<p><dl compact>
 
83
<p><dt>u_int32_t hash_magic*<dd>Magic number that identifies the file as a Hash file.
 
84
<dt>u_int32_t hash_version*<dd>The version of the Hash database.
 
85
<dt>u_int32_t hash_nkeys*<dd>The number of unique keys in the database.  If DB_FAST_STAT was
 
86
specified the count will be the last saved value unless it has never
 
87
been calculated, in which case it will be 0.
 
88
<dt>u_int32_t hash_ndata*<dd>The number of key/data pairs in the database.  If DB_FAST_STAT
 
89
was specified the count will be the last saved value unless it has never
 
90
been calculated, in which case it will be 0.
 
91
<dt>u_int32_t hash_pagesize*<dd>The underlying Hash database page (and bucket) size, in bytes.
 
92
<dt>u_int32_t hash_nelem*<dd>The estimated size of the hash table specified at database-creation time.
 
93
<dt>u_int32_t hash_ffactor*<dd>The desired fill factor (number of items per bucket) specified at
 
94
database-creation time.
 
95
<dt>u_int32_t hash_buckets*<dd>The number of hash buckets.
 
96
<dt>u_int32_t hash_free<dd>The number of pages on the free list.
 
97
<dt>u_int32_t hash_bfree<dd>The number of bytes free on bucket pages.
 
98
<dt>u_int32_t hash_bigpages<dd>The number of big key/data pages.
 
99
<dt>u_int32_t hash_big_bfree<dd>The number of bytes free on big item pages.
 
100
<dt>u_int32_t hash_overflows<dd>The number of overflow pages (overflow pages are pages that contain items
 
101
that did not fit in the main bucket page).
 
102
<dt>u_int32_t hash_ovfl_free<dd>The number of bytes free on overflow pages.
 
103
<dt>u_int32_t hash_dup<dd>The number of duplicate pages.
 
104
<dt>u_int32_t hash_dup_free<dd>The number of bytes free on duplicate pages.
 
105
</dl>
 
106
<h3>Btree and Recno Statistics</h3>
 
107
<p>In the case of a Btree or Recno database,
 
108
the statistics are stored in a structure of type DB_BTREE_STAT.  The
 
109
following fields will be filled in:
 
110
<p><dl compact>
 
111
<p><dt>u_int32_t bt_magic*<dd>Magic number that identifies the file as a Btree database.
 
112
<dt>u_int32_t bt_version*<dd>The version of the Btree database.
 
113
<dt>u_int32_t bt_nkeys*<dd>For the Btree Access Method, the number of unique keys in the database.
 
114
If DB_FAST_STAT was specified and the database was created with
 
115
the <a href="../api_c/db_set_flags.html#DB_RECNUM">DB_RECNUM</a> flag, the count will be exact, otherwise, the
 
116
count will be the last saved value unless it has never been calculated,
 
117
in which case it will be 0.
 
118
<p>For the Recno Access Method, the exact number of records in the
 
119
database.
 
120
<dt>u_int32_t bt_ndata*<dd>For the Btree Access Method, the number of key/data pairs in the
 
121
database.  If DB_FAST_STAT was specified the count will be the
 
122
last saved value unless it has never been calculated, in which case it
 
123
will be 0.
 
124
<p>For the Recno Access Method, the exact number of records in the
 
125
database. If the database has been configured to not renumber records
 
126
during deletion, the count of records will only reflect undeleted
 
127
records.
 
128
<dt>u_int32_t bt_pagesize*<dd>Underlying database page size, in bytes.
 
129
<dt>u_int32_t bt_minkey*<dd>The minimum keys per page.
 
130
<dt>u_int32_t bt_re_len*<dd>The length of fixed-length records.
 
131
<dt>u_int32_t bt_re_pad*<dd>The padding byte value for fixed-length records.
 
132
<dt>u_int32_t bt_levels<dd>Number of levels in the database.
 
133
<dt>u_int32_t bt_int_pg<dd>Number of database internal pages.
 
134
<dt>u_int32_t bt_leaf_pg<dd>Number of database leaf pages.
 
135
<dt>u_int32_t bt_dup_pg<dd>Number of database duplicate pages.
 
136
<dt>u_int32_t bt_over_pg<dd>Number of database overflow pages.
 
137
<dt>u_int32_t bt_free<dd>Number of pages on the free list.
 
138
<dt>u_int32_t bt_int_pgfree<dd>Number of bytes free in database internal pages.
 
139
<dt>u_int32_t bt_leaf_pgfree<dd>Number of bytes free in database leaf pages.
 
140
<dt>u_int32_t bt_dup_pgfree<dd>Number of bytes free in database duplicate pages.
 
141
<dt>u_int32_t bt_over_pgfree<dd>Number of bytes free in database overflow pages.
 
142
</dl>
 
143
<h3>Queue Statistics</h3>
 
144
<p>In the case of a Queue database,
 
145
the statistics are stored in a structure of type DB_QUEUE_STAT.  The
 
146
following fields will be filled in:
 
147
<p><dl compact>
 
148
<p><dt>u_int32_t qs_magic*<dd>Magic number that identifies the file as a Queue file.
 
149
<dt>u_int32_t qs_version*<dd>The version of the Queue file type.
 
150
<dt>u_int32_t qs_nkeys*<dd>The number of records in the database.  If DB_FAST_STAT was
 
151
specified the count will be the last saved value unless it has never
 
152
been calculated, in which case it will be 0.
 
153
<dt>u_int32_t qs_ndata*<dd>The number of records in the database.  If DB_FAST_STAT was
 
154
specified the count will be the last saved value unless it has never
 
155
been calculated, in which case it will be 0.
 
156
<dt>u_int32_t qs_pagesize*<dd>Underlying database page size, in bytes.
 
157
<dt>u_int32_t qs_extentsize*<dd>Underlying database extent size, in pages.
 
158
<dt>u_int32_t qs_pages<dd>Number of pages in the database.
 
159
<dt>u_int32_t qs_re_len*<dd>The length of the records.
 
160
<dt>u_int32_t qs_re_pad*<dd>The padding byte value for the records.
 
161
<dt>u_int32_t qs_pgfree<dd>Number of bytes free in database pages.
 
162
<dt>u_int32_t qs_start<dd>Start offset.
 
163
<dt>u_int32_t qs_first_recno*<dd>First undeleted record in the database.
 
164
<dt>u_int32_t qs_cur_recno*<dd>Last allocated record number in the database.
 
165
</dl>
 
166
<p>The DB-&gt;stat function returns a non-zero error value on failure and 0 on success.
 
167
<h1>Errors</h1>
 
168
<p>The DB-&gt;stat function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
 
169
If a catastrophic error has occurred, the DB-&gt;stat function may fail and return
 
170
<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail
 
171
in the same way.
 
172
<h1>See Also</h1>
 
173
<a href="../api_c/db_create.html">db_create</a>,
 
174
<a href="../api_c/db_associate.html">DB-&gt;associate</a>,
 
175
<a href="../api_c/db_close.html">DB-&gt;close</a>,
 
176
<a href="../api_c/db_cursor.html">DB-&gt;cursor</a>,
 
177
<a href="../api_c/db_del.html">DB-&gt;del</a>,
 
178
<a href="../api_c/db_err.html">DB-&gt;err</a>, <a href="../api_c/db_err.html">DB-&gt;errx</a>
 
179
<a href="../api_c/db_fd.html">DB-&gt;fd</a>,
 
180
<a href="../api_c/db_get.html">DB-&gt;get</a>,
 
181
<a href="../api_c/db_get.html">DB-&gt;pget</a>,
 
182
<a href="../api_c/db_get_byteswapped.html">DB-&gt;get_byteswapped</a>,
 
183
<a href="../api_c/db_get_type.html">DB-&gt;get_type</a>,
 
184
<a href="../api_c/db_join.html">DB-&gt;join</a>,
 
185
<a href="../api_c/db_key_range.html">DB-&gt;key_range</a>,
 
186
<a href="../api_c/db_open.html">DB-&gt;open</a>,
 
187
<a href="../api_c/db_put.html">DB-&gt;put</a>,
 
188
<a href="../api_c/db_remove.html">DB-&gt;remove</a>,
 
189
<a href="../api_c/db_rename.html">DB-&gt;rename</a>,
 
190
<a href="../api_c/db_set_alloc.html">DB-&gt;set_alloc</a>,
 
191
<a href="../api_c/db_set_append_recno.html">DB-&gt;set_append_recno</a>,
 
192
<a href="../api_c/db_set_bt_compare.html">DB-&gt;set_bt_compare</a>,
 
193
<a href="../api_c/db_set_bt_minkey.html">DB-&gt;set_bt_minkey</a>,
 
194
<a href="../api_c/db_set_bt_prefix.html">DB-&gt;set_bt_prefix</a>,
 
195
<a href="../api_c/db_set_cachesize.html">DB-&gt;set_cachesize</a>,
 
196
<a href="../api_c/db_set_dup_compare.html">DB-&gt;set_dup_compare</a>,
 
197
<a href="../api_c/db_set_errcall.html">DB-&gt;set_errcall</a>,
 
198
<a href="../api_c/db_set_errfile.html">DB-&gt;set_errfile</a>,
 
199
<a href="../api_c/db_set_errpfx.html">DB-&gt;set_errpfx</a>,
 
200
<a href="../api_c/db_set_feedback.html">DB-&gt;set_feedback</a>,
 
201
<a href="../api_c/db_set_flags.html">DB-&gt;set_flags</a>,
 
202
<a href="../api_c/db_set_h_ffactor.html">DB-&gt;set_h_ffactor</a>,
 
203
<a href="../api_c/db_set_h_hash.html">DB-&gt;set_h_hash</a>,
 
204
<a href="../api_c/db_set_h_nelem.html">DB-&gt;set_h_nelem</a>,
 
205
<a href="../api_c/db_set_lorder.html">DB-&gt;set_lorder</a>,
 
206
<a href="../api_c/db_set_pagesize.html">DB-&gt;set_pagesize</a>,
 
207
<a href="../api_c/db_set_paniccall.html">DB-&gt;set_paniccall</a>,
 
208
<a href="../api_c/db_set_q_extentsize.html">DB-&gt;set_q_extentsize</a>,
 
209
<a href="../api_c/db_set_re_delim.html">DB-&gt;set_re_delim</a>,
 
210
<a href="../api_c/db_set_re_len.html">DB-&gt;set_re_len</a>,
 
211
<a href="../api_c/db_set_re_pad.html">DB-&gt;set_re_pad</a>,
 
212
<a href="../api_c/db_set_re_source.html">DB-&gt;set_re_source</a>,
 
213
<a href="../api_c/db_stat.html">DB-&gt;stat</a>,
 
214
<a href="../api_c/db_sync.html">DB-&gt;sync</a>,
 
215
<a href="../api_c/db_truncate.html">DB-&gt;truncate</a>,
 
216
<a href="../api_c/db_upgrade.html">DB-&gt;upgrade</a>,
 
217
and
 
218
<a href="../api_c/db_verify.html">DB-&gt;verify</a>.
 
219
</tt>
 
220
<table width="100%"><tr><td><br></td><td align=right>
 
221
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
 
222
</td></tr></table>
 
223
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
 
224
</body>
 
225
</html>