# Efficiently Deleting An Account

**URL:** <https://www.ruby-forum.com/t/efficiently-deleting-an-account/137601>\
**Category:** Rails\
**Created:** [May 14, 2008, 3:38pm UTC](https://www.ruby-forum.com/t/efficiently-deleting-an-account/137601 "2008-05-14T15:38:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [May 14, 2008, 3:38pm UTC](https://www.ruby-forum.com/t/efficiently-deleting-an-account/137601/1 "2008-05-14T15:38:32Z")

</div>

The un-fun part of creating an app is making a way to delete a user’s  
account. Are people using :dependent or do people find it inefficient  
and  
that it create way too many locks? I am using exclusively :dependent =\>  
:destroy and it could take up to a minute to delete a user and I get a  
bunch  
of DB lock problems. What are other people doing? Does it make sense  
that  
I am getting these problems? Deleting even sometimes takes down my  
server… argh…  
I appreciate everyone’s feedback.

–  
John K.  
removed\_email\_address@domain.invalid

Blog: [http://www.kopanas.com](http://www.kopanas.com)  
Conference: [http://www.cusec.net](http://www.cusec.net)  
Twits: [http://www.twitter.com/kopanas](http://www.twitter.com/kopanas)

---

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [May 14, 2008, 5:31pm UTC](https://www.ruby-forum.com/t/efficiently-deleting-an-account/137601/2 "2008-05-14T17:31:25Z")

</div>

John K. wrote:

> The un-fun part of creating an app is making a way to delete a user’s  
> account. Are people using :dependent or do people find it inefficient  
> and  
> that it create way too many locks? I am using exclusively :dependent =\>  
> :destroy and it could take up to a minute to delete a user and I get a  
> bunch  
> of DB lock problems. What are other people doing? Does it make sense  
> that  
> I am getting these problems? Deleting even sometimes takes down my  
> server… argh…  
> I appreciate everyone’s feedback.
> 
> –  
> John K.  
> removed\_email\_address@domain.invalid
> 
> Blog: [http://www.kopanas.com](http://www.kopanas.com)  
> Conference: [http://www.cusec.net](http://www.cusec.net)  
> Twits: [http://www.twitter.com/kopanas](http://www.twitter.com/kopanas)

I am also using dependent =\> :destroy to delete a user and all their  
corresponding stuff, but I have never gotten a lock or crashed the  
server. My guess is that there might be other issues? Wish I could help  
more, but for me I have had no problems in terms of locks etc. How many  
hits are you getting on your app per day. The reason that I ask is that  
my app is just going into large scale use this past month and I am  
wondering if this might be a problem that I might encounter down the  
road? Good luck,

-S

---

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [May 14, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/efficiently-deleting-an-account/137601/3 "2008-05-14T17:34:26Z")

</div>

In most cases we avoid deleting at all.  
We just set a flag like “active” to false.

It’s just too dangerous to get inconsistent data.  
You would have to make sure, all data related to  
the user gets deleted. That’s not so difficult, depending  
on you project you can make this with :dependent =\> :destroy  
or manually. (If it takes down the server I guess you have  
defined something wrong)

But in most cases you don’t want to destroy this data.  
You can’t destroy old orders for example, since this  
would kill all statistics you may want to create.  
And you would end up with having money (paid for those orders)  
without knowing where it comes from.
