This is being changed for 2.4.10 and 2.6.0-RC3. Tyler Brock ' s explanation:
Now so the server uses power of 2 by default, if the default chunk size for Gridfs is 256k we'll almost always be thro Wing away some storage space. This is because if the bindata field of a chunk would occupy 256k (an exact power of 2), then _id and foreign key reference To the Files collection, etc would take a additional space that would cause the document ' s allocated storage to be rounded Up to 512k (the next power of 2). This would is a huge waste.
Instead, if we make the default chunk size 255k then we have a extra 1k to store the _id and other metadata so this when The document is persisted we round up to 256k and not 512k upon persisting the document.
MongoDB has changed the default chunksize from 2.4.10 to 255KB, before it was 256KB. The above paragraph explains why to modify, the original MongoDB server always 2^n bytes to get space, when the default setting of Chunksize is 256K, BinaryData will consume 256K of space, and other fields such as _id, File_ids and N will occupy an additional dozens of bytes of space. This will be more than 256K, then the server will give each chunk to allocate 512K, so waste is big .....
ThechunksCollection
Each document in the chunks collection represents a distinct chunk of a file as represented in the Gridfsstore. The following is a prototype document from the chunks collection.:
{ <ObjectId><ObjectId><num>< binary>}
A document from the chunks collection contains the following fields:
- chunks. _id
-
The unique ObjectId of the chunk.
- chunks. files_id
-
The _id of the "parent" document, as specified in the files collection.
- chunks. N
-
The sequence number of the chunk. Gridfs numbers all chunks, starting with 0.
- chunks. Data
-
The chunk ' s payload as a BSON binary type.
The chunks collection uses a compound index on files_id and n, as described in Gridfs Index.
TheFilesCollection
Each document in the files collection represents a file in the Gridfs store. Consider the following prototype of a document in the files collection:
{"_ID":<ObjectId>,"Length":<Num>,"ChunkSize":<Num>,"Uploaddate":<timestamp> "MD5" : <hash> "filename" : <string> " ContentType ": <string> span class= "S2" > "aliases" : <string array< Span class= "o" >> "metadata" : < dataobject>,}
Documents in the files collection contain some or all of the following fields. Applications may create additional arbitrary fields:
- files. _id
-
The unique ID for this document. The _id is of the data type, chose for the original document. The default type for MongoDB documents is BSON ObjectId.
- files. length
-
The size of the document in bytes.
- files. chunkSize
-
The size of each chunk. Gridfs divides the document into chunks of the size specified here. The default size is 255 kilobytes.
Changed in version 2.4.10:the the default chunk size Changed from 256k to 255k.
- files. uploaddate
-
The date the document was first stored by GRIDFS. This value has the Date type.
- files. MD5
-
An MD5 hash returned by the FILEMD5 command. The value has the String type.
- files. filename
-
Optional. A human-readable name for the document.
- files. ContentType
-
Optional. A valid MIME type for the document.
- files. aliases
-
Optional. An array of alias strings.
- files. metadata
-
Optional. Any additional information your want to store.