1

I have 10 million documents in a mongo collection as of current_date and want to destroy 6 million documents which are older than yesterday.

Is there any bulk_delete option in mongoid ? I know I can bulk_insert as Mongo::my_collection.collection.insert(data) which fires only one insert command.

Similarly is there any way to bulk_delete in mongoid?

abhishek
  • 301
  • 2
  • 7
  • 18

1 Answers1

0

There is deleteMany command, but despite it's a single command, the execution time may be huge and load on your database while deletion will be significant if not to say more.

I would write a script, which will slowly destroy records by reasonable chunks (ie. by 1000 of records per request).

nattfodd
  • 1,790
  • 1
  • 17
  • 35