pgdexter 0.3.10 → 0.4.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 +6 -0
- data/README.md +35 -5
- data/lib/dexter/indexer.rb +22 -13
- data/lib/dexter/processor.rb +1 -1
- data/lib/dexter/version.rb +1 -1
- data/lib/dexter.rb +1 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62ad383008579d8dbe952b3f96c827e01aa198c0eb74b3b884188472459b34b8
|
4
|
+
data.tar.gz: b77596742f0e13bb058354edcd901d1e93ec94f61bf6a695957c51fe9c7e41dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b5f18ce901729f9e22d4222b0ba7ee498be18edb7897221c28069f8beceb65058342c47e9211ce94814d04b380387b95506722b1568a1d44b4d3c8386beeb17
|
7
|
+
data.tar.gz: fa51ae2cde49dfcf9fc181a30bda4941c2ea01f1186fdd6a8cd002059a71c4b3341686cd62f2d1366874c941b92db1a4f74a6abd272baa66063907602e1376c5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,8 +12,8 @@ First, install [HypoPG](https://github.com/HypoPG/hypopg) on your database serve
|
|
12
12
|
|
13
13
|
```sh
|
14
14
|
cd /tmp
|
15
|
-
curl -L https://github.com/HypoPG/hypopg/archive/1.
|
16
|
-
cd hypopg-1.
|
15
|
+
curl -L https://github.com/HypoPG/hypopg/archive/1.3.1.tar.gz | tar xz
|
16
|
+
cd hypopg-1.3.1
|
17
17
|
make
|
18
18
|
make install # may need sudo
|
19
19
|
```
|
@@ -32,7 +32,7 @@ And install the command line tool with:
|
|
32
32
|
gem install pgdexter
|
33
33
|
```
|
34
34
|
|
35
|
-
The command line tool is also available as a [Linux package](guides/Linux.md).
|
35
|
+
The command line tool is also available with [Docker](#docker), [Homebrew](#homebrew), or as a [Linux package](guides/Linux.md).
|
36
36
|
|
37
37
|
## How to Use
|
38
38
|
|
@@ -190,7 +190,37 @@ dexter --log-sql --log-level debug2
|
|
190
190
|
|
191
191
|
## Hosted Postgres
|
192
192
|
|
193
|
-
Some hosted providers like Amazon RDS and Heroku do not support the HypoPG extension, which Dexter needs to run. See [how to use Dexter](guides/Hosted-Postgres.md) in these cases.
|
193
|
+
Some hosted providers like Amazon RDS and Heroku do not support the HypoPG extension, which Dexter needs to run. See [how to use Dexter](guides/Hosted-Postgres.md) in these cases. To request the extension:
|
194
|
+
|
195
|
+
- Amazon RDS - follow the instructions on [this page](https://aws.amazon.com/rds/postgresql/faqs/)
|
196
|
+
- Google Cloud SQL - star the [feature request](https://issuetracker.google.com/issues/69250435)
|
197
|
+
- DigitalOcean Managed Databases - follow the instructions on [this page](https://docs.digitalocean.com/products/databases/postgresql/details/supported-extensions/#supported-extensions)
|
198
|
+
|
199
|
+
## Additional Installation Methods
|
200
|
+
|
201
|
+
### Docker
|
202
|
+
|
203
|
+
Get the [Docker image](https://hub.docker.com/r/ankane/dexter) with:
|
204
|
+
|
205
|
+
```sh
|
206
|
+
docker pull ankane/dexter
|
207
|
+
```
|
208
|
+
|
209
|
+
And run it with:
|
210
|
+
|
211
|
+
```sh
|
212
|
+
docker run -ti ankane/dexter <connection-options>
|
213
|
+
```
|
214
|
+
|
215
|
+
On Mac and Windows, use `host.docker.internal` as the database hostname for databases on your local machine.
|
216
|
+
|
217
|
+
### Homebrew
|
218
|
+
|
219
|
+
With Homebrew, you can use:
|
220
|
+
|
221
|
+
```sh
|
222
|
+
brew install ankane/brew/dexter
|
223
|
+
```
|
194
224
|
|
195
225
|
## Future Work
|
196
226
|
|
@@ -213,7 +243,7 @@ gem specific_install https://github.com/ankane/dexter.git
|
|
213
243
|
|
214
244
|
## Thanks
|
215
245
|
|
216
|
-
This software wouldn’t be possible without [HypoPG](https://github.com/
|
246
|
+
This software wouldn’t be possible without [HypoPG](https://github.com/HypoPG/hypopg), which allows you to create hypothetical indexes, and [pg_query](https://github.com/lfittl/pg_query), which allows you to parse and fingerprint queries. A big thanks to Dalibo and Lukas Fittl respectively.
|
217
247
|
|
218
248
|
## Research
|
219
249
|
|
data/lib/dexter/indexer.rb
CHANGED
@@ -240,6 +240,7 @@ module Dexter
|
|
240
240
|
end
|
241
241
|
|
242
242
|
def find_columns(plan)
|
243
|
+
plan = JSON.parse(plan.to_json)
|
243
244
|
find_by_key(plan, "ColumnRef")
|
244
245
|
end
|
245
246
|
|
@@ -248,20 +249,24 @@ module Dexter
|
|
248
249
|
end
|
249
250
|
|
250
251
|
def find_by_key(plan, key)
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
252
|
+
result = []
|
253
|
+
queue = [plan]
|
254
|
+
while queue.any?
|
255
|
+
node = queue.pop
|
256
|
+
case node
|
257
|
+
when Hash
|
258
|
+
node.each do |k, v|
|
259
|
+
if k == key
|
260
|
+
result << v
|
261
|
+
elsif !v.nil?
|
262
|
+
queue << v
|
263
|
+
end
|
259
264
|
end
|
265
|
+
when Array
|
266
|
+
queue.concat(node)
|
260
267
|
end
|
261
|
-
when Array
|
262
|
-
indexes.concat(plan.flat_map { |v| find_by_key(v, key) })
|
263
268
|
end
|
264
|
-
|
269
|
+
result
|
265
270
|
end
|
266
271
|
|
267
272
|
def hypo_indexes_from_plan(index_name_to_columns, plan, index_set)
|
@@ -483,10 +488,10 @@ module Dexter
|
|
483
488
|
statement = String.new("CREATE INDEX CONCURRENTLY ON #{quote_ident(index[:table])} (#{index[:columns].map { |c| quote_ident(c) }.join(", ")})")
|
484
489
|
statement << " TABLESPACE #{quote_ident(@tablespace)}" if @tablespace
|
485
490
|
log "Creating index: #{statement}"
|
486
|
-
started_at =
|
491
|
+
started_at = monotonic_time
|
487
492
|
begin
|
488
493
|
execute(statement)
|
489
|
-
log "Index created: #{((
|
494
|
+
log "Index created: #{((monotonic_time - started_at) * 1000).to_i} ms"
|
490
495
|
rescue PG::LockNotAvailable
|
491
496
|
log "Could not acquire lock: #{index[:table]}"
|
492
497
|
end
|
@@ -498,6 +503,10 @@ module Dexter
|
|
498
503
|
new_indexes
|
499
504
|
end
|
500
505
|
|
506
|
+
def monotonic_time
|
507
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
508
|
+
end
|
509
|
+
|
501
510
|
def conn
|
502
511
|
@conn ||= begin
|
503
512
|
# set connect timeout if none set
|
data/lib/dexter/processor.rb
CHANGED
data/lib/dexter/version.rb
CHANGED
data/lib/dexter.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgdexter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slop
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: pg_query
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '2'
|
47
|
+
version: '2.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '2'
|
54
|
+
version: '2.1'
|
55
55
|
description:
|
56
56
|
email: andrew@ankane.org
|
57
57
|
executables:
|
@@ -87,14 +87,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '2.
|
90
|
+
version: '2.5'
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
|
-
rubygems_version: 3.
|
97
|
+
rubygems_version: 3.3.7
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: The automatic indexer for Postgres
|