ruby-pg-extras 5.4.0 → 5.4.2
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 +31 -54
- 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: d0c2a3e53db33c3f6e1acdbd46a93640425038e3db8d97297c641474a1f35831
|
4
|
+
data.tar.gz: 48849139f119982d36f4ac886522158687c43453c17a37c466dc81e886bb2528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfe571164b5544efbd220d6be208352900c67bfbb0af288b6411863002781a55caf74406e07b22ce3b80ea06895e714a8f9abf8cbea9e734c3dadda9cfcc72e9
|
7
|
+
data.tar.gz: 04d3a6b2444f0b31a17d9017e5e290591f336d65e72f150d1585f20dbfce551c3b26ac92330c810b0b6a9fdd9d4d5bc0c2748ca082ed0a26dcb387826280c47c
|
data/.github/workflows/ci.yml
CHANGED
@@ -12,45 +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
|
-
- name: Run PostgreSQL
|
46
|
+
- name: Run PostgreSQL 16
|
47
|
+
run: |
|
48
|
+
docker run --env POSTGRES_USER=postgres \
|
49
|
+
--env POSTGRES_DB=ruby-pg-extras-test \
|
50
|
+
--env POSTGRES_PASSWORD=secret \
|
51
|
+
-d -p 5436:5432 postgres:16.4-alpine \
|
52
|
+
postgres -c shared_preload_libraries=pg_stat_statements
|
53
|
+
- name: Run PostgreSQL 17
|
47
54
|
run: |
|
48
55
|
docker run --env POSTGRES_USER=postgres \
|
49
56
|
--env POSTGRES_DB=ruby-pg-extras-test \
|
50
57
|
--env POSTGRES_PASSWORD=secret \
|
51
|
-
-d -p
|
58
|
+
-d -p 5437:5432 postgres:17.0-alpine \
|
52
59
|
postgres -c shared_preload_libraries=pg_stat_statements
|
53
|
-
sleep
|
60
|
+
sleep 5
|
54
61
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
55
62
|
uses: ruby/setup-ruby@v1
|
56
63
|
with:
|
@@ -63,65 +70,35 @@ jobs:
|
|
63
70
|
sudo apt install libpq-dev
|
64
71
|
bundle config set --local path 'vendor/bundle'
|
65
72
|
bundle install
|
66
|
-
sleep
|
67
|
-
- name: Run tests for PG 11
|
68
|
-
env:
|
69
|
-
PG_VERSION: 11
|
70
|
-
POSTGRES_HOST: localhost
|
71
|
-
POSTGRES_USER: postgres
|
72
|
-
POSTGRES_DB: ruby-pg-extras-test
|
73
|
-
POSTGRES_PASSWORD: secret
|
74
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5432/ruby-pg-extras-test
|
75
|
-
run: |
|
76
|
-
bundle exec rspec spec/
|
77
|
-
- name: Run tests for PG 11
|
78
|
-
env:
|
79
|
-
PG_VERSION: 11
|
80
|
-
POSTGRES_HOST: localhost
|
81
|
-
POSTGRES_USER: postgres
|
82
|
-
POSTGRES_DB: ruby-pg-extras-test
|
83
|
-
POSTGRES_PASSWORD: secret
|
84
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5432/ruby-pg-extras-test
|
85
|
-
run: |
|
86
|
-
bundle exec rspec spec/
|
73
|
+
sleep 5
|
87
74
|
- name: Run tests for PG 12
|
88
75
|
env:
|
89
76
|
PG_VERSION: 12
|
90
|
-
POSTGRES_HOST: localhost
|
91
|
-
POSTGRES_USER: postgres
|
92
|
-
POSTGRES_DB: ruby-pg-extras-test
|
93
|
-
POSTGRES_PASSWORD: secret
|
94
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5433/ruby-pg-extras-test
|
95
77
|
run: |
|
96
78
|
bundle exec rspec spec/
|
97
79
|
- name: Run tests for PG 13
|
98
80
|
env:
|
99
81
|
PG_VERSION: 13
|
100
|
-
POSTGRES_HOST: localhost
|
101
|
-
POSTGRES_USER: postgres
|
102
|
-
POSTGRES_DB: ruby-pg-extras-test
|
103
|
-
POSTGRES_PASSWORD: secret
|
104
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5434/ruby-pg-extras-test
|
105
82
|
run: |
|
106
83
|
bundle exec rspec spec/
|
107
84
|
- name: Run tests for PG 14
|
108
85
|
env:
|
109
86
|
PG_VERSION: 14
|
110
|
-
POSTGRES_HOST: localhost
|
111
|
-
POSTGRES_USER: postgres
|
112
|
-
POSTGRES_DB: ruby-pg-extras-test
|
113
|
-
POSTGRES_PASSWORD: secret
|
114
|
-
DATABASE_URL: postgresql://postgres:secret@localhost:5435/ruby-pg-extras-test
|
115
87
|
run: |
|
116
88
|
bundle exec rspec spec/
|
117
89
|
- name: Run tests for PG 15
|
118
90
|
env:
|
119
91
|
PG_VERSION: 15
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
92
|
+
run: |
|
93
|
+
bundle exec rspec spec/
|
94
|
+
- name: Run tests for PG 16
|
95
|
+
env:
|
96
|
+
PG_VERSION: 16
|
97
|
+
run: |
|
98
|
+
bundle exec rspec spec/
|
99
|
+
- name: Run tests for PG 17
|
100
|
+
env:
|
101
|
+
PG_VERSION: 17
|
125
102
|
run: |
|
126
103
|
bundle exec rspec spec/
|
127
104
|
|
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.2
|
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-11-21 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
|