MongoDB Documentation, Release 3.0.4 • MongoDB using the mmapv1 storage engine has limits on the number of namespaces . You may wish to know the current number of namespaces in order to determine how many additional namespaces the database can support. To get the current number of namespaces, run the following in the mongo shell: • A MongoDB driver. See the drivers documentation for information on using GridFS with your driver. 9 The use of the term chunks in the context of GridFS is not related to the use of the term chunks in the context of sharding. Chapter 4. Data Models 150 • The mongofiles command-line tool in the mongo shell. See the mongofiles reference for complete documentation. To store and retrieve files using GridFS , use either of the following: Changed in version 2.4.10: The default chunk size changed from 256k to 255k. GridFS is useful not only for storing files that exceed 16MB but also for storing any files for which you want access without having to load the entire file into memory. For more information on the indications of GridFS, see When should I use GridFS? (page 749). When you query a GridFS store for a file, the driver or client will reassemble the chunks as needed. You can perform range queries on files stored through GridFS. You also can access information from arbitrary sections of files, which allows you to “skip” into the middle of a video or audio file. Instead of storing a file in a single document, GridFS divides a file into parts, or chunks, 9 and stores each of those chunks as a separate document. By default GridFS limits chunk size to 255k. GridFS uses two collections to store files. One collection stores the file chunks, and the other stores file metadata. GridFS is a specification for storing and retrieving files that exceed the BSON -document size limit of 16MB. Data modeling decisions should take data lifecycle management into consideration. The Time to Live or TTL feature (page 211) of collections expires documents after a period of time. Consider using the TTL feature if your application requires some data to persist in the database for a limited period of time. Additionally, if your application only uses recently inserted documents, consider Capped Collections (page 209). Capped collections provide first-in-first-out (FIFO) management of inserted documents and efficiently support opera- tions that insert and read documents based on insertion order. To change the size of the new namespace file, start the server with the option --nssize <new size MB> . For existing databases, after starting up the server with --nssize , run the db.repairDatabase() com- mand from the mongo shell. For impacts and considerations on running db.repairDatabase() , see repairDatabase . The limit on the number of namespaces depend on the <database>.ns size. The namespace file defaults to 16 MB. db.system.namespaces.count() Data Lifecycle Management 4.2.3 GridFS Implement GridFS