Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
Why do you want to have different collections in different files? – Asya Kamsky Nov 6 '13 at 8:29

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.

share|improve this answer
discrete file-sets == .0, .1 datafiles? – vDipak Oct 30 '13 at 2:27
@vDipak Correct, those are the extents that support the database. – sysadmin1138 Oct 30 '13 at 2:46
what if I just want to look at individual collection? How do I dig into it? – vDipak Oct 30 '13 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. – sysadmin1138 Oct 30 '13 at 11:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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