2

So, I got a question on a test (without answer unfortunately) that left me with a big doubt whether it's true or false.

The question is this: "By default, WiredTiger storage engine creates one file per collection and per index".

I went to check all the documentation, but I couldn't find a really satisfying answer to this question. I would assume by logic that it of course creates one file per collection and one per index, but how to be sure about that? I think those files are managed by the DB system and thus are not visible to the user.

I just remember that somewhere there are the files of the database looking like dbname.0 and when it grows after a certain threshold, it creates another file dbname.1 etc. so I would assume the collection is inside that file and not a separate entity, thus making the test statement wrong?

1 Answer 1

1

Yes, WiredTiger Engine creates one file per collection and per index.

Files are the part of storage layer that is being maintained by the Storage Engine part. you can locate the created files in the dbpath specified in the configuration file used to start the server instance. For example in case if your underlying OS is ubuntu the default config file path is:

/etc/mongod.conf

In case of WiredTiger engine when you create any collection, then you will be able to find new files like:

collection-22--9037026691096837958.wt index-23--9037026691096837958.wt

here numbers 22,23 indicates the unique identity of collection and index to the storage engine and being maintained withing the storage engine's metadata.

in last part of your question about threshold, you may be interested in storage capacity limits, so you can consider following these links:

https://docs.mongodb.com/manual/reference/limits/ https://stackoverflow.com/questions/4327723/mongodb-limit-storage-size

3
  • Thank you for your detailed answer. Just out of curiosity, does MMAPv1 storage engine also create one file per collection and per index? Aug 10, 2018 at 17:12
  • I have not had a chance to work with MMAPv1. However I have created test environment to check and found that it works as per your expected format. There are no separate files for indexes and collections instead it creates dbname.0 file formatted files and create multiple files with growing amount of data. Results I have achieved so far are as follows: -rw------- 1 vagrant vagrant 64M Aug 11 17:18 test.0 -rw------- 1 vagrant vagrant 128M Aug 11 17:19 test.1 -rw------- 1 vagrant vagrant 256M Aug 11 17:19 test.2 Aug 11, 2018 at 17:24
  • hopefully your query is resolved, please consider upvoting the answer. Aug 13, 2018 at 14:15

Your Answer

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

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