1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>DbEnv::set_lk_partitions()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" /> 10 <link rel="up" href="lock.html" title="Chapter 7. The DbLock Handle" /> 11 <link rel="prev" href="envset_lk_max_objects.html" title="DbEnv::set_lk_max_objects()" /> 12 <link rel="next" href="lockdetect.html" title="DbEnv::lock_detect()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbEnv::set_lk_partitions()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_lk_max_objects.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 7. 23 The DbLock Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="lockdetect.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="envset_lk_partitions"></a>DbEnv::set_lk_partitions()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::set_lk_partitions(u_int32_t partitions); </pre> 42 <p> 43 Set the number of lock table partitions in the Berkeley DB 44 environment. The default value is 10 times the number of CPUs on the 45 system if there is more than one CPU. Increasing the number of 46 partitions can provide for greater throughput on a system with 47 multiple CPUs and more than one thread contending for the lock 48 manager. On single processor systems more than one partition may 49 increase the overhead of the lock manager. Systems often report 50 threading contexts as CPUs. If your system does this, set the number of 51 partitions to 1 to get optimal performance. 52 </p> 53 <p> 54 The database environment's number of partitions may also be configured 55 using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 56 syntax of the entry in that file is a single line with the string 57 "set_lk_partitions", one or more whitespace characters, and the number 58 of partitions. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is 59 read when the database environment is opened, it will silently 60 overrule configuration done before that time. 61 </p> 62 <p> 63 The <code class="methodname">DbEnv::set_lk_partitions()</code> method configures a database 64 environment, not only operations performed using the specified 65 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle. 66 </p> 67 <p> 68 The <code class="methodname">DbEnv::set_lk_partitions()</code> method may not be called after the 69 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method is 70 called. If the database environment already exists when 71 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> is called, the 72 information specified to <code class="methodname">DbEnv::set_lk_partitions()</code> will be ignored. 73 </p> 74 <p> 75 The <code class="methodname">DbEnv::set_lk_partitions()</code> <span> 76 77 <span> 78 method either returns a non-zero error value or throws an 79 exception that encapsulates a non-zero error value on 80 failure, and returns 0 on success. 81 </span> 82 </span> 83 </p> 84 <div class="sect2" lang="en" xml:lang="en"> 85 <div class="titlepage"> 86 <div> 87 <div> 88 <h3 class="title"><a id="id1680698"></a>Parameters</h3> 89 </div> 90 </div> 91 </div> 92 <div class="sect3" lang="en" xml:lang="en"> 93 <div class="titlepage"> 94 <div> 95 <div> 96 <h4 class="title"><a id="id1680773"></a>partitions</h4> 97 </div> 98 </div> 99 </div> 100 <p> 101 The <span class="bold"><strong>partitions</strong></span> parameter is the 102 number of partitions to be configured in the Berkeley DB environment. 103 </p> 104 </div> 105 </div> 106 <div class="sect2" lang="en" xml:lang="en"> 107 <div class="titlepage"> 108 <div> 109 <div> 110 <h3 class="title"><a id="id1680942"></a>Errors</h3> 111 </div> 112 </div> 113 </div> 114 <p> 115 The <code class="methodname">DbEnv::set_lk_partitions()</code> <span> 116 117 <span> 118 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 119 exception, encapsulating one of the following non-zero errors, or return one 120 of the following non-zero errors: 121 </span> 122 </span> 123 </p> 124 <div class="sect3" lang="en" xml:lang="en"> 125 <div class="titlepage"> 126 <div> 127 <div> 128 <h4 class="title"><a id="id1680629"></a>EINVAL</h4> 129 </div> 130 </div> 131 </div> 132 <p> 133 If the method was called after <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> 134 was called; or if an invalid flag value or parameter was specified. 135 </p> 136 </div> 137 </div> 138 <div class="sect2" lang="en" xml:lang="en"> 139 <div class="titlepage"> 140 <div> 141 <div> 142 <h3 class="title"><a id="id1680848"></a>Class</h3> 143 </div> 144 </div> 145 </div> 146 <p> 147 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a>, 148 <a class="link" href="lock.html" title="Chapter 7. The DbLock Handle">DbLock</a> 149 </p> 150 </div> 151 <div class="sect2" lang="en" xml:lang="en"> 152 <div class="titlepage"> 153 <div> 154 <div> 155 <h3 class="title"><a id="id1680590"></a>See Also</h3> 156 </div> 157 </div> 158 </div> 159 <p> 160 <a class="xref" href="lock.html#locklist" title="Locking Subsystem and Related Methods">Locking Subsystem and Related Methods</a> 161 </p> 162 </div> 163 </div> 164 <div class="navfooter"> 165 <hr /> 166 <table width="100%" summary="Navigation footer"> 167 <tr> 168 <td width="40%" align="left"><a accesskey="p" href="envset_lk_max_objects.html">Prev</a> </td> 169 <td width="20%" align="center"> 170 <a accesskey="u" href="lock.html">Up</a> 171 </td> 172 <td width="40%" align="right"> <a accesskey="n" href="lockdetect.html">Next</a></td> 173 </tr> 174 <tr> 175 <td width="40%" align="left" valign="top">DbEnv::set_lk_max_objects() </td> 176 <td width="20%" align="center"> 177 <a accesskey="h" href="index.html">Home</a> 178 </td> 179 <td width="40%" align="right" valign="top"> DbEnv::lock_detect()</td> 180 </tr> 181 </table> 182 </div> 183 </body> 184</html> 185