rails/rails — pull request #15842 by rahulk1000 (2014-06-20 19:36:32+00:00)
Title: Optimize dependent destroy on a has many

https://gist.github.com/rahulk1000/10a67737f231a14fb9fa

See the gist above for reference:
When the car object gets destroyed, each of its 10,000 parts will gets destroyed individually which is quite cumbersome. This change makes the dependent destroy smarter so that it deletes them with SQL instead when the associated object has no destroy callbacks on it. It does not make sense to call destroy on each object is it has no destroy call backs.