Why gridfs's chunk max size is 3.5*1000*1000? Can I increase it to 15*1000*1000?

572 views
Skip to first unread message

gavinliu

unread,
Jun 6, 2013, 11:47:54 PM6/6/13
to mongod...@googlegroups.com
Why gridfs's chunk max size is 3.5*1000*1000?
 Can I increase it to 15*1000*1000?
I want use chunk size = 8MB, this can decrease query times when download large files.

Bernie Hackett

unread,
Jun 7, 2013, 12:08:25 PM6/7/13
to mongod...@googlegroups.com
The GridFS max chunk size is 16MB, just like the max document size in MongoDB.

>>> import gridfs
>>> gfs = gridfs.GridFS(db)
>>> file = 'x' * (32 * 1024 * 1024)
>>> len(file)
33554432
>>> gfs.put(file, chunkSize=15 * 1000 * 1000)
ObjectId('51b204d2fa5bd803b4c21ebd')
>>> db.fs.files.count()
1
>>> db.fs.chunks.count()
3




--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Sam Millman

unread,
Jun 7, 2013, 12:31:09 PM6/7/13
to mongod...@googlegroups.com
As for increasing the chunk size....It all depends, you need to see how it effects your working set.

Bernie Hackett

unread,
Jun 7, 2013, 12:41:58 PM6/7/13
to mongod...@googlegroups.com
Let me clarify a little more. The max size of a "chunk" document is 16MB, like any other MongoDB document. There is some overhead for other required fields (see http://docs.mongodb.org/manual/reference/gridfs/#gridfs-chunks-collection). So the max chunk size is a bit less than 16MB.

gavinliu

unread,
Jun 7, 2013, 10:44:59 PM6/7/13
to mongod...@googlegroups.com
Thanks a lot.
I find 3.5*1000*1000 in Java driver 2.9.1, and I don't understand why its limit is more small than document's max size(16MB).

gavinliu

unread,
Jun 7, 2013, 10:52:48 PM6/7/13
to mongod...@googlegroups.com
In GridFS.java:  
 /**
     * file's chunk size
     */
    public static final int DEFAULT_CHUNKSIZE = 256 * 1024;

    /**
     * file's max chunk size
     */
    public static final long MAX_CHUNKSIZE = (long)(3.5 * 1000 * 1000);

Bernie Hackett

unread,
Jun 8, 2013, 12:55:26 PM6/8/13
to mongod...@googlegroups.com
I don't know why that number was picked. It's not specified in the GridFS spec. You may want to open a ticket about it:



--

gavinliu

unread,
Jun 8, 2013, 9:26:28 PM6/8/13
to mongod...@googlegroups.com
Yes, I will have a try. Thanks.
Reply all
Reply to author
Forward
0 new messages