ruby on rails - Destroying some records takes a really, really long time -
i have product
model has_many
productattributes
in rails 4.2.3 application.
a product
can have on 10,000 producattributes sometimes.
i need delete of these products, when call destroy
on product, takes really, long time. looks gets list of ids productattribute
, called delete on each 1 individually.
but when gets end, sort of hangs. have lot of data delete, , need this.
but can't have thing hang forever. have ctrl-c
, after time see rollback
happening.
my question is, in heck doing? why can't reliably delete lots of data application layer?
i suspect use like
has_many :product_attributes, dependent: :destroy
you might want using dependent: :delete
rails doesn't instantiate dependent records before destroying them individually.
the documentation have more information consequences (e.g. if callbacks executed on dependent models etc.)
Comments
Post a Comment