ruby - Destroy dependent objects in Rails using one transaction -
please, optimize object destroing in rails application: have relatively big database, , when want delete user dependent objects removing takes > 1 minute. it's long. database has indexes field, used find data, without indexes takes > 5 minutes.
i see every 1 query takes little time: 0.1 - 1ms. there many queries. question is: how can tell rails remove related objects using 1 database transaction? think should speed operation , other operations too.
thanks
if want delete object , of it's dependancies, use destroy method:
post.last.destroy
if want destroy posts
, use destroy_all
method:
post.destroy_all
Comments
Post a Comment