rails-pg-extras 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c107fe728b02513bceaa617c45f5cf5bc4048fb0376ec46a13a70ba86cff4cf9
4
- data.tar.gz: 07fd71c6c2a1ff119b30845f32967d4d2c49d8ae0eccfbdaf52b228b5c907541
3
+ metadata.gz: 91474e6c121e4a84110dd1b7fb9724012627696625d08ce73c38eb27b0398636
4
+ data.tar.gz: 50971a690cc8b350d1caf20d43776c7ff6b1927d394e55316a2203e9a00b1d72
5
5
  SHA512:
6
- metadata.gz: d9de7a07381f8d203e60f98b750b0791e7be932dfaf8a621106bc69bbe44eb4ce5ca0893e4d8b22905913626f28bedc77da7fad282c4171ea51e3b424c359984
7
- data.tar.gz: 99872d4b0efcddf6d4a0af106068fc2a83544053c13596c2532320ac746a3ca6174d7ff1fd8e3a8c2533b49acaeaac896bbf6def5bc1f5dc083e6956b9cf52f9
6
+ metadata.gz: 3880fcea5eed8f047dcbfc733836b8f93f220b139a96a6b20f64e11f90de338fa0489b7644fc632df2b6947332692c4a78ec17f35124a7eb4f5a7931cfb2dab6
7
+ data.tar.gz: 148f28f307696d2d08acb81d4c61b8ed75bfc31823670bcd669b12a9eb37593d1081a0fe8959a6f11622426f3a4021b0226d99728f61be751915a6f7a7b57ad2
data/.circleci/config.yml CHANGED
@@ -6,7 +6,22 @@ jobs:
6
6
  environment:
7
7
  DATABASE_URL: postgresql://postgres:secret@localhost:5432/rails-pg-extras-test
8
8
  - image: circleci/postgres:11.5
9
- command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c max_connections=200
9
+ command: postgres -c shared_preload_libraries=pg_stat_statements
10
+ name: postgres11
11
+ environment:
12
+ POSTGRES_USER: postgres
13
+ POSTGRES_DB: rails-pg-extras-test
14
+ POSTGRES_PASSWORD: secret
15
+ - image: circleci/postgres:12.7
16
+ command: postgres -c shared_preload_libraries=pg_stat_statements
17
+ name: postgres12
18
+ environment:
19
+ POSTGRES_USER: postgres
20
+ POSTGRES_DB: rails-pg-extras-test
21
+ POSTGRES_PASSWORD: secret
22
+ - image: circleci/postgres:13.3
23
+ command: postgres -c shared_preload_libraries=pg_stat_statements
24
+ name: postgres13
10
25
  environment:
11
26
  POSTGRES_USER: postgres
12
27
  POSTGRES_DB: rails-pg-extras-test
@@ -17,13 +32,24 @@ jobs:
17
32
  - run: gem update --system
18
33
  - run: gem install bundler
19
34
  - run: bundle install --path vendor/bundle
20
- - run: sudo apt-get update
35
+ - run: sudo apt-get update --allow-releaseinfo-change
21
36
  - run: sudo apt install postgresql-client
22
- - run: dockerize -wait tcp://localhost:5432 -timeout 1m
37
+ - run: dockerize -wait tcp://postgres11:5432 -timeout 1m
38
+ - run:
39
+ name: Run specs for PG 11
40
+ environment:
41
+ DATABASE_URL: postgresql://postgres:secret@postgres11:5432/rails-pg-extras-test
42
+ command: bundle exec rspec spec/
43
+ - run:
44
+ name: Run specs for PG 12
45
+ environment:
46
+ DATABASE_URL: postgresql://postgres:secret@postgres12:5432/rails-pg-extras-test
47
+ command: bundle exec rspec spec/
23
48
  - run:
24
- name: Run specs
25
- command: |
26
- bundle exec rspec spec/
49
+ name: Run specs for PG 13
50
+ environment:
51
+ DATABASE_URL: postgresql://postgres:secret@postgres13:5432/rails-pg-extras-test
52
+ command: bundle exec rspec spec/
27
53
  workflows:
28
54
  version: 2
29
55
  test:
data/README.md CHANGED
@@ -4,7 +4,13 @@ Rails port of [Heroku PG Extras](https://github.com/heroku/heroku-pg-extras) wit
4
4
 
5
5
  Included rake tasks and Ruby methods can be used to obtain information about a Postgres instance, that may be useful when analyzing performance issues. This includes information about locks, index usage, buffer cache hit ratios and vacuum statistics. Ruby API enables developers to easily integrate the tool into e.g. automatic monitoring tasks.
6
6
 
7
- You can check out this blog post for detailed step by step tutorial on how to [optimize PostgreSQL using PG Extras library](https://pawelurbanek.com/postgresql-fix-performance).
7
+ You can read this blog post for detailed step by step tutorial on how to [optimize PostgreSQL using PG Extras library](https://pawelurbanek.com/postgresql-fix-performance).
8
+
9
+ **Shameless plug:** rails-pg-extras is one of the tools that I use when conducting Rails performance audits. [Check out my offer](https://pawelurbanek.com/#rails-performance-tuning) if you need help with fine-tuning your app.
10
+
11
+ Use [rails-pg-extras-web](https://github.com/defkode/rails-pg-extras-web) if you want to see SQL metrics in the UI instead of a command line interface.
12
+
13
+ ![Web interface](https://github.com/pawurb/rails-pg-extras/raw/master/rails-pg-extras-web.png)
8
14
 
9
15
  Alternative versions:
10
16
 
@@ -394,6 +400,19 @@ This command displays indexes that have < 50 scans recorded against them, and ar
394
400
 
395
401
  [More info](https://pawelurbanek.com/postgresql-fix-performance#unused-indexes)
396
402
 
403
+ ### `duplicate_indexes`
404
+
405
+ ```ruby
406
+
407
+ RailsPGExtras.duplicate_indexes
408
+
409
+ | size | idx1 | idx2 | idx3 | idx4 |
410
+ +------------+--------------+----------------+----------+-----------+
411
+ | 128 k | users_pkey | index_users_id | | |
412
+ ```
413
+
414
+ This command displays multiple indexes that have the same set of columns, same opclass, expression and predicate - which make them equivalent. Usually it's safe to drop one of them.
415
+
397
416
  ### `null_indexes`
398
417
 
399
418
  ```ruby
@@ -565,6 +584,14 @@ $ rake pg_extras:mandelbrot
565
584
 
566
585
  This command outputs the Mandelbrot set, calculated through SQL.
567
586
 
587
+ ## Testing
588
+
589
+ ```bash
590
+ cp docker-compose.yml.sample docker-compose.yml
591
+ docker compose up -d
592
+ rake test_all
593
+ ```
594
+
568
595
  ## Query sources
569
596
 
570
597
  - [https://github.com/heroku/heroku-pg-extras](https://github.com/heroku/heroku-pg-extras)
data/Rakefile CHANGED
@@ -3,3 +3,8 @@ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
+ desc 'Test all PG versions'
7
+ task :test_all do
8
+ system("PG_VERSION=11 bundle exec rspec spec/ && PG_VERSION=12 bundle exec rspec spec/ && PG_VERSION=13 bundle exec rspec spec/")
9
+ end
10
+
@@ -3,7 +3,7 @@ version: '3'
3
3
  services:
4
4
  postgres11:
5
5
  image: postgres:11.5-alpine
6
- command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c max_connections=200
6
+ command: postgres -c shared_preload_libraries=pg_stat_statements
7
7
  environment:
8
8
  POSTGRES_USER: postgres
9
9
  POSTGRES_DB: rails-pg-extras-test
@@ -12,7 +12,7 @@ services:
12
12
  - '5432:5432'
13
13
  postgres12:
14
14
  image: postgres:12.7-alpine
15
- command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c max_connections=200
15
+ command: postgres -c shared_preload_libraries=pg_stat_statements
16
16
  environment:
17
17
  POSTGRES_USER: postgres
18
18
  POSTGRES_DB: rails-pg-extras-test
@@ -21,7 +21,7 @@ services:
21
21
  - '5433:5432'
22
22
  postgres13:
23
23
  image: postgres:13.3-alpine
24
- command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c max_connections=200
24
+ command: postgres -c shared_preload_libraries=pg_stat_statements
25
25
  environment:
26
26
  POSTGRES_USER: postgres
27
27
  POSTGRES_DB: rails-pg-extras-test
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPGExtras
4
- VERSION = "2.0.0"
4
+ VERSION = "2.1.0"
5
5
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-pg-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2021-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-pg-extras
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: 2.1.0
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: 2.0.0
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +86,7 @@ files:
86
86
  - lib/rails-pg-extras/railtie.rb
87
87
  - lib/rails-pg-extras/tasks/all.rake
88
88
  - lib/rails-pg-extras/version.rb
89
+ - rails-pg-extras-web.png
89
90
  - rails-pg-extras.gemspec
90
91
  - spec/smoke_spec.rb
91
92
  - spec/spec_helper.rb