Urbanleg
Urbanleg

Reputation: 6542

mongoDB does a huge collection affects the preformance of other collections?

In my application I'm about to save some files on the DB. I've seen the debate whether to save on the filesystem \ db and chose to save the files on the database.

my database for the project is mongoDB.

I would like to know if i have lets say 20 collections in my mongoDB, and exactly one of them is extremely big. will i see a performance impact when i work on the other (less large) collections?

if So should i separate this collection from the other collections ? (create another DB for this huge collection alone)?

Does my-sql suffer from the same effect?

thanks.

Upvotes: 0

Views: 369

Answers (1)

Zaid Masud
Zaid Masud

Reputation: 13463

There are two key considerations here:

  1. Ensure that your working set fits in memory. This will mean that your available memory should exceed at least the total size of the indexes you use for your reads.
  2. MongoDB has a database level write lock after v2.2. This means that during any write operation, the entire database is locked for reads. So for large bulk inserts into a single collection that may take a while, all other collections are locked for the duration of the bulk insert. Therefore, if you separate your large collection into a separate database, your key advantage will be that inserts to that collection will not block reads to collections in other databases.

I'd suggest firstly ensuring that you have enough memory for your working set, and secondly I'd separate the large collection into a separate DB if you intend to write to it a lot.

Upvotes: 1

Related Questions