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: DB_ENV->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>DB_ENV->set_lk_partitions</b> 14</td> 15<td align=right> 16<a href="../api_c/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.h> 23<p> 24int 25DB_ENV->set_lk_partitions(DB_ENV *dbenv, u_int32_t partitions); 26<p> 27int 28DB_ENV->get_lk_partitions(DB_ENV *dbenv, u_int32_t *lk_partitions); 29</pre></b> 30<hr size=1 noshade> 31<b>Description: DB_ENV->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 DB_ENV->set_lk_partitions method configures a database environment, not only operations 51performed using the specified <a href="../api_c/env_class.html">DB_ENV</a> handle.</p> 52<p>The DB_ENV->set_lk_partitions method may not be called after the <a href="../api_c/env_open.html">DB_ENV->open</a> method is 53called. 54If the database environment already exists when 55<a href="../api_c/env_open.html">DB_ENV->open</a> is called, the information specified to DB_ENV->set_lk_partitions 56will be ignored. 57</p> 58<p>The DB_ENV->set_lk_partitions method 59returns a non-zero error value on failure 60and 0 on success. 61</p> 62<b>Parameters</b> <br> 63 <b>partitions</b><ul compact><li>The <b>partitions</b> parameter is the number of partitions 64to be configured in the Berkeley DB environment.</ul> 65<br> 66<br><b>Errors</b> 67<p>The DB_ENV->set_lk_partitions method 68may fail and return one of the following non-zero errors:</p> 69<br> 70<b>EINVAL</b><ul compact><li>If the method was called after <a href="../api_c/env_open.html">DB_ENV->open</a> was called; or if an 71invalid flag value or parameter was specified.</ul> 72<br> 73<hr size=1 noshade> 74<b>Description: DB_ENV->get_lk_partitions</b> 75<p>The DB_ENV->get_lk_partitions method returns the number of partitions.</p> 76<p>The DB_ENV->get_lk_partitions method may be called at any time during the life of the 77application.</p> 78<p>The DB_ENV->get_lk_partitions method 79returns a non-zero error value on failure 80and 0 on success. 81</p> 82<b>Parameters</b> <br> 83 <b>lk_partitions</b><ul compact><li>The DB_ENV->get_lk_partitions method returns the 84number of partitions in <b>lk_partitions</b>.</ul> 85<br> 86<hr size=1 noshade> 87<br><b>Class</b> 88<a href="../api_c/env_class.html">DB_ENV</a>, <a href="../api_c/lock_class.html">DB_LOCK</a> 89<br><b>See Also</b> 90<a href="../api_c/lock_list.html">Locking Subsystem and Related Methods</a> 91</tt> 92<table width="100%"><tr><td><br></td><td align=right> 93<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 94</td></tr></table> 95<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 96</body> 97</html> 98