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

« back to all changes in this revision

Viewing changes to db/docs/ref/am_misc/tune.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: tune.html,v 1.1.1.1.2.1 2001/07/23 20:31:18 jbj Exp $-->
 
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
 
3
<!--All rights reserved.-->
 
4
<html>
 
5
<head>
 
6
<title>Berkeley DB Reference Guide: Access method tuning</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><a name="3"><!--meow--></a>
 
12
<table width="100%"><tr valign=top>
 
13
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Access Methods</dl></h3></td>
 
14
<td align=right><a href="../../ref/am_misc/diskspace.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/am_misc/faq.html"><img src="../../images/next.gif" alt="Next"></a>
 
15
</td></tr></table>
 
16
<p>
 
17
<h1 align=center>Access method tuning</h1>
 
18
<p>There are a few different issues to consider when tuning the performance
 
19
of Berkeley DB access method applications.
 
20
<p><dl compact>
 
21
<p><dt>access method<dd>An application's choice of a database access method can significantly
 
22
affect performance.  Applications using fixed-length records and integer
 
23
keys are likely to get better performance from the Queue access method.
 
24
Applications using variable-length records are likely to get better
 
25
performance from the Btree access method, as it tends to be faster for
 
26
most applications than either the Hash or Recno access methods.  Because
 
27
the access method APIs are largely identical between the Berkeley DB access
 
28
methods, it is easy for applications to benchmark the different access
 
29
methods against each other.  See <a href="../../ref/am_conf/select.html">Selecting an access method</a> for more information.
 
30
<p><dt>cache size<dd>The Berkeley DB database cache defaults to a fairly small size, and most
 
31
applications concerned with performance will want to set it explicitly.
 
32
Using a too-small cache will result in horrible performance.  The first
 
33
step in tuning the cache size is to use the db_stat utility (or the
 
34
statistics returned by the <a href="../../api_c/db_stat.html">DB-&gt;stat</a> function) to measure the
 
35
effectiveness of the cache.  The goal is to maximize the cache's hit
 
36
rate.  Typically, increasing the size of the cache until the hit rate
 
37
reaches 100% or levels off will yield the best performance.  However,
 
38
if your working set is sufficiently large, you will be limited by the
 
39
system's available physical memory.  Depending on the virtual memory
 
40
and file system buffering policies of your system, and the requirements
 
41
of other applications, the maximum cache size will be some amount
 
42
smaller than the size of physical memory.  If you find that
 
43
<a href="../../utility/db_stat.html">db_stat</a> shows that increasing the cache size improves your hit
 
44
rate, but performance is not improving (or is getting worse), then it's
 
45
likely you've hit other system limitations.  At this point, you should
 
46
review the system's swapping/paging activity and limit the size of the
 
47
cache to the maximum size possible without triggering paging activity.
 
48
Finally, always remember to make your measurements under conditions as
 
49
close as possible to the conditions your deployed application will run
 
50
under, and to test your final choices under worst-case conditions.
 
51
<p><dt>shared memory<dd>By default, Berkeley DB creates its database environment shared regions in
 
52
filesystem backed memory.  Some systems do not distinguish between
 
53
regular filesystem pages and memory-mapped pages backed by the
 
54
filesystem, when selecting dirty pages to be flushed back to disk.  For
 
55
this reason, dirtying pages in the Berkeley DB cache may cause intense
 
56
filesystem activity, typically when the filesystem sync thread or
 
57
process is run.  In some cases, this can dramatically affect application
 
58
throughput.  The workaround to this problem is to create the shared
 
59
regions in system shared memory (<a href="../../api_c/env_open.html#DB_SYSTEM_MEM">DB_SYSTEM_MEM</a>) or in
 
60
application private memory (<a href="../../api_c/env_open.html#DB_PRIVATE">DB_PRIVATE</a>).
 
61
<p><dt>large key/data items<dd>Storing large key/data items in a database can alter the performance
 
62
characteristics of Btree, Hash and Recno databases.  The first parameter
 
63
to consider is the database page size.  When a key/data item is too
 
64
large to be placed on a database page, it is stored on "overflow" pages
 
65
that are maintained outside of the normal database structure (typically,
 
66
items that are larger than one-quarter of the page size are deemed to
 
67
be too large).  Accessing these overflow pages requires at least one
 
68
additional page reference over a normal access, so it is usually better
 
69
to increase the page size than to create a database with a large number
 
70
of overflow pages.  Use the <a href="../../utility/db_stat.html">db_stat</a> utility (or the statistics
 
71
returned by the <a href="../../api_c/db_stat.html">DB-&gt;stat</a> function) to review the number of overflow
 
72
pages in the database.
 
73
<p>The second issue is using large key/data items instead of duplicate data
 
74
items.  While this can offer performance gains to some applications
 
75
(because it is possible to retrieve several data items in a single get
 
76
call), once the key/data items are large enough to be pushed off-page,
 
77
they will slow the application down.  Using duplicate data items is
 
78
usually the better choice in the long run.
 
79
</dl>
 
80
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/am_misc/diskspace.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/am_misc/faq.html"><img src="../../images/next.gif" alt="Next"></a>
 
81
</td></tr></table>
 
82
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
 
83
</body>
 
84
</html>