user745235
user745235

Reputation:

MongoDB created files

I'm trying MongoDB but I don't understand the files created by it.

If I create a document on my db collection lets say users, it will create these files on my /data/db/

_tmp (folder)
mongod.lock
users.0 - 16.8MB
users.1 - 33.6MB
users.ns - 16.8MB

I've added some documents and the files size haven't changed..I'm a bit lost here...does anyone know how those files work? I've tried to open them with gedit/vim and nothing.

Thanks in advance for any help.

Upvotes: 14

Views: 14502

Answers (2)

Bill
Bill

Reputation: 599

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. Information regarding datafiles can be found here:

http://www.mongodb.org/display/DOCS/Excessive+Disk+Space

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.

Maximum .ns file size is 2GB.

Upvotes: 44

Alex Howansky
Alex Howansky

Reputation: 53581

Mongo pre-allocates space in chunks, so your file size will stay at 16Mb until you have more than 16Mb of data, and it rolls over a new chunk.

Upvotes: 1

Related Questions