问题
I'm currently investigating to use MongoDB for storing E-Mail data. As E-Mails may become rather big in size (say 10 megs).
I believe that GridFS would be a good fit for this. What scares me a bit tough is, that the docs are not very clear about the shard size within gridFS. From what I understand is, that the shard size in gridFS is not equal to the normal shard size but defaults to 256kb. Which sounds to me like a big waste of space, as many e-mails will not exceed 50kb in size.
Is there a way to configure the shard size of files in GridFS to make it more adequate for storing mails?
Cheers, Matthias
回答1:
You do not have to worry about size. Even if the chunksize is 256kb, a document (containing your email) of 50kb, will still just use 50kb (+ minor overhead).
The chunksize is configured in the driver. For example with the PHP driver you would do:
$gridFs->storeFile( 'filename.txt', array( 'chunkSize' => 50 * 1024 ) );
And in the Java driver you'd call setChunkSize on GridFSInputFile.
But in general, you shouldn't have to worry about the chunkSize.
来源:https://stackoverflow.com/questions/10384307/configure-gridfs-chunksize-in-mongodb