On this page
Out of GridFS dividing sheet storage, note the following cases:
files collection
In most cases does not require files collection fragmented, this collection is usually very small, only contains some meta information collection nor proper key piece of data it can be evenly distributed in the cluster. If you need to files be fragments may be used _id field associated with the application field of the composite sheet made key.
Not to `` files`` fragmentation means that all meta-information files are stored on a slice, in a production environment, to be in stores files using a replication set on the slices.
chunks collection
Using the following command { files_id : . 1 , n- : . 1 } to do is key sheet chunks set slice:
db.fs.chunks.createIndex( { files_id : 1 , n : 1 } ) db.runCommand( { shardCollection : "test.fs.chunks" , key : { files_id : 1 , n : 1 } } )
Only like this can also be used file_id fields fragmentation:
db.runCommand( { shardCollection : "test.fs.chunks" , key : { files_id : 1 } } )
important
In GridFS storage of chunks collection time slice, only two sheets key to select, `` {files_id: 1, n: 1} `` and { files_id : . 1 } .
The default files_id is the ObjectId , the ObjectId is incremented, and therefore all new data will be written to a separate storage slice, the slice if the write load is too large, consider for a key sheet or files use a different set of the _id value.