I am new to MongoDB.I looked inside dbpath I found

users.0 -  16.8MB
users.1 -  33.6MB
users.ns - 16.8MB

Further when I dig deeper I found,

The .0, .1 files are datafiles. Each datafile is preallocated to a particular size. (This is done to prevent file system fragmentation, among other reasons.) The first filename for a database is .0, then .1, etc. .0 will be 64MB, .1 128MB, et cetera, up to 2GB. Once the files reach 2GB in size, each successive file is also 2GB. The ".ns" files are namespace files. Each collection and index would count as a namespace. Each namespace is 628 bytes, the .ns file is 16MB by default.Thus if every collection had one index, we can create up to 12,000 collections. The --nssize parameter allows you to increase this limit

But I when I started comparing MySQL with I figured out if you specify

innodb_file_per_table = true/1

But I cannot find any option for MongoDB to create separate file to each collection.

Does MongoDB only creates datafiles(.0, .1) which will contain all the collection?


Is there any way to tell MongoDB to create separate files for each collection?

Your kind help and precious time would be highly appreciated

  • Why do you want to have different collections in different files? Commented Nov 6, 2013 at 8:29

1 Answer 1


MongoDB only creates discrete file-sets for discrete databases. There isn't an option to split out collections into files like table-files in MySQL.

  • discrete file-sets == .0, .1 datafiles?
    – vDipak
    Commented Oct 30, 2013 at 2:27
  • @vDipak Correct, those are the extents that support the database. Commented Oct 30, 2013 at 2:46
  • what if I just want to look at individual collection? How do I dig into it?
    – vDipak
    Commented Oct 30, 2013 at 3:51
  • @vDipak If you really want to do it through file-analysis, it is my understanding that the files are BSON format (Binary-JSON). Direct access and manipulation is strongly recommended against, though. Otherwise, do so through the software layer. Commented Oct 30, 2013 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.