pghero 3.6.0 → 3.6.2
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 +24 -1
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/app/views/layouts/pg_hero/application.html.erb +1 -1
- data/lib/pghero/database.rb +1 -1
- data/lib/pghero/engine.rb +2 -2
- data/lib/pghero/methods/basic.rb +19 -21
- data/lib/pghero/methods/sequences.rb +8 -3
- data/lib/pghero/methods/suggested_indexes.rb +3 -1
- data/lib/pghero/version.rb +1 -1
- data/lib/pghero.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ddf920adafa90b3c49ff86f3abd05d23bb22ed3be2b27786dc8f755b308b90e
|
4
|
+
data.tar.gz: 60758c308a9f298c54993c2118a8594ef3a56fd01ff5a7f0864821296f3d4a40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c65e4c0dc52a9312e6c832c68fccbeccd1c8307ecb747b00a640a08b7d58223cd20a3c92ad0747cf2681ff4b0fcd3003e02d5617d0a6f3d9a69ee9b0f1cf4f2
|
7
|
+
data.tar.gz: e764269d546c4931fc5fd1680f2f25ad699f406830a7a3a1923174c8b9053393c6e124e4e049bccc11ab779071a3500a4e15a7db17cb8b22edfbe83d625c162d
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
+
## 3.6.2 (2025-03-21)
|
2
|
+
|
3
|
+
- Improved query in `sequences` method
|
4
|
+
|
5
|
+
## 3.6.1 (2024-10-14)
|
6
|
+
|
7
|
+
- Fixed error when Propshaft is installed but not used
|
8
|
+
|
1
9
|
## 3.6.0 (2024-07-10)
|
2
10
|
|
3
11
|
- Improved CSP support
|
12
|
+
- Dropped support for Linux packages for Ubuntu 18.04, CentOS 7, and SLES 12
|
4
13
|
- Dropped support for Ruby < 3.1 and Rails < 6.1
|
5
14
|
|
6
15
|
## 3.5.0 (2024-05-21)
|
@@ -486,4 +495,18 @@ PgHero.with(:database2) { PgHero.running_queries }
|
|
486
495
|
|
487
496
|
## 0.1.0 (2014-07-23)
|
488
497
|
|
489
|
-
-
|
498
|
+
- Improved explanations
|
499
|
+
- Updated design
|
500
|
+
|
501
|
+
## 0.0.3 (2014-07-22)
|
502
|
+
|
503
|
+
- Fixed `missing_indexes` method
|
504
|
+
|
505
|
+
## 0.0.2 (2014-07-21)
|
506
|
+
|
507
|
+
- Added `unused_tables` method
|
508
|
+
- Added `database_size` method
|
509
|
+
|
510
|
+
## 0.0.1 (2014-07-21)
|
511
|
+
|
512
|
+
- First release
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ A performance dashboard for Postgres
|
|
4
4
|
|
5
5
|
[See it in action](https://pghero.dokkuapp.com/)
|
6
6
|
|
7
|
-
[](https://pghero.dokkuapp.com/)
|
8
8
|
|
9
9
|
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
10
10
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<meta charset="utf-8" />
|
7
7
|
<%= favicon_link_tag "pghero/favicon.png" %>
|
8
|
-
<% if defined?(Propshaft::Railtie) %>
|
8
|
+
<% if defined?(Propshaft::Railtie) && Rails.application.assets.is_a?(Propshaft::Assembly) %>
|
9
9
|
<%= stylesheet_link_tag "pghero/nouislider", "pghero/arduino-light", "pghero/application" %>
|
10
10
|
<%= javascript_include_tag "pghero/jquery", "pghero/nouislider", "pghero/Chart.bundle", "pghero/chartkick", "pghero/highlight.min", "pghero/application", nonce: true %>
|
11
11
|
<% else %>
|
data/lib/pghero/database.rb
CHANGED
@@ -126,7 +126,7 @@ module PgHero
|
|
126
126
|
# rough check for Postgres adapter
|
127
127
|
# keep this message generic so it's useful
|
128
128
|
# when empty url set in Docker image pghero.yml
|
129
|
-
unless @connection_model.
|
129
|
+
unless @connection_model.connection_db_config.adapter.to_s.match?(/postg/i)
|
130
130
|
raise Error, "Invalid connection URL"
|
131
131
|
end
|
132
132
|
@adapter_checked = true
|
data/lib/pghero/engine.rb
CHANGED
@@ -4,8 +4,8 @@ module PgHero
|
|
4
4
|
|
5
5
|
initializer "pghero", group: :all do |app|
|
6
6
|
# check if Rails api mode
|
7
|
-
if app.config.respond_to?(:assets)
|
8
|
-
if
|
7
|
+
if app.config.respond_to?(:assets) && defined?(Sprockets)
|
8
|
+
if Sprockets::VERSION.to_i >= 4
|
9
9
|
app.config.assets.precompile << "pghero/application.js"
|
10
10
|
app.config.assets.precompile << "pghero/application.css"
|
11
11
|
app.config.assets.precompile << "pghero/favicon.png"
|
data/lib/pghero/methods/basic.rb
CHANGED
@@ -31,13 +31,18 @@ module PgHero
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def quote_ident(value)
|
34
|
-
|
34
|
+
with_connection { |c| c.quote_column_name(value) }
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
def select_all(sql,
|
40
|
-
|
39
|
+
def select_all(sql, stats: false, query_columns: [])
|
40
|
+
with_connection(stats: stats) do |conn|
|
41
|
+
select_all_leased(sql, conn: conn, query_columns: query_columns)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def select_all_leased(sql, conn:, query_columns:)
|
41
46
|
# squish for logs
|
42
47
|
retries = 0
|
43
48
|
begin
|
@@ -81,7 +86,7 @@ module PgHero
|
|
81
86
|
end
|
82
87
|
|
83
88
|
def select_all_stats(sql, **options)
|
84
|
-
select_all(sql, **options,
|
89
|
+
select_all(sql, **options, stats: true)
|
85
90
|
end
|
86
91
|
|
87
92
|
def select_all_size(sql)
|
@@ -92,24 +97,17 @@ module PgHero
|
|
92
97
|
result
|
93
98
|
end
|
94
99
|
|
95
|
-
def select_one(sql
|
96
|
-
select_all(sql
|
97
|
-
end
|
98
|
-
|
99
|
-
def select_one_stats(sql)
|
100
|
-
select_one(sql, conn: stats_connection)
|
100
|
+
def select_one(sql)
|
101
|
+
select_all(sql).first.values.first
|
101
102
|
end
|
102
103
|
|
103
104
|
def execute(sql)
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
def connection
|
108
|
-
connection_model.connection
|
105
|
+
with_connection { |c| c.execute(add_source(sql)) }
|
109
106
|
end
|
110
107
|
|
111
|
-
def
|
112
|
-
::PgHero::Stats
|
108
|
+
def with_connection(stats: false, &block)
|
109
|
+
model = stats ? ::PgHero::Stats : connection_model
|
110
|
+
model.connection_pool.with_connection(&block)
|
113
111
|
end
|
114
112
|
|
115
113
|
def squish(str)
|
@@ -121,15 +119,15 @@ module PgHero
|
|
121
119
|
end
|
122
120
|
|
123
121
|
def quote(value)
|
124
|
-
|
122
|
+
with_connection { |c| c.quote(value) }
|
125
123
|
end
|
126
124
|
|
127
125
|
def quote_table_name(value)
|
128
|
-
|
126
|
+
with_connection { |c| c.quote_table_name(value) }
|
129
127
|
end
|
130
128
|
|
131
129
|
def quote_column_name(value)
|
132
|
-
|
130
|
+
with_connection { |c| c.quote_column_name(value) }
|
133
131
|
end
|
134
132
|
|
135
133
|
def unquote(part)
|
@@ -150,7 +148,7 @@ module PgHero
|
|
150
148
|
end
|
151
149
|
|
152
150
|
def table_exists?(table)
|
153
|
-
|
151
|
+
with_connection(stats: true) { |c| c.table_exists?(table) }
|
154
152
|
end
|
155
153
|
end
|
156
154
|
end
|
@@ -39,14 +39,19 @@ module PgHero
|
|
39
39
|
|
40
40
|
add_sequence_attributes(sequences)
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
last_value = {}
|
43
|
+
sequences.select { |s| s[:readable] }.map { |s| [s[:schema], s[:sequence]] }.uniq.each_slice(1024) do |slice|
|
44
|
+
sql = slice.map { |s| "SELECT last_value FROM #{quote_ident(s[0])}.#{quote_ident(s[1])}" }.join(" UNION ALL ")
|
44
45
|
|
45
46
|
select_all(sql).zip(slice) do |row, seq|
|
46
|
-
seq
|
47
|
+
last_value[seq] = row[:last_value]
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
51
|
+
sequences.select { |s| s[:readable] }.each do |seq|
|
52
|
+
seq[:last_value] = last_value[[seq[:schema], seq[:sequence]]]
|
53
|
+
end
|
54
|
+
|
50
55
|
# use to_s for unparsable sequences
|
51
56
|
sequences.sort_by { |s| s[:sequence].to_s }
|
52
57
|
end
|
@@ -79,7 +79,9 @@ module PgHero
|
|
79
79
|
suggested_indexes.each do |index|
|
80
80
|
p index
|
81
81
|
if create
|
82
|
-
|
82
|
+
with_connection do |connection|
|
83
|
+
connection.execute("CREATE INDEX CONCURRENTLY ON #{quote_table_name(index[:table])} (#{index[:columns].map { |c| quote_column_name(c) }.join(",")})")
|
84
|
+
end
|
83
85
|
end
|
84
86
|
end
|
85
87
|
end
|
data/lib/pghero/version.rb
CHANGED
data/lib/pghero.rb
CHANGED
@@ -64,7 +64,7 @@ module PgHero
|
|
64
64
|
:query_stats_available?, :query_stats_enabled?, :query_stats_extension_enabled?, :query_stats_readable?,
|
65
65
|
:rds_stats, :read_iops_stats, :aws_region, :relation_sizes, :replica?, :replication_lag, :replication_lag_stats,
|
66
66
|
:reset_query_stats, :reset_stats, :running_queries, :aws_secret_access_key, :sequence_danger, :sequences, :settings,
|
67
|
-
:slow_queries, :space_growth, :ssl_used?, :
|
67
|
+
:slow_queries, :space_growth, :ssl_used?, :suggested_indexes, :suggested_indexes_by_query,
|
68
68
|
:suggested_indexes_enabled?, :system_stats_enabled?, :table_caching, :table_hit_rate, :table_stats,
|
69
69
|
:total_connections, :transaction_id_danger, :unused_indexes, :unused_tables, :write_iops_stats
|
70
70
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pghero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-22 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activerecord
|
@@ -24,7 +23,6 @@ dependencies:
|
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '6.1'
|
27
|
-
description:
|
28
26
|
email: andrew@ankane.org
|
29
27
|
executables: []
|
30
28
|
extensions: []
|
@@ -109,7 +107,6 @@ homepage: https://github.com/ankane/pghero
|
|
109
107
|
licenses:
|
110
108
|
- MIT
|
111
109
|
metadata: {}
|
112
|
-
post_install_message:
|
113
110
|
rdoc_options: []
|
114
111
|
require_paths:
|
115
112
|
- lib
|
@@ -124,8 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
121
|
- !ruby/object:Gem::Version
|
125
122
|
version: '0'
|
126
123
|
requirements: []
|
127
|
-
rubygems_version: 3.
|
128
|
-
signing_key:
|
124
|
+
rubygems_version: 3.6.2
|
129
125
|
specification_version: 4
|
130
126
|
summary: A performance dashboard for Postgres
|
131
127
|
test_files: []
|