In MongoDB, WiredTiger provides the Zlib compression option.
To enable the Zlib compression option, I created a collection using the following code.
db.createCollection( "questions", { storageEngine: {
wiredTiger: { configString: "blockCompressor=zlib" }}})
I ran some simple tests to measure compression performance and used following data sets storing strings
{
'_id': <ObjectID>,
'question_id': <Five character string>,
'question': <My question>
}
I created another one collection with any compression option using the following code.
db.createCollection( "questions")
Measured the data size using following comment
db.stats(1024*1024).dataSize + db.stats(1024*1024).indexSize
But I can't able to see the compression difference between these two collections. I referred the following links to achieve my process.
https://www.mongodb.com/blog/post/new-compression-options-mongodb-30
https://scalegrid.io/blog/enabling-data-compression-in-mongodb-3-0/