Search code examples
ruby-on-railsmongodbdisk

Why is MongoDB data saved when I remove all files from /data/db?


I just started using MonogDB with Rails 3. After doing some benchmarks, I found out that it performs 5-10 times faster than Postgresql/pg.

I decided to check how the data is stored, so I removed all the files from /data/db (that folder contained files like "mydb.0", "mydb.1" etc.

However I still can access data from my Rails app! Even after reloading the server.

So is there any kind of temp or cache folder with all the .json files with data?


Solution

    1. You can't delete 'data files' without stopping MongoDB.
    2. MongoDB uses caching, but in case when MongoDB was stopped cached date also emptied.
    3. If you stopped MongoDB and removed the data folder, the data is no longer accessible.
    4. MongoDB saves all data as bson, not as json.