ppn029012
ppn029012

Reputation: 570

A bad performance of upserting item to a million-document collection

It takes 700~800 ms to upsert an item into a collection, which is containing about 2 million documents. I have tried the functions as following,

Model.findOneAndUpdate()

bulk.find({...}).upsert().updateOne()

But both of them takes about almost 1 second to upsert ONE item.

I have another 1 million items to insert/upsert, so it will takes me several days. How can I improve it?

Upvotes: 0

Views: 49

Answers (1)

ppn029012
ppn029012

Reputation: 570

Adding an Index for the querying item will accelerate the process.

Upvotes: 1

Related Questions