Configure GridFS Chunksize in MongoDB

元气小坏坏 提交于 2019-12-06 05:51:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!