NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: choosing a lightweight database



reed%reedmedia.net@localhost wrote in <alpine.NEB.2.21.1901152015270.21728%t1.m.re@localhost\
edmedia.net>:
 |Any recommendations on a lightweight database (no extra server process) 
 |to use with dynamic website?

I have written a LMDB backend for bogofilter, and am using it
since about mid of July 2018.  (It is not yet released, but done.)
It took a week to learn using LMDB and having implemented that
backend (actually two in one, choosable by preprocessor).  It
could have been shorter if i would have accepted that one error
was on LMDB side (it resulted in the second optional
implementation, but which i do not use, actually, because the
other one is nice, especially compared to how postfix does it).

It is very fast, and very small.  If Berkeley DB is enough for
you, LMDB could be a good option!  As it comes from the OpenLDAP
project, it should be enterprisable:

  #?0|essex:nail.git$ apk info lmdb|grep -A1 size
  lmdb-0.9.23-r0 installed size:
  94208
  #?0|essex:nail.git$ apk info db|grep -A1 size
  db-5.3.28-r1 installed size:
  1572864
  #?0|essex:nail.git$ ll /usr/lib/liblmdb.so.0.0.0
    -rwxr-xr-x 1 root root 79576 Nov 29 11:36 /usr/lib/liblmdb.so.0.0.0*
  #?0|essex:nail.git$ ll /usr/lib/libdb-5.3.so
    -rwxr-xr-x 1 root root 1558496 Nov 21 17:45 /usr/lib/libdb-5.3.so*

It has one "problem" which may be none for you: it grows as it
touches pages; i usually dump my DB once a month, and reload it
thereafter, which saves ~50% or something like that:

  #?0|essex:.bogofilter$ ll
  ...
  -rw-r-----  1 steffen steffen 136531968 Jan 16 21:18 wordlist.lmdb
  ...
  #?0|essex:.bogofilter$ zstd -l ...spam.db.zst
  Frames  Skips  Compressed  Uncompressed  Ratio  Check  Filename
       1      0    15.64 MB      53.05 MB  3.391  XXH64  ...spam.db.zst

 |Any thoughts on lightweight no database server ideas? I may just use 
 |sqlite. Minimal dependencies would be great.

None thereof.

 |Thanks

Well i can send you the implementation (or look at the bogofilter
file at sourceforge [1]): as i learned while i did it, you will
find comments which get you going.

  [1] https://sourceforge.net/p/bogofilter/code/HEAD/tree/trunk/bogofilter/src/datastore_lmdb.c

Ciao,

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)


Home | Main Index | Thread Index | Old Index