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

Berkeley DB Reference Guide: Access Methods



0

Selecting an access method



JKeys in the Btree are stored in sorted order, and the relationship betweenGthem is defined by that sort order. The default sort order is lexical,Jbut applications may provide any sort order they choose. For this reason,Bthe Btree access method should be used when there is a locality ofGreference between keys. Locality of reference means that accessing oneHparticular key in the Btree means that the application is more likely toGwant to access keys that are somehow related to the key being accessed.NFor example, if keys are timestamps, and it's likely that a request for an 8AM@timestamp will be followed by a request for a 9AM timestamp, theKBtree access method is generally the right choice. Or, for example, if theIkeys are individual surnames, and the application will want to review allEindividuals with the same last name, the Btree access method is againthe right choice.

BThe Hash access method should be used when there is no locality ofreference between keys.

DThe Recno access method should be used when it is desirable to store5and retrieve records based on logical record numbers.

DIt is possible to store and retrieve records based on logical record#numbers in the Btree access method.!However, those record numbers areEalways mutable, i.e., as records are deleted or inserted, the logicalFrecord number for other records in the database can change. The RecnoGaccess method can be configured to run in either mutable or fixed mode:Fmutable, where logical record numbers change as records are deleted orDinserted, and fixed, where record numbers never change regardless ofEthe database operation. Generally, the Recno access method should beDused when the primary method for accessing the database is a logicalrecord number.)

IIn addition, the Recno access method provides support for databases whoseIpermanent storage is a flat text file and the database is used as a fast,@temporary storage area while the data is being read or modified.

GBecause the access method implementation unavoidably interacts with theFapplication's data set, locking requirements and data access patterns,Iusing one access method instead of another can sometimes provide superiorJperformance. For applications whose data can potentially be stored in moreJthan one type of database, it may be useful to benchmark the application's)performance using the two access methods.

OOne of the strengths of Berkeley DB is that it provides multiple access methodsIand provides almost identical interfaces to the different access methods.FBecause of this, it is a simple task to modify an application to use aCdifferent access method. This allows applications to benchmark theLdifferent Berkeley DB access methods against each other for their particulardata set and access pattern.

GAHÿÿ