1<!--$Id: db_set_h_ffactor.so,v 10.37 2004/09/28 15:04:19 bostic 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->set_h_ffactor</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->set_h_ffactor</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->set_h_ffactor(DB *db, u_int32_t h_ffactor); 26int 27<p> 28DB->get_h_ffactor(DB *db, u_int32_t *h_ffactorp); 29</pre></b> 30<hr size=1 noshade> 31<b>Description: DB->set_h_ffactor</b> 32<p>Set the desired density within the hash table. If no value is 33specified, the fill factor will be selected dynamically as pages are 34filled.</p> 35<p>The DB->set_h_ffactor method configures a database, not only operations performed 36using the specified <a href="../api_c/db_class.html">DB</a> handle.</p> 37<p>The DB->set_h_ffactor method may not be called after the <a href="../api_c/db_open.html">DB->open</a> method is called. 38If the database already exists when 39<a href="../api_c/db_open.html">DB->open</a> is called, the information specified to DB->set_h_ffactor will 40be ignored. 41</p> 42<p>The DB->set_h_ffactor method 43returns a non-zero error value on failure 44and 0 on success. 45</p> 46<b>Parameters</b> <br> 47 <b>h_ffactor</b><ul compact><li>The <b>h_ffactor</b> parameter is the desired density within the hash table.</ul> 48<p>The density is an approximation of the number of keys allowed to 49accumulate in any one bucket, determining when the hash table grows or 50shrinks. If you know the average sizes of the keys and data in your 51data set, setting the fill factor can enhance performance. A reasonable 52rule computing fill factor is to set it to the following:</p> 53<blockquote><pre>(pagesize - 32) / (average_key_size + average_data_size + 8)</pre></blockquote> 54<br> 55<br><b>Errors</b> 56<p>The DB->set_h_ffactor method 57may fail and return one of the following non-zero errors:</p> 58<br> 59<b>EINVAL</b><ul compact><li>If the method was called after <a href="../api_c/db_open.html">DB->open</a> was called; or if an 60invalid flag value or parameter was specified.</ul> 61<br> 62<hr size=1 noshade> 63<b>Description: DB->get_h_ffactor</b> 64<p>The DB->get_h_ffactor method returns the hash table density.</p> 65<p>The DB->get_h_ffactor method may be called at any time during the life of the 66application.</p> 67<p>The DB->get_h_ffactor method 68returns a non-zero error value on failure 69and 0 on success. 70</p> 71<b>Parameters</b> <br> 72 <b>h_ffactorp</b><ul compact><li>The DB->get_h_ffactor method returns the 73hash table density in <b>h_ffactorp</b>.</ul> 74<br> 75<hr size=1 noshade> 76<br><b>Class</b> 77<a href="../api_c/db_class.html">DB</a> 78<br><b>See Also</b> 79<a href="../api_c/db_list.html">Databases and Related Methods</a> 80</tt> 81<table width="100%"><tr><td><br></td><td align=right> 82<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> 83</td></tr></table> 84<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 85</body> 86</html> 87