LoginSignup
1
1

More than 5 years have passed since last update.

mongoDB v3 圧縮データの find()

Posted at

mongoDB v3 でストレージエンジンでのデータ圧縮がサポートされているが、このデータを読み込む時のメモリの使用量に違いがあるかどうかを確認した。

確認方法

mongoDB に 1,000,000/2,000,000/4,000,000 件のデータを登録して、その全データを find() により取得する。

スクリプト実行中に、
・vmstat 1 2
・mongostat 1 -n 2
を 1 秒 sleep で実行し、find() 開始前後のメモリ使用量を比較する。

find.js
DBQuery.shellBatchSize=2000000000
db.test.find({})
実行
shell> mongo test1 < find.js > /dev/null

結果

ストレージ上は圧縮されるが、メモリに展開されたときには、ローデータが乗っているよう。
Percona server for mongoDB でも試してみたが、同じ結果が得られた。

mongoV3 + 圧縮none

show dbs
test1 0.323GB <- 1,000,000 件
test2 0.646GB <- 2,000,000 件
test3 1.293GB <- 4,000,000 件

1,000,000 2,000,000 4,000,000
vsize 336M 669M 1,254M
res 336M 670M 1,341B

mongoV3 + snappy (cacheSizeは大きめに設定)

show dbs
test1 0.048GB
test2 0.096GB
test3 0.190GB

1,000,000 2,000,000 4,000,000
vsize 309M 668M 1,254M
res 316M 669M 1,341M

Percona server for mongoDB

show dbs
test1 0.016GB
test2 0.031GB
test3 0.047GB

1,000,000 2,000,000 4,000,000
vsize 398M 898M 1,698M
res 340M 682M 1,310M
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1