.I:Berkeley DB Reference Guide: Access Methods[P4

Berkeley DB Reference Guide: Access Methods



+

Selecting a page size



FThe size of the pages used in the underlying database can be specifiedeas part of the db_open call to open the database, specificallylby setting the the db_pagesize element of the DB_INFO structure.

JThe minimum page size is 512 bytes and the maximum page size is 64K bytes,@and must be a power-of-two. If no page size is specified by theGapplication, a page size is selected based on the underlying filesystemGI/O block size. The selected size has a lower limit of 512 bytes and anupper limit of 16K bytes.

=There are three issues to consider when selecting a pagesize:

?First, the page size implicitly sets the size of an overflowIrecord. Overflow records are either key or data items that cannot beHplace on a normal database page because of their size, and are thereforeIstored in overflow pages. Overflow pages are pages that exist outside ofAthe normal database structure. For this reason, there is often aAsignificant performance penalty associated with retrieving and/orImodifying overflow records. Selecting a page size that is too small, andJwhich causes a large number of overflow pages to be created, can seriously+impact the performance of your application.

KSecond, Berkeley DB does page-level locking, i.e., access to records in theDdatabase is single-threaded at the granularity of a page, not at theGgranularity of a record on the page. Selecting a page size that is tooJlarge, and which causes threads or processes to wait unnecessarily becauseGother threads of control are accessing or modifying records on the sameBpage as the waiting thread of control needs to lock can impact the performance of your application.

GThird, the page size specifies the granularity of I/O from the databaseNto the operating system (i.e., Berkeley DB will give a page size unit of bytesFto the operating system to be scheduled for writing to the disk). ForGmost operating systems, there is an internal block size which isIused as the granularity of I/O from the operating system to the disk. IfIthe page size is smaller than the block size, the operating system may beGforced to read block size bytes from the disk, copy the page size bytesIinto the buffer it read, and then write out block size bytes to the disk.M(Obviously, it will be much more efficient for Berkeley DB to write page sizeEbytes to the operating system and then the operating system to simplyFwrite the same page size bytes to the disk.) So, selecting a page sizeGthat is too small, and which causes the operating system to coalesce orIotherwise manipulate Berkeley DB pages can impact the performance of yourHapplication. Alternatively, selecting a page size that is too large mayNcause Berkeley DB and the operating system to write more data than is strictly necessary.

HAKÿÿ