hi Soorya,
Since I was doing all the write operation in a single large collection, the write performance was slow and also using index on that.
May I know what led you to believe of the slow performance? I.e. metrics and tools you used. Collection size itself usually does not incur performance degradation.
There are a number of factors that may impact performance, such as inappropriate indexing strategies, hardware availability, or the number of open database connections.
For more performance related topics, see Analysing MongoDB Performance. You can also utilise mtools to help with slow queries analysis.
Instead of writing in the single larger collection, If I write in the temporary collection and then I move it larger collection using the below query, … Will it be quick to copy into the larger collection?
Depending on your use case, as you still need to consolidate the temporary collection into the large collection eventually, this may not be a good solution. You need to figure out the root cause of the performance issue.
$out is replacing completely the collection.Is there way to add it without replacing it?.
$out
always replace the whole collection.
Regards,
Lungang