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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -