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>DB_ENV->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 6. The DB_LOCK Handle" /> 11 <link rel="prev" href="envset_lk_max_objects.html" title="DB_ENV->set_lk_max_objects()" /> 12 <link rel="next" href="lockdetect.html" title="DB_ENV->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">DB_ENV->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 6. 23 The DB_LOCK 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>DB_ENV->set_lk_partitions()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->set_lk_partitions(DB_ENV *dbenv, 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">DB_ENV->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 DB_ENV Handle">DB_ENV</a> handle. 66 </p> 67 <p> 68 The <code class="methodname">DB_ENV->set_lk_partitions()</code> method may not be called after the 69 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method is 70 called. If the database environment already exists when 71 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> is called, the 72 information specified to <code class="methodname">DB_ENV->set_lk_partitions()</code> will be ignored. 73 </p> 74 <p> 75 The <code class="methodname">DB_ENV->set_lk_partitions()</code> <span> 76 <span> 77 method returns a non-zero error value on failure and 0 on success. 78 </span> 79 80 </span> 81 </p> 82 <div class="sect2" lang="en" xml:lang="en"> 83 <div class="titlepage"> 84 <div> 85 <div> 86 <h3 class="title"><a id="id1676467"></a>Parameters</h3> 87 </div> 88 </div> 89 </div> 90 <div class="sect3" lang="en" xml:lang="en"> 91 <div class="titlepage"> 92 <div> 93 <div> 94 <h4 class="title"><a id="id1676584"></a>partitions</h4> 95 </div> 96 </div> 97 </div> 98 <p> 99 The <span class="bold"><strong>partitions</strong></span> parameter is the 100 number of partitions to be configured in the Berkeley DB environment. 101 </p> 102 </div> 103 </div> 104 <div class="sect2" lang="en" xml:lang="en"> 105 <div class="titlepage"> 106 <div> 107 <div> 108 <h3 class="title"><a id="id1676468"></a>Errors</h3> 109 </div> 110 </div> 111 </div> 112 <p> 113 The <code class="methodname">DB_ENV->set_lk_partitions()</code> <span> 114 <span> 115 method may fail and return one of the following non-zero errors: 116 </span> 117 118 </span> 119 </p> 120 <div class="sect3" lang="en" xml:lang="en"> 121 <div class="titlepage"> 122 <div> 123 <div> 124 <h4 class="title"><a id="id1676519"></a>EINVAL</h4> 125 </div> 126 </div> 127 </div> 128 <p> 129 If the method was called after <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> 130 was called; or if an invalid flag value or parameter was specified. 131 </p> 132 </div> 133 </div> 134 <div class="sect2" lang="en" xml:lang="en"> 135 <div class="titlepage"> 136 <div> 137 <div> 138 <h3 class="title"><a id="id1676659"></a>Class</h3> 139 </div> 140 </div> 141 </div> 142 <p> 143 <a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a>, 144 <a class="link" href="lock.html" title="Chapter 6. The DB_LOCK Handle">DB_LOCK</a> 145 </p> 146 </div> 147 <div class="sect2" lang="en" xml:lang="en"> 148 <div class="titlepage"> 149 <div> 150 <div> 151 <h3 class="title"><a id="id1676632"></a>See Also</h3> 152 </div> 153 </div> 154 </div> 155 <p> 156 <a class="xref" href="lock.html#locklist" title="Locking Subsystem and Related Methods">Locking Subsystem and Related Methods</a> 157 </p> 158 </div> 159 </div> 160 <div class="navfooter"> 161 <hr /> 162 <table width="100%" summary="Navigation footer"> 163 <tr> 164 <td width="40%" align="left"><a accesskey="p" href="envset_lk_max_objects.html">Prev</a> </td> 165 <td width="20%" align="center"> 166 <a accesskey="u" href="lock.html">Up</a> 167 </td> 168 <td width="40%" align="right"> <a accesskey="n" href="lockdetect.html">Next</a></td> 169 </tr> 170 <tr> 171 <td width="40%" align="left" valign="top">DB_ENV->set_lk_max_objects() </td> 172 <td width="20%" align="center"> 173 <a accesskey="h" href="index.html">Home</a> 174 </td> 175 <td width="40%" align="right" valign="top"> DB_ENV->lock_detect()</td> 176 </tr> 177 </table> 178 </div> 179 </body> 180</html> 181