delete_in_batches 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/LICENSE.txt +1 -1
- data/README.md +16 -19
- data/lib/delete_in_batches.rb +7 -2
- data/lib/delete_in_batches/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f67278c3ef5c894ad549056a5f5b877e69742eb830b69aa1e468da9b109705f
|
4
|
+
data.tar.gz: 4aee16921a6b72a72b392a46bd03f69c6de5b939ffa9c1fd1f17f9f0d3933da6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 386a6ed82ebdc123f9f286abeb4d0f15645a3d82ee013c48058ba9b230cfb1b05d4ccca2306bc0b06e3568c9e9cb5a22bd2f26c1cfb978ff083997111703e315
|
7
|
+
data.tar.gz: 2d17af5375794e73ed3e2c8a41a3b5b8fc96f2e8807905194970fc79b63e500df5799618d3daf8bf560cba619534be8d71fd131813deb43fe043e3c56d924259
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
## 0.2.0 (2020-05-27)
|
2
|
+
|
3
|
+
- Improved Active Record integration
|
4
|
+
- Dropped support for Rails < 5
|
5
|
+
|
6
|
+
## 0.1.0 (2018-09-05)
|
7
|
+
|
8
|
+
- Added support for MySQL
|
9
|
+
|
10
|
+
## 0.0.2 (2014-01-27)
|
11
|
+
|
12
|
+
- Added missing dependency
|
13
|
+
|
14
|
+
## 0.0.1 (2014-01-27)
|
15
|
+
|
16
|
+
- First release
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
|
3
3
|
:fire: The fastest way to delete 100k+ rows with ActiveRecord
|
4
4
|
|
5
|
-
|
5
|
+
[![Build Status](https://travis-ci.org/ankane/delete_in_batches.svg?branch=master)](https://travis-ci.org/ankane/delete_in_batches)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application’s Gemfile:
|
6
10
|
|
7
11
|
```ruby
|
8
|
-
|
12
|
+
gem 'delete_in_batches'
|
9
13
|
```
|
10
14
|
|
11
|
-
[![Build Status](https://travis-ci.org/ankane/delete_in_batches.svg?branch=master)](https://travis-ci.org/ankane/delete_in_batches)
|
12
|
-
|
13
15
|
## Slow
|
14
16
|
|
15
17
|
```ruby
|
@@ -19,7 +21,16 @@ Tweet.where(user_id: 1).delete_all
|
|
19
21
|
|
20
22
|
The database performs the delete in a transaction - either all the records are deleted (query completes) or none are, due to [multiversion concurrency control](http://en.wikipedia.org/wiki/Multiversion_concurrency_control).
|
21
23
|
|
22
|
-
##
|
24
|
+
## Faster
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
Tweet.where(user_id: 1).in_batches(of: 10000).delete_all
|
28
|
+
# SELECT tweets.id FROM tweets WHERE user_id = 1 ORDER BY id LIMIT 1000
|
29
|
+
# DELETE FROM tweets WHERE user_id = 1 AND id IN (1, 2, 3, ...)
|
30
|
+
# ...
|
31
|
+
```
|
32
|
+
|
33
|
+
## Fastest
|
23
34
|
|
24
35
|
```ruby
|
25
36
|
Tweet.where(user_id: 1).delete_in_batches
|
@@ -56,20 +67,6 @@ To delete all rows in a table, `TRUNCATE` is fastest.
|
|
56
67
|
ActiveRecord::Base.connection.execute("TRUNCATE tweets")
|
57
68
|
```
|
58
69
|
|
59
|
-
## Installation
|
60
|
-
|
61
|
-
Add this line to your application’s Gemfile:
|
62
|
-
|
63
|
-
```ruby
|
64
|
-
gem "delete_in_batches"
|
65
|
-
```
|
66
|
-
|
67
|
-
And then execute:
|
68
|
-
|
69
|
-
```sh
|
70
|
-
bundle
|
71
|
-
```
|
72
|
-
|
73
70
|
## Contributing
|
74
71
|
|
75
72
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
data/lib/delete_in_batches.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# dependencies
|
2
|
+
require "active_support"
|
3
|
+
|
4
|
+
# modules
|
1
5
|
require "delete_in_batches/version"
|
2
|
-
require "active_record"
|
3
6
|
|
4
7
|
module DeleteInBatches
|
5
8
|
def delete_in_batches(options = {})
|
@@ -19,4 +22,6 @@ module DeleteInBatches
|
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
|
-
|
25
|
+
ActiveSupport.on_load(:active_record) do
|
26
|
+
extend DeleteInBatches
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delete_in_batches
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +86,7 @@ executables: []
|
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
|
+
- CHANGELOG.md
|
89
90
|
- LICENSE.txt
|
90
91
|
- README.md
|
91
92
|
- lib/delete_in_batches.rb
|
@@ -102,15 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
103
|
requirements:
|
103
104
|
- - ">="
|
104
105
|
- !ruby/object:Gem::Version
|
105
|
-
version: '2.
|
106
|
+
version: '2.4'
|
106
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
108
|
requirements:
|
108
109
|
- - ">="
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: '0'
|
111
112
|
requirements: []
|
112
|
-
|
113
|
-
rubygems_version: 2.7.7
|
113
|
+
rubygems_version: 3.1.2
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: The fastest way to delete 100k+ rows with ActiveRecord
|