pg_reindex 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +2 -3
- data/bin/pgre +2 -3
- data/lib/pg-reindex.rb +4 -4
- data/pg_reindex.gemspec +1 -1
- data/spec/reindex_spec.rb +6 -0
- metadata +88 -94
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -46,8 +46,8 @@ Rebuild index produces sqls:
|
|
46
46
|
3. DROP INDEX bla;
|
47
47
|
4. ALTER INDEX bla2 RENAME TO bla;
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
2 can be blocked by long running query(LRQ), or autovacuum (in this case just kill autovacuum or wait LRQ).
|
50
|
+
By careful, if between 2 and (3,4) started LRQ or autovacuum, (3,4) can blocks all queries on this table. If this happens, and (3,4) not quit after < 30s, should stop (3,4) by cancel query in PostgreSQL. And execute (3,4) manually.
|
51
51
|
|
52
52
|
|
53
53
|
Rebuild pkey produces sqls:
|
@@ -59,5 +59,4 @@ Rebuild pkey produces sqls:
|
|
59
59
|
Same issue with 2 and 3.
|
60
60
|
|
61
61
|
|
62
|
-
|
63
62
|
MIT-LICENCE
|
data/bin/pgre
CHANGED
@@ -98,7 +98,7 @@ private
|
|
98
98
|
if File.exists?(file)
|
99
99
|
YAML.load_file(file)
|
100
100
|
else
|
101
|
-
say "Specify path to database.yml with env
|
101
|
+
say "Specify path to database.yml with env PGRE_CFG, like: PGRE_CFG=/../../database.yml pgre ...", :red
|
102
102
|
exit 1
|
103
103
|
end
|
104
104
|
end
|
@@ -140,7 +140,7 @@ private
|
|
140
140
|
|
141
141
|
if row['index'].end_with?("_pkey")
|
142
142
|
unless conn.check_swap_for_pkey
|
143
|
-
say " ... You should install function swap_for_pkey for rebuild pkey, call: #{$0} install ENV", :red
|
143
|
+
say " ... You should install function swap_for_pkey for rebuild pkey, call: #{$0} install ENV\n", :red
|
144
144
|
return
|
145
145
|
end
|
146
146
|
end
|
@@ -188,7 +188,6 @@ private
|
|
188
188
|
say "#{f['size_p'].ljust(off2)}", :yellow, false
|
189
189
|
say "#{f['total_i_size_p'].ljust(off3)}", :yellow, true
|
190
190
|
#say "#{f['total_size_p']}", :yellow
|
191
|
-
|
192
191
|
|
193
192
|
indexes.each do |rel|
|
194
193
|
say " #{(rel['index']+" ").ljust(off1 - 2 + off2, '.')}", nil, false
|
data/lib/pg-reindex.rb
CHANGED
@@ -141,13 +141,13 @@ $$language plpgsql;
|
|
141
141
|
|
142
142
|
if name.end_with?('_pkey')
|
143
143
|
[
|
144
|
-
index_sql(
|
144
|
+
index_sql(oid, name, new_name),
|
145
145
|
"ANALYZE #{table}",
|
146
146
|
"SELECT swap_for_pkey('public', '#{name}', '#{new_name}')"
|
147
147
|
]
|
148
148
|
else
|
149
149
|
[
|
150
|
-
index_sql(
|
150
|
+
index_sql(oid, name, new_name),
|
151
151
|
"ANALYZE #{table}",
|
152
152
|
"DROP INDEX #{name}",
|
153
153
|
"ALTER INDEX #{new_name} RENAME TO #{name}"
|
@@ -155,8 +155,8 @@ $$language plpgsql;
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
def index_sql(
|
159
|
-
str = index_def(oid).
|
158
|
+
def index_sql(oid, name, new_name)
|
159
|
+
str = index_def(oid).sub(name, new_name)
|
160
160
|
|
161
161
|
pos = str.index(new_name)
|
162
162
|
|
data/pg_reindex.gemspec
CHANGED
data/spec/reindex_spec.rb
CHANGED
@@ -77,6 +77,12 @@ describe PgReindex do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
it "index_sql with save name" do
|
81
|
+
@pgre.stub!(:index_def).and_return("CREATE INDEX locked_by ON delayed_jobs USING btree (locked_by)")
|
82
|
+
sql = @pgre.index_sql(0, "locked_by", "locked_by_2")
|
83
|
+
sql.should == "CREATE INDEX CONCURRENTLY locked_by_2 ON delayed_jobs USING btree (locked_by)"
|
84
|
+
end
|
85
|
+
|
80
86
|
it "index def" do
|
81
87
|
r = row('a_b_c')
|
82
88
|
@pgre.index_def(r['index_oid']).should == "CREATE UNIQUE INDEX a_b_c ON tests USING btree (a, b, c) WHERE ((a > 0) AND (b < 0))"
|
metadata
CHANGED
@@ -1,101 +1,104 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_reindex
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 0.1.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Makarchev Konstantin
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: thor
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: pg
|
36
23
|
prerelease: false
|
37
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: pg
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
38
33
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
46
38
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: rspec
|
50
39
|
prerelease: false
|
51
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
52
49
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
version: "0"
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
60
54
|
type: :development
|
61
|
-
version_requirements: *id003
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rake
|
64
55
|
prerelease: false
|
65
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
57
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
74
70
|
type: :development
|
75
|
-
version_requirements: *id004
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: activerecord
|
78
71
|
prerelease: false
|
79
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
73
|
none: false
|
81
|
-
requirements:
|
82
|
-
- -
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: activerecord
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
88
86
|
type: :development
|
89
|
-
|
90
|
-
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Console utility for gracefully rebuild indexes/pkeys for PostgreSQL,
|
95
|
+
with minimal locking in semi-auto mode.
|
91
96
|
email: kostya27@gmail.com
|
92
|
-
executables:
|
97
|
+
executables:
|
93
98
|
- pgre
|
94
99
|
extensions: []
|
95
|
-
|
96
100
|
extra_rdoc_files: []
|
97
|
-
|
98
|
-
files:
|
101
|
+
files:
|
99
102
|
- .gitignore
|
100
103
|
- Gemfile
|
101
104
|
- Gemfile.lock
|
@@ -110,36 +113,27 @@ files:
|
|
110
113
|
- spec/spec_support.rb
|
111
114
|
homepage: http://github.com/kostya/pg_reindex
|
112
115
|
licenses: []
|
113
|
-
|
114
116
|
post_install_message:
|
115
117
|
rdoc_options: []
|
116
|
-
|
117
|
-
require_paths:
|
118
|
+
require_paths:
|
118
119
|
- lib
|
119
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
121
|
none: false
|
121
|
-
requirements:
|
122
|
-
- -
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
|
125
|
-
|
126
|
-
- 0
|
127
|
-
version: "0"
|
128
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
127
|
none: false
|
130
|
-
requirements:
|
131
|
-
- -
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
|
134
|
-
segments:
|
135
|
-
- 0
|
136
|
-
version: "0"
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
137
132
|
requirements: []
|
138
|
-
|
139
133
|
rubyforge_project:
|
140
134
|
rubygems_version: 1.8.24
|
141
135
|
signing_key:
|
142
136
|
specification_version: 3
|
143
|
-
summary: Console utility for gracefully rebuild indexes/pkeys for PostgreSQL, with
|
137
|
+
summary: Console utility for gracefully rebuild indexes/pkeys for PostgreSQL, with
|
138
|
+
minimal locking in semi-auto mode.
|
144
139
|
test_files: []
|
145
|
-
|