-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I've got a class that looks like this:
class Person include Mongoid::Document has_many :lots_of_freaking_documents, dependent: :delete # ^ about a 500k documents related to this person. end
When I do this:
person = Person.find(...) person.destroy
Instead of just deleting all of of the "lots_of_many_freaking_documents" based on the person_id field, Mongoid seems to be iterating through the "lots_of_many_freaking_documents" relationship, loading them and one by one removing them from the collection, which takes it a very, very long time.
Shouldn't Mongoid just be doing the equivalent of person.lots_of_many_freaking_documents.delete_all for this kind of dependent behavior? Am I missing something here with how this is supposed to work?