Michael Ströder wrote:
HI!
In my monitoring check I'd like to indicate how many entries are in a database.
Currently I'm using the no-op search control without any filtering to count the entries which is obviously a huge waste of CPU and I/O ressources for just retrieving the raw number of DB entries.
Is it easily possible to access the id2e sub-DB and query number of entries?
Something like
mdb_stat -s id2e -e <db-path> | grep Entries
but from Python with python-lmdb or a similar module. (Yes, I know subprocess module but I really hate invoking command-line tools from Python.)
It's pretty trivial in py-lmdb.
#### import lmdb
env = lmdb.open('/tmp/test', max_dbs=2) with env.begin() as txn: subdb = env.open_db('id2e', txn=txn, create=False) print txn.stat(subdb) ####