1<!--$Id: env_set_lk_partitions.so,v 10.2 2008/04/29 22:45:33 mbrey Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DbEnv::set_lk_partitions</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DbEnv::set_lk_partitions</b> 14</td> 15<td align=right> 16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24int 25DbEnv::set_lk_partitions(u_int32_t partitions); 26<p> 27int 28DbEnv::get_lk_partitions(u_int32_t *lk_partitions); 29</pre></b> 30<hr size=1 noshade> 31<b>Description: DbEnv::set_lk_partitions</b> 32<p>Set the number of lock table partitions in the Berkeley DB 33environment. 34The default value is 10 times the number of CPUs on the system if there 35is more than one CPU. 36Increasing the number of partitions can provide for greater throughput on 37a system with multiple CPUs and more than one thread contending for the 38lock manager. 39On single processor systems more than one partition may increase the overhead 40of the lock manager. Systems often report threading contexts as CPUs this 41may require setting the number of partitions to 1 to get optimal performance. 42</p> 43<p>The database environment's number of partitions may also be configured using the 44environment's <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file. The syntax of the entry in that 45file is a single line with the string "set_lk_partitions", one or more whitespace 46characters, and the number of partitions. 47Because the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file is read when the database environment 48is opened, it will silently overrule configuration done before that 49time.</p> 50<p>The DbEnv::set_lk_partitions method configures a database environment, not only operations 51performed using the specified <a href="../api_cxx/env_class.html">DbEnv</a> handle.</p> 52<p>The DbEnv::set_lk_partitions method may not be called after the <a href="../api_cxx/env_open.html">DbEnv::open</a> method is 53called. 54If the database environment already exists when 55<a href="../api_cxx/env_open.html">DbEnv::open</a> is called, the information specified to DbEnv::set_lk_partitions 56will be ignored. 57</p> 58<p>The DbEnv::set_lk_partitions method 59either returns a non-zero error value 60or throws an exception that encapsulates a non-zero error value on 61failure, and returns 0 on success. 62</p> 63<b>Parameters</b> <br> 64 <b>partitions</b><ul compact><li>The <b>partitions</b> parameter is the number of partitions 65to be configured in the Berkeley DB environment.</ul> 66<br> 67<br><b>Errors</b> 68<p>The DbEnv::set_lk_partitions method 69may fail and throw 70<a href="../api_cxx/except_class.html">DbException</a>, 71encapsulating one of the following non-zero errors, or return one of 72the following non-zero errors:</p> 73<br> 74<b>EINVAL</b><ul compact><li>If the method was called after <a href="../api_cxx/env_open.html">DbEnv::open</a> was called; or if an 75invalid flag value or parameter was specified.</ul> 76<br> 77<hr size=1 noshade> 78<b>Description: DbEnv::get_lk_partitions</b> 79<p>The DbEnv::get_lk_partitions method returns the number of partitions.</p> 80<p>The DbEnv::get_lk_partitions method may be called at any time during the life of the 81application.</p> 82<p>The DbEnv::get_lk_partitions method 83either returns a non-zero error value 84or throws an exception that encapsulates a non-zero error value on 85failure, and returns 0 on success. 86</p> 87<b>Parameters</b> <br> 88 <b>lk_partitions</b><ul compact><li>The DbEnv::get_lk_partitions method returns the 89number of partitions in <b>lk_partitions</b>.</ul> 90<br> 91<hr size=1 noshade> 92<br><b>Class</b> 93<a href="../api_cxx/env_class.html">DbEnv</a>, <a href="../api_cxx/lock_class.html">DbLock</a> 94<br><b>See Also</b> 95<a href="../api_cxx/lock_list.html">Locking Subsystem and Related Methods</a> 96</tt> 97<table width="100%"><tr><td><br></td><td align=right> 98<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 99</td></tr></table> 100<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 101</body> 102</html> 103