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

Jesus Cea jcea at jcea.es
Fri Jun 11 17:45:03 CEST 2010


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

On 10/06/10 18:13, Jeremy Fishman wrote:
> FYI, memcached specifically limits the number of keys you can query from
> a bucket in one go (to a 2MB response), and does not support range
> queries (on keys), so it is often not possible to dump the entire
> cache's keys.

If you are actually using so many keys, you can use range key request in
Berkeley DB. I am not sure we support it yet in pybsddb. I can not check
it now. But if not, and you need it, just ask and I would add it to the
new pybsddb version.

PS: In my previous email I suggested you use cursors to check and delete
the oldest key in a btree database. If your deletion involves a lot of
keys, you could delete them when moving the cursor, or cache the keys to
delete in memory and then do a mass delete.

The performance depends of your specifics. But everything is better than
a blind "keys()", that would iterate over ALL the database... Unless the
database is really small or cached in RAM :).

- -- 
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/

iQCVAwUBTBJZ/5lgi5GaxT1NAQI0tgP9FbdpNOuOjyIiIpUoKAzofAjJScujBHZ9
zV1pNbUd/EaHAQkEe4I1XC+M8wukSO5qND9g7KYH0t5wgbr7prLgakb99KECwFyi
K5xUAOzpHg/cCPSttpFAo+H0q6xfwjE3I+EkKZTzgXFx/jVw9zuOPkMgzxkmNqMy
6g+sAUdswJE=
=YCJk
-----END PGP SIGNATURE-----



More information about the pybsddb mailing list