I am currently using 3.2.1 mongo driver version
.
Use Case -
Write - Bulk Insert in Collection or per row insert
Read - Read on basis of _id
.
No extra indexes required, default index which mongodb creates on _id field is enough.
Problem - My Mongo Service (calling mongodb) is taking too much of CPU load.
1.) Does Mongodb creates indexes on _id field in background.
2.) If not do i need to make it create index in background to fasten the process. How can i do that programmatically.
Maybe something like this,
collection.createIndex(new BasicDBObject("_id", 1),new BasicDBObject("background", true));
I came across this link
Running an index in the background does not make inserting run faster, on the contrary, it runs slower. However, the query will be asynchronous, thus allowing your application to run other queries in the mean time.
You can try the following approaches to improve the performance on bulk inserts