pgdexter 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/dexter/client.rb +3 -2
- data/lib/dexter/index_creator.rb +7 -2
- data/lib/dexter/indexer.rb +1 -1
- data/lib/dexter/sources/statement_source.rb +5 -3
- data/lib/dexter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e926f9a4b3e7f95a7e1d95813901d689795efa42edf9690872f3caf04477020
|
|
4
|
+
data.tar.gz: 1039ccc8c6184a5f09899dd8243f3852aae738a8ecc317c8302ea10db66b1d5d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9cb24cb4005250306fee1e6c20003e3a922d72b21bd91bb1d5ea0a00a3fefee46baf51e2d48d58085783993c0a5ce405c589af0140865d87c0e54de353d2baea
|
|
7
|
+
data.tar.gz: adcce320a6c5713ead81f0d18d6d8332f4392854ed9eac086e58e50f3f4af18e4f411a922ce3cbc6d8c2ae3595662e6ed1c7d32d064c25672f55a5b75d2b1a69
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -253,7 +253,7 @@ And run it with:
|
|
|
253
253
|
docker run -ti ankane/dexter <connection-options>
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
For databases on the host machine, use `host.docker.internal` as the hostname (on Linux, this requires
|
|
256
|
+
For databases on the host machine, use `host.docker.internal` as the hostname (on Linux, this requires `--add-host=host.docker.internal:host-gateway`).
|
|
257
257
|
|
|
258
258
|
### Homebrew
|
|
259
259
|
|
data/lib/dexter/client.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Dexter
|
|
|
23
23
|
connection.setup(options[:enable_hypopg])
|
|
24
24
|
|
|
25
25
|
source =
|
|
26
|
-
if options[:statement]
|
|
26
|
+
if options[:statement].any?
|
|
27
27
|
# TODO raise error for --interval, --min-calls, --min-time
|
|
28
28
|
StatementSource.new(options[:statement])
|
|
29
29
|
elsif options[:pg_stat_statements]
|
|
@@ -63,7 +63,7 @@ module Dexter
|
|
|
63
63
|
o.boolean "--pg-stat-activity", "use pg_stat_activity", default: false
|
|
64
64
|
o.boolean "--pg-stat-statements", "use pg_stat_statements", default: false, help: false
|
|
65
65
|
o.boolean "--stdin", "use stdin", default: false
|
|
66
|
-
o.
|
|
66
|
+
o.array "-s", "--statement", "process a single statement", delimiter: nil
|
|
67
67
|
o.separator ""
|
|
68
68
|
|
|
69
69
|
o.separator "Connection options:"
|
|
@@ -88,6 +88,7 @@ module Dexter
|
|
|
88
88
|
o.integer "--min-cost", default: 100, help: false
|
|
89
89
|
o.integer "--min-cost-savings-pct", default: 50, help: false
|
|
90
90
|
o.string "--tablespace", "tablespace to create indexes"
|
|
91
|
+
o.boolean "--non-concurrently", "use non-concurrent index creation", default: false
|
|
91
92
|
o.separator ""
|
|
92
93
|
|
|
93
94
|
o.separator "Logging options:"
|
data/lib/dexter/index_creator.rb
CHANGED
|
@@ -2,11 +2,12 @@ module Dexter
|
|
|
2
2
|
class IndexCreator
|
|
3
3
|
include Logging
|
|
4
4
|
|
|
5
|
-
def initialize(connection, indexer, new_indexes, tablespace)
|
|
5
|
+
def initialize(connection, indexer, new_indexes, tablespace, concurrently)
|
|
6
6
|
@connection = connection
|
|
7
7
|
@indexer = indexer
|
|
8
8
|
@new_indexes = new_indexes
|
|
9
9
|
@tablespace = tablespace
|
|
10
|
+
@concurrently = concurrently
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
# 1. create lock
|
|
@@ -17,7 +18,9 @@ module Dexter
|
|
|
17
18
|
with_advisory_lock do
|
|
18
19
|
@new_indexes.each do |index|
|
|
19
20
|
unless index_exists?(index)
|
|
20
|
-
statement = String.new("CREATE INDEX
|
|
21
|
+
statement = String.new("CREATE INDEX")
|
|
22
|
+
statement << " CONCURRENTLY" if @concurrently
|
|
23
|
+
statement << " ON #{@connection.quote_ident(index[:table])} (#{index[:columns].map { |c| @connection.quote_ident(c) }.join(", ")})"
|
|
21
24
|
statement << " TABLESPACE #{@connection.quote_ident(@tablespace)}" if @tablespace
|
|
22
25
|
log "Creating index: #{statement}"
|
|
23
26
|
started_at = monotonic_time
|
|
@@ -26,6 +29,8 @@ module Dexter
|
|
|
26
29
|
log "Index created: #{((monotonic_time - started_at) * 1000).to_i} ms"
|
|
27
30
|
rescue PG::LockNotAvailable
|
|
28
31
|
log "Could not acquire lock: #{index[:table]}"
|
|
32
|
+
rescue PG::FeatureNotSupported => e
|
|
33
|
+
raise Error, e.message
|
|
29
34
|
end
|
|
30
35
|
end
|
|
31
36
|
end
|
data/lib/dexter/indexer.rb
CHANGED
|
@@ -61,7 +61,7 @@ module Dexter
|
|
|
61
61
|
show_debug_info(new_indexes, queries) if @log_level.start_with?("debug")
|
|
62
62
|
|
|
63
63
|
# create new indexes
|
|
64
|
-
IndexCreator.new(@connection, self, new_indexes, @tablespace).perform if @create && new_indexes.any?
|
|
64
|
+
IndexCreator.new(@connection, self, new_indexes, @tablespace, !@options[:non_concurrently]).perform if @create && new_indexes.any?
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
private
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
module Dexter
|
|
2
2
|
class StatementSource
|
|
3
|
-
def initialize(
|
|
4
|
-
@
|
|
3
|
+
def initialize(statements)
|
|
4
|
+
@statements = statements
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
def perform(collector)
|
|
8
|
-
|
|
8
|
+
@statements.each do |statement|
|
|
9
|
+
collector.add(statement, 0, 0, true)
|
|
10
|
+
end
|
|
9
11
|
end
|
|
10
12
|
end
|
|
11
13
|
end
|
data/lib/dexter/version.rb
CHANGED