ruby-pg-extras 5.4.0 → 5.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +33 -30
- data/Rakefile +1 -1
- data/docker-compose.yml.sample +27 -10
- data/lib/ruby-pg-extras.rb +5 -0
- data/lib/ruby_pg_extras/queries/calls_17.sql +9 -0
- data/lib/ruby_pg_extras/queries/outliers_17.sql +10 -0
- data/lib/ruby_pg_extras/version.rb +1 -1
- data/spec/spec_helper.rb +8 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 809377163a6ca42ea4b8b0087e1d4ede8cfe326d0ee10a85a32df4d6f0e447f5
|
4
|
+
data.tar.gz: 295812fd83c470552c330bcf520749ebfcd6574270c7f2ee7d58d74c0877b968
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf48947fd5d74c8e7052cfcf9383521366887e22b7206cc4f830c91cbc17fa75db07279240d6a611febc0b7af6a9f03b9db7431b4a3b21cb80c416becaa13e2f
|
7
|
+
data.tar.gz: 1aa0b28a52a83e76f31a5101af38fa006f07ab2180980d3d149206925eba96ca76a7589cf194e534f621e32513fe7c313d45137933824a6600b86bb42295849d
|
data/.github/workflows/ci.yml
CHANGED
@@ -12,43 +12,52 @@ jobs:
|
|
12
12
|
strategy:
|
13
13
|
fail-fast: false
|
14
14
|
matrix:
|
15
|
-
ruby-version: ['3.2', '3.1', '3.0', '2.7', '2.6']
|
15
|
+
ruby-version: ['3.3', '3.2', '3.1', '3.0', '2.7', '2.6']
|
16
16
|
steps:
|
17
|
-
- uses: actions/checkout@
|
18
|
-
- name: Run PostgreSQL
|
17
|
+
- uses: actions/checkout@v4
|
18
|
+
- name: Run PostgreSQL 12
|
19
19
|
run: |
|
20
20
|
docker run --env POSTGRES_USER=postgres \
|
21
21
|
--env POSTGRES_DB=ruby-pg-extras-test \
|
22
22
|
--env POSTGRES_PASSWORD=secret \
|
23
|
-
-d -p 5432:5432 postgres:
|
23
|
+
-d -p 5432:5432 postgres:12.20-alpine \
|
24
24
|
postgres -c shared_preload_libraries=pg_stat_statements
|
25
|
-
- name: Run PostgreSQL
|
25
|
+
- name: Run PostgreSQL 13
|
26
26
|
run: |
|
27
27
|
docker run --env POSTGRES_USER=postgres \
|
28
28
|
--env POSTGRES_DB=ruby-pg-extras-test \
|
29
29
|
--env POSTGRES_PASSWORD=secret \
|
30
|
-
-d -p 5433:5432 postgres:
|
30
|
+
-d -p 5433:5432 postgres:13.16-alpine \
|
31
31
|
postgres -c shared_preload_libraries=pg_stat_statements
|
32
|
-
- name: Run PostgreSQL
|
32
|
+
- name: Run PostgreSQL 14
|
33
33
|
run: |
|
34
34
|
docker run --env POSTGRES_USER=postgres \
|
35
35
|
--env POSTGRES_DB=ruby-pg-extras-test \
|
36
36
|
--env POSTGRES_PASSWORD=secret \
|
37
|
-
-d -p 5434:5432 postgres:13
|
37
|
+
-d -p 5434:5432 postgres:14.13-alpine \
|
38
38
|
postgres -c shared_preload_libraries=pg_stat_statements
|
39
|
-
- name: Run PostgreSQL
|
39
|
+
- name: Run PostgreSQL 15
|
40
40
|
run: |
|
41
41
|
docker run --env POSTGRES_USER=postgres \
|
42
42
|
--env POSTGRES_DB=ruby-pg-extras-test \
|
43
43
|
--env POSTGRES_PASSWORD=secret \
|
44
|
-
-d -p 5435:5432 postgres:
|
44
|
+
-d -p 5435:5432 postgres:15.8-alpine \
|
45
45
|
postgres -c shared_preload_libraries=pg_stat_statements
|
46
|
-
|
46
|
+
sleep 15
|
47
|
+
- name: Run PostgreSQL 16
|
48
|
+
run: |
|
49
|
+
docker run --env POSTGRES_USER=postgres \
|
50
|
+
--env POSTGRES_DB=ruby-pg-extras-test \
|
51
|
+
--env POSTGRES_PASSWORD=secret \
|
52
|
+
-d -p 5436:5432 postgres:16.4-alpine \
|
53
|
+
postgres -c shared_preload_libraries=pg_stat_statements
|
54
|
+
sleep 15
|
55
|
+
- name: Run PostgreSQL 17
|
47
56
|
run: |
|
48
57
|
docker run --env POSTGRES_USER=postgres \
|
49
58
|
--env POSTGRES_DB=ruby-pg-extras-test \
|
50
59
|
--env POSTGRES_PASSWORD=secret \
|
51
|
-
-d -p
|
60
|
+
-d -p 5437:5432 postgres:17.0-alpine \
|
52
61
|
postgres -c shared_preload_libraries=pg_stat_statements
|
53
62
|
sleep 15
|
54
63
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
@@ -64,64 +73,58 @@ jobs:
|
|
64
73
|
bundle config set --local path 'vendor/bundle'
|
65
74
|
bundle install
|
66
75
|
sleep 10
|
67
|
-
- name: Run tests for PG
|
76
|
+
- name: Run tests for PG 12
|
68
77
|
env:
|
69
|
-
PG_VERSION:
|
78
|
+
PG_VERSION: 12
|
70
79
|
POSTGRES_HOST: localhost
|
71
80
|
POSTGRES_USER: postgres
|
72
81
|
POSTGRES_DB: ruby-pg-extras-test
|
73
82
|
POSTGRES_PASSWORD: secret
|
74
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5432/ruby-pg-extras-test
|
75
83
|
run: |
|
76
84
|
bundle exec rspec spec/
|
77
|
-
- name: Run tests for PG
|
85
|
+
- name: Run tests for PG 13
|
78
86
|
env:
|
79
|
-
PG_VERSION:
|
87
|
+
PG_VERSION: 13
|
80
88
|
POSTGRES_HOST: localhost
|
81
89
|
POSTGRES_USER: postgres
|
82
90
|
POSTGRES_DB: ruby-pg-extras-test
|
83
91
|
POSTGRES_PASSWORD: secret
|
84
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5432/ruby-pg-extras-test
|
85
92
|
run: |
|
86
93
|
bundle exec rspec spec/
|
87
|
-
- name: Run tests for PG
|
94
|
+
- name: Run tests for PG 14
|
88
95
|
env:
|
89
|
-
PG_VERSION:
|
96
|
+
PG_VERSION: 14
|
90
97
|
POSTGRES_HOST: localhost
|
91
98
|
POSTGRES_USER: postgres
|
92
99
|
POSTGRES_DB: ruby-pg-extras-test
|
93
100
|
POSTGRES_PASSWORD: secret
|
94
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5433/ruby-pg-extras-test
|
95
101
|
run: |
|
96
102
|
bundle exec rspec spec/
|
97
|
-
- name: Run tests for PG
|
103
|
+
- name: Run tests for PG 15
|
98
104
|
env:
|
99
|
-
PG_VERSION:
|
105
|
+
PG_VERSION: 15
|
100
106
|
POSTGRES_HOST: localhost
|
101
107
|
POSTGRES_USER: postgres
|
102
108
|
POSTGRES_DB: ruby-pg-extras-test
|
103
109
|
POSTGRES_PASSWORD: secret
|
104
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5434/ruby-pg-extras-test
|
105
110
|
run: |
|
106
111
|
bundle exec rspec spec/
|
107
|
-
- name: Run tests for PG
|
112
|
+
- name: Run tests for PG 16
|
108
113
|
env:
|
109
|
-
PG_VERSION:
|
114
|
+
PG_VERSION: 16
|
110
115
|
POSTGRES_HOST: localhost
|
111
116
|
POSTGRES_USER: postgres
|
112
117
|
POSTGRES_DB: ruby-pg-extras-test
|
113
118
|
POSTGRES_PASSWORD: secret
|
114
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5435/ruby-pg-extras-test
|
115
119
|
run: |
|
116
120
|
bundle exec rspec spec/
|
117
|
-
- name: Run tests for PG
|
121
|
+
- name: Run tests for PG 17
|
118
122
|
env:
|
119
|
-
PG_VERSION:
|
123
|
+
PG_VERSION: 17
|
120
124
|
POSTGRES_HOST: localhost
|
121
125
|
POSTGRES_USER: postgres
|
122
126
|
POSTGRES_DB: ruby-pg-extras-test
|
123
127
|
POSTGRES_PASSWORD: secret
|
124
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5436/ruby-pg-extras-test
|
125
128
|
run: |
|
126
129
|
bundle exec rspec spec/
|
127
130
|
|
data/Rakefile
CHANGED
@@ -5,5 +5,5 @@ RSpec::Core::RakeTask.new(:spec)
|
|
5
5
|
|
6
6
|
desc "Test all PG versions"
|
7
7
|
task :test_all do
|
8
|
-
system("PG_VERSION=
|
8
|
+
system("PG_VERSION=12 bundle exec rspec spec/ && PG_VERSION=13 bundle exec rspec spec/ && PG_VERSION=14 bundle exec rspec spec/ && PG_VERSION=15 bundle exec rspec spec/ && PG_VERSION=16 bundle exec rspec spec/ && PG_VERSION=17 bundle exec rspec spec/")
|
9
9
|
end
|
data/docker-compose.yml.sample
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
version: '3'
|
2
|
-
|
3
1
|
services:
|
4
|
-
|
5
|
-
image: postgres:
|
2
|
+
postgres12:
|
3
|
+
image: postgres:12.20-alpine
|
6
4
|
command: postgres -c shared_preload_libraries=pg_stat_statements
|
7
5
|
environment:
|
8
6
|
POSTGRES_USER: postgres
|
@@ -10,8 +8,8 @@ services:
|
|
10
8
|
POSTGRES_PASSWORD: secret
|
11
9
|
ports:
|
12
10
|
- '5432:5432'
|
13
|
-
|
14
|
-
image: postgres:
|
11
|
+
postgres13:
|
12
|
+
image: postgres:13.16-alpine
|
15
13
|
command: postgres -c shared_preload_libraries=pg_stat_statements
|
16
14
|
environment:
|
17
15
|
POSTGRES_USER: postgres
|
@@ -19,8 +17,8 @@ services:
|
|
19
17
|
POSTGRES_PASSWORD: secret
|
20
18
|
ports:
|
21
19
|
- '5433:5432'
|
22
|
-
|
23
|
-
image: postgres:13
|
20
|
+
postgres14:
|
21
|
+
image: postgres:14.13-alpine
|
24
22
|
command: postgres -c shared_preload_libraries=pg_stat_statements
|
25
23
|
environment:
|
26
24
|
POSTGRES_USER: postgres
|
@@ -28,8 +26,8 @@ services:
|
|
28
26
|
POSTGRES_PASSWORD: secret
|
29
27
|
ports:
|
30
28
|
- '5434:5432'
|
31
|
-
|
32
|
-
image: postgres:
|
29
|
+
postgres15:
|
30
|
+
image: postgres:15.8-alpine
|
33
31
|
command: postgres -c shared_preload_libraries=pg_stat_statements
|
34
32
|
environment:
|
35
33
|
POSTGRES_USER: postgres
|
@@ -37,3 +35,22 @@ services:
|
|
37
35
|
POSTGRES_PASSWORD: secret
|
38
36
|
ports:
|
39
37
|
- '5435:5432'
|
38
|
+
postgres16:
|
39
|
+
image: postgres:16.4-alpine
|
40
|
+
command: postgres -c shared_preload_libraries=pg_stat_statements
|
41
|
+
environment:
|
42
|
+
POSTGRES_USER: postgres
|
43
|
+
POSTGRES_DB: ruby-pg-extras-test
|
44
|
+
POSTGRES_PASSWORD: secret
|
45
|
+
ports:
|
46
|
+
- '5436:5432'
|
47
|
+
postgres17:
|
48
|
+
image: postgres:17.0-alpine
|
49
|
+
command: postgres -c shared_preload_libraries=pg_stat_statements
|
50
|
+
environment:
|
51
|
+
POSTGRES_USER: postgres
|
52
|
+
POSTGRES_DB: ruby-pg-extras-test
|
53
|
+
POSTGRES_PASSWORD: secret
|
54
|
+
ports:
|
55
|
+
- '5437:5432'
|
56
|
+
|
data/lib/ruby-pg-extras.rb
CHANGED
@@ -14,6 +14,7 @@ require "ruby_pg_extras/table_info_print"
|
|
14
14
|
module RubyPgExtras
|
15
15
|
@@database_url = nil
|
16
16
|
NEW_PG_STAT_STATEMENTS = "1.8"
|
17
|
+
PG_STAT_STATEMENTS_17 = "1.11"
|
17
18
|
|
18
19
|
QUERIES = %i(
|
19
20
|
add_extensions bloat blocking cache_hit db_settings
|
@@ -32,11 +33,13 @@ module RubyPgExtras
|
|
32
33
|
DEFAULT_ARGS = Hash.new({}).merge({
|
33
34
|
calls: { limit: 10 },
|
34
35
|
calls_legacy: { limit: 10 },
|
36
|
+
calls_17: { limit: 10 },
|
35
37
|
long_running_queries: { threshold: "500 milliseconds" },
|
36
38
|
locks: { limit: 20 },
|
37
39
|
blocking: { limit: 20 },
|
38
40
|
outliers: { limit: 10 },
|
39
41
|
outliers_legacy: { limit: 10 },
|
42
|
+
outliers_17: { limit: 10 },
|
40
43
|
buffercache_stats: { limit: 10 },
|
41
44
|
buffercache_usage: { limit: 20 },
|
42
45
|
unused_indexes: { max_scans: 50, schema: DEFAULT_SCHEMA },
|
@@ -70,6 +73,8 @@ module RubyPgExtras
|
|
70
73
|
if pg_stat_statements_ver != nil
|
71
74
|
if Gem::Version.new(pg_stat_statements_ver) < Gem::Version.new(NEW_PG_STAT_STATEMENTS)
|
72
75
|
query_name = "#{query_name}_legacy".to_sym
|
76
|
+
elsif Gem::Version.new(pg_stat_statements_ver) >= Gem::Version.new(PG_STAT_STATEMENTS_17)
|
77
|
+
query_name = "#{query_name}_17".to_sym
|
73
78
|
end
|
74
79
|
end
|
75
80
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/* Queries that have highest frequency of execution */
|
2
|
+
|
3
|
+
SELECT query AS qry,
|
4
|
+
interval '1 millisecond' * total_exec_time AS exec_time,
|
5
|
+
to_char((total_exec_time/sum(total_exec_time) OVER()) * 100, 'FM90D0') || '%%' AS prop_exec_time,
|
6
|
+
to_char(calls, 'FM999G999G990') AS ncalls,
|
7
|
+
interval '1 millisecond' * (shared_blk_read_time + shared_blk_write_time) AS sync_io_time
|
8
|
+
FROM pg_stat_statements WHERE userid = (SELECT usesysid FROM pg_user WHERE usename = current_user LIMIT 1)
|
9
|
+
ORDER BY calls DESC LIMIT %{limit};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/* Queries that have longest execution time in aggregate */
|
2
|
+
|
3
|
+
SELECT interval '1 millisecond' * total_exec_time AS total_exec_time,
|
4
|
+
to_char((total_exec_time/sum(total_exec_time) OVER()) * 100, 'FM90D0') || '%%' AS prop_exec_time,
|
5
|
+
to_char(calls, 'FM999G999G999G990') AS ncalls,
|
6
|
+
interval '1 millisecond' * (shared_blk_read_time + shared_blk_write_time) AS sync_io_time,
|
7
|
+
query AS query
|
8
|
+
FROM pg_stat_statements WHERE userid = (SELECT usesysid FROM pg_user WHERE usename = current_user LIMIT 1)
|
9
|
+
ORDER BY total_exec_time DESC
|
10
|
+
LIMIT %{limit};
|
data/spec/spec_helper.rb
CHANGED
@@ -6,14 +6,18 @@ require_relative "../lib/ruby-pg-extras"
|
|
6
6
|
|
7
7
|
pg_version = ENV["PG_VERSION"]
|
8
8
|
|
9
|
-
port = if pg_version == "
|
9
|
+
port = if pg_version == "12"
|
10
10
|
"5432"
|
11
|
-
elsif pg_version == "12"
|
12
|
-
"5433"
|
13
11
|
elsif pg_version == "13"
|
14
|
-
"
|
12
|
+
"5433"
|
15
13
|
elsif pg_version == "14"
|
14
|
+
"5434"
|
15
|
+
elsif pg_version == "15"
|
16
16
|
"5435"
|
17
|
+
elsif pg_version == "16"
|
18
|
+
"5436"
|
19
|
+
elsif pg_version == "17"
|
20
|
+
"5437"
|
17
21
|
else
|
18
22
|
"5432"
|
19
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-pg-extras
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.4.
|
4
|
+
version: 5.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/ruby_pg_extras/queries/buffercache_usage.sql
|
110
110
|
- lib/ruby_pg_extras/queries/cache_hit.sql
|
111
111
|
- lib/ruby_pg_extras/queries/calls.sql
|
112
|
+
- lib/ruby_pg_extras/queries/calls_17.sql
|
112
113
|
- lib/ruby_pg_extras/queries/calls_legacy.sql
|
113
114
|
- lib/ruby_pg_extras/queries/connections.sql
|
114
115
|
- lib/ruby_pg_extras/queries/db_settings.sql
|
@@ -126,6 +127,7 @@ files:
|
|
126
127
|
- lib/ruby_pg_extras/queries/mandelbrot.sql
|
127
128
|
- lib/ruby_pg_extras/queries/null_indexes.sql
|
128
129
|
- lib/ruby_pg_extras/queries/outliers.sql
|
130
|
+
- lib/ruby_pg_extras/queries/outliers_17.sql
|
129
131
|
- lib/ruby_pg_extras/queries/outliers_legacy.sql
|
130
132
|
- lib/ruby_pg_extras/queries/pg_stat_statements_reset.sql
|
131
133
|
- lib/ruby_pg_extras/queries/records_rank.sql
|