{"id":13880314,"url":"https://github.com/ankane/delete_in_batches","last_synced_at":"2025-07-16T16:31:32.414Z","repository":{"id":13609584,"uuid":"16302590","full_name":"ankane/delete_in_batches","owner":"ankane","description":"Fast batch deletes for Active Record and Postgres","archived":true,"fork":false,"pushed_at":"2022-12-30T17:52:33.000Z","size":30,"stargazers_count":201,"open_issues_count":0,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-14T03:19:18.138Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ankane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-28T05:01:24.000Z","updated_at":"2025-02-23T09:12:48.000Z","dependencies_parsed_at":"2023-01-13T17:33:21.726Z","dependency_job_id":null,"html_url":"https://github.com/ankane/delete_in_batches","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ankane/delete_in_batches","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdelete_in_batches","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdelete_in_batches/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdelete_in_batches/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdelete_in_batches/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/delete_in_batches/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fdelete_in_batches/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265524632,"owners_count":23782016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:02:56.324Z","updated_at":"2025-07-16T16:31:32.045Z","avatar_url":"https://github.com/ankane.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# delete_in_batches\n\n:fire: Fast batch deletes for Active Record and Postgres\n\n[![Build Status](https://github.com/ankane/delete_in_batches/workflows/build/badge.svg?branch=master)](https://github.com/ankane/delete_in_batches/actions)\n\n## Installation\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem 'delete_in_batches'\n```\n\n## How to Use\n\nDelete rows in batches\n\n```ruby\nTweet.where(user_id: 1).delete_in_batches\n```\n\n**Important:** Be sure to test your query before running it in production\n\nChange the batch size\n\n```ruby\nTweet.where(user_id: 1).delete_in_batches(batch_size: 50000) # defaults to 10000\n```\n\nSleep between batches\n\n```ruby\nTweet.where(user_id: 1).delete_in_batches(sleep: 0.01)\n```\n\nShow progress\n\n```ruby\nTweet.where(user_id: 1).delete_in_batches do\n  puts \"Another batch deleted\"\nend\n```\n\nWorks with associations\n\n```ruby\nuser.tweets.delete_in_batches\n```\n\nTo delete all rows in a table, `TRUNCATE` is fastest.\n\n```ruby\nActiveRecord::Base.connection.execute(\"TRUNCATE tweets\")\n```\n\n## History\n\nView the [changelog](https://github.com/ankane/delete_in_batches/blob/master/CHANGELOG.md)\n\n**Note:** This project originally had the description “the fastest way to delete 100k+ rows with ActiveRecord” but a single `DELETE` statement will likely be faster. See [this discussion](https://github.com/ankane/delete_in_batches/issues/4) for more details.\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/delete_in_batches/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/delete_in_batches/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\nTo get started with development:\n\n```sh\ngit clone https://github.com/ankane/delete_in_batches.git\ncd delete_in_batches\nbundle install\nbundle exec rake test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fdelete_in_batches","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Fdelete_in_batches","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fdelete_in_batches/lists"}