# Bulk deleting / mass modifying users

**URL:** https://meta.discourse.org/t/bulk-deleting-mass-modifying-users/64362
**Category:** Support
**Created:** [6월 12, 2017, 3:50오후 UTC](https://meta.discourse.org/t/bulk-deleting-mass-modifying-users/64362 "2017-06-12T15:50:17Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jonathon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathon/32/265865_2.png) [@jonathon](https://meta.discourse.org/u/jonathon)
#### Post date: [2월 10, 2018, 1:06오후 UTC](https://meta.discourse.org/t/bulk-deleting-mass-modifying-users/64362/2 "2018-02-10T13:06:04Z")

</div>

A potentially more efficient way would be to select the users and delete as one transaction:

```ruby
User.joins(:user_stat).where("user_stats.post_count = 0 AND user_stats.topic_count = 0").destroy_all

```

See also:

> [@Bulk delete suspended users after import](https://meta.discourse.org/t/bulk-delete-suspended-users-after-import/73011/3):
>
> For that, you should enter into the container with ./launcher enter app Then, you will need to launch the [rails console](http://guides.rubyonrails.org/command_line.html#rails-console) with rails c Once you’re in the rails console, you can delete all suspended users who have zero posts and topics with User.joins(:user\_stat).where("users.suspended\_at IS NOT NULL AND user\_stats.topic\_count = 0 AND user\_stats.post\_count = 0").destroy\_all Always make sure you have latest db backup whenever you run destroy\_all method.

---

_[View the full topic](https://meta.discourse.org/t/bulk-deleting-mass-modifying-users/64362)._
