Take the 2-minute tour ×
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. It's 100% free, no registration required.

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?

Or

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

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.

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

 
discard

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.