[pybsddb] Making calls to keys() more efficient (or, how to do inequality gets on keys?)

Jesus Cea jcea at jcea.es
Fri Jun 18 16:33:47 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 18/06/10 16:16, Denis Papathanasiou wrote:
> Unfortunately, the db in question is not a btree, so I couldn't use the
> cursor idea.

You could "convert it" to a btree easily, surely. I would recomend you
to do.

You only need to open new databases with "DB_BTREE" instead of
"DB_HASH". To convert a old database, you only need to create a new
"DB_BTREE" database and copy the values over with a cursor. It is a
simple and fast, one time operation.

Usually HASH databases have better performance when you have huge number
or registers accessed at random, but I suspect you have a pretty high
locality of reference, so a BTREE would be more performant (because it
keeps key-close registers close in disk too).

Please, evaluate seriously to migrate to btree. Collect stats with both
approaches, and decide with real hard data at hand.

> Is range key request limited to btrees? If not, then I'd vote for it to
> be included in pybsddb as well.

Only btree allows ranges, because hashes doesn't preserve key ordering
in disk.

- -- 
Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
jcea at jcea.es - http://www.jcea.es/     _/_/    _/_/  _/_/    _/_/  _/_/
jabber / xmpp:jcea at jabber.org         _/_/    _/_/          _/_/_/_/_/
.                              _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQCVAwUBTBuDy5lgi5GaxT1NAQIstQQAi2R3EbEU4O/JXjPeFgufv6XiwGybG+2n
SiE0DqK48Nsh508rAuOFu6au8dfvu8T8V+Uhc2Ugv++uRkqUfmTxD6YgTPY6g26c
TnsADaItdwR5/uBeNS0XOJgfcabs0Ekju60/2MM00VTs6uPRsfZsx8unbP6R2uKB
FOf6Byej9tA=
=VEAT
-----END PGP SIGNATURE-----



More information about the pybsddb mailing list