disable compression for default collection fs.chunks and enable compression for fs.files

357 views
Skip to first unread message

Christopher Smith

unread,
Jan 10, 2016, 5:54:59 PM1/10/16
to mongodb-user
Team,

I am creating a replicaset and at creation time, I would like to enable

compression for fs.files and NOT for fs.chunks.

I know via configuration file  one can disable for all collections.  but how can one enable compression for this default collection

fs.files also.


via config doable for all collections

storage:
  engine: wiredTiger
  wiredTiger:
    collectionConfig:
      blockCompressor: none


I am not sure how to enable for fs.files and disable compression for fs.chunks

Wan Bachtiar

unread,
Jan 21, 2016, 2:25:05 AM1/21/16
to mongodb-user

compression for fs.files and NOT for fs.chunks.

Hi Christopher,

Are there any particular reasons why would you want to disable compression for fs.chunks ? This would make sense if your (binary) data is already compressed enough.

With WiredTiger, MongoDB supports compression for all collections and indexes. By default, collection data in WiredTiger uses snappy block compression. Compression settings are also configurable on a per-collection and per-index basis during collection and index creation.

Note that you can’t change the compression setting on an existing collection. However you can export the data, drop the collection, re-create with the new compression option, and re-import the data.

When you create a new GridFS database, the driver would create the default collection names of fs.files and fs.chunks. So you need to pre-empt the creation of fs.chunks collection on the database to disable compression. You can utilise db.createCollection() to create a new collection and specify to disable compression. For example:

db.createCollection(
    "fs.chunks", 
    { storageEngine: 
        { wiredTiger: 
            { configString: "block_compressor=none" }
        }
    }
);

To confirm whether the collection has been created without compression, you can run db.collection.stats().wiredTiger.creationString and check the block_compressor value.

Regards,

Wan.

Christopher Smith

unread,
Feb 1, 2016, 12:14:02 AM2/1/16
to mongodb-user
yes, the data being stored is jpeg images.  It already has been compressed, I think.

I do not want to use CPU for minimal benefits.
Reply all
Reply to author
Forward
0 new messages