mongodb - mongo 3 duplicates on unique index - dropDups -
in documentation mongodb says: "changed in version 3.0: dropdups option no longer available."
is there can (other downgrading) if want create unique index , destroy duplicate entries?
please keep in mind receive 300 inserts per second can't delete duplicates , hope none come in time i'm done indexing.
yes dropdupes deprecated since version 2.7.5 because not possible predict correctly document deleted in process.
typically, have 2 options :
use new collection :
- create new collection,
 - create unique index on new collection,
 - run batch copy documents old collection new 1 , make sure ignore duplicated key error during process.
 
deal in own collection manually :
- make sure won't insert more duplicated documents in code,
 - run batch on collection delete duplicates (and make sure keep 1 if not identical),
 - then add unique index.
 
for particular case, recommend first option trick :
- create new collection unique index,
 - update code insert documents in both tables,
 - run batch copy documents old collection new 1 (ignore duplicated key error),
 - rename new collection match old name.
 - re-update code write in "old" collection
 
Comments
Post a Comment