Mongo removes and inserts vs update

I am using mongo version 3.0 db and java driver. I have a collection of over 100,000 entries. Each day there will be about 500 updates and about 500 inserts to be performed in the package. I will get updated documents with old fields plus some new ones that I have to keep. I do not know which feilds have recently been added also for each field. I support the final statistics. Since I don’t know what the changes were, I will need to get the records that already exist in order to see the difference between the updated and the new ones, in order to set up the summary statistics accordingly. Therefore, I need materials on how to do this effectively.

Should I delete existing records and insert them again or should I update 500 records. And I should consider using 1000 upgrades if it has potential benefits.

An example UseCase initial entry contains: f = [185, 75, 186]. I get an update request as f = [185, 75, 186, 1, 2, 3] for the same record. Also, the summary statistics mentioned above stores identifier counts by f. Thus, the calculations for 1,2,3 will be increased, and for 185, 75, 186 will remain the same.

+4
source share
2 answers

Upserts are used to add a document if it does not exist. So, if you are expecting new documents, then yes, install {upsert: true}.

, , - , mongo (, ). , . , .

mongo, collection, (, ), , . / collection , .

0

Mongo oplog.rs capped db. tailable cursor oplog.rs timestamp, db/collection . , . , . http://docs.mongodb.org/manual/reference/glossary/#term-oplog

0

All Articles