简体   繁体   English

为什么LMDB数据库占用的数据超过实际数据?

[英]Why LMDB database taking more than actual data size?

I put around 11K key&values in LMDB database . 我在LMDB数据库中放了大约11K键和值。 LMDB database file size become 21Mb. LMDB数据库文件大小变为21Mb。

For the same data the leveldb is taking 8Mb only (with snappy compression). 对于相同的数据,leveldb仅采用8Mb(具有快速压缩)。

LMDB env info , LMDB env info,

VERSION=3
format=bytevalue
type=btree
mapsize=1073741824
maxreaders=126
db_pagesize=4096

TO check why LMDB file size is more ,I iterated through all keys & values inside the database. 为了检查LMDB文件大小的原因,我迭代了数据库中的所有键和值。 The total size of all key & value is 10Mb. 所有键和值的总大小为10Mb。

But the actual size of the file is 21Mb. 但是文件的实际大小是21Mb。 Remaining file size of 11Mb (21Mb - 10Mb) used for what purpose???!!. 剩余文件大小为11Mb(21Mb - 10Mb)用于什么目的??? !!

If i compress data before put operation ,only 2Mb got reduced 如果我在放置操作之前压缩数据,只减少了2Mb

Why LMDB database file size is more than actual data size? 为什么LMDB数据库文件大小超过实际数据大小?

Any way to shrink it ? 有什么方法可以缩小它吗?

The database is bigger than the original file because lmdb requires to do some bookeeping to keep the data sorted. 数据库比原始文件大,因为lmdb需要做一些bookeeping以保持数据排序。 Also, there is an overhead because even if your record (key + value) is say 1kb lmdb allocates a fixed size of space to store those. 此外,还有一个开销,因为即使你的记录(键+值)是1kb,lmdb也会分配一个固定大小的空间来存储它们。 I don't know the actual value. 我不知道实际价值。 But this overhead is always expected. 但总是可以预期这种开销。

Compression doesn't work well on small records. 压缩对小记录不起作用。

lmdb doesn't support prefix or block compression. lmdb不支持前缀或块压缩。 Your best bet is to use a key-value store that does, like wiredtiger . 您最好的选择是使用像有线网格一样的键值存储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM