File: cachesize.html

package info (click to toggle)
db4.3 4.3.29-8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 34,368 kB
  • ctags: 26,050
  • sloc: ansic: 111,720; tcl: 39,474; java: 29,503; perl: 11,771; sh: 11,295; cpp: 8,584; makefile: 1,769; awk: 1,312; cs: 457; xml: 114; php: 22; asm: 14
file content (98 lines) | stat: -rw-r--r-- 4,632 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Selecting the Cache Size</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.62.4" />
    <link rel="home" href="index.html" title="Getting Started with Berkeley DB" />
    <link rel="up" href="dbconfig.html" title="Chapter6.Database Configuration" />
    <link rel="previous" href="dbconfig.html" title="Chapter6.Database Configuration" />
    <link rel="next" href="btree.html" title="BTree Configuration" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Selecting the Cache Size</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="dbconfig.html">Prev</a></td>
          <th width="60%" align="center">Chapter6.Database Configuration</th>
          <td width="20%" align="right"><a accesskey="n" href="btree.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="cachesize"></a>Selecting the Cache Size</h2>
          </div>
        </div>
        <div></div>
      </div>
      <p>
        Cache size is important to your application because if it is set to too
        small of a value, your application's performance will suffer from too
        much disk I/O. On the other hand, if your cache is too large, then your
        application will use more memory than it actually needs.
        Moreover, if your application uses too much memory, then on most
        operating systems this can result in your application being swapped out
        of memory, resulting in extremely poor performance.
    </p>
      <p>
        You select your cache size using either
            <span>
                <tt class="methodname">DB-&gt;set_cachesize()</tt>, or 
                <tt class="methodname">DB_ENV-&gt;set_cachesize()</tt>,
            </span>
            
            
         depending on whether you are using a database environment or not. You
         cache size must be a power of 2, but it is otherwise limited only by
         available memory and performance considerations.
    </p>
      <p>
        Selecting a cache size is something of an art, but fortunately it is
        selected at database (or environment) open time, so it can be easily
        tuned to your application's data requirements as they change over time.
        The best way to determine how large your cache needs to be is to put
        your application into a production environment and watch to see how much
        disk I/O is occurring. If your application is going to disk quite a lot
        to retrieve database records, then you should increase the size of your
        cache (provided that you have enough memory to do so).
    </p>
      <p>
        You can use the <tt class="literal">db_stat</tt> command line utility with the
        <tt class="literal">-m</tt> option to gauge the effectiveness of your cache.
        In particular, the number of pages found in the cache is shown, along
        with a percentage value. The closer to 100% that you can get, the
        better. If this value drops too low, and you are experiencing
        performance problems, then you should consider increasing the size of
        your cache, assuming you have memory to support it.
    </p>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="dbconfig.html">Prev</a></td>
          <td width="20%" align="center">
            <a accesskey="u" href="dbconfig.html">Up</a>
          </td>
          <td width="40%" align="right"><a accesskey="n" href="btree.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Chapter6.Database Configuration</td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top">BTree Configuration</td>
        </tr>
      </table>
    </div>
  </body>
</html>