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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 725af86da804f9f7869d727483cdc077de020c77cf5d364abecb943db6b2e7e9
4
- data.tar.gz: 0e15c553a23d7288711f1b16e619ffff6cc38bbb26a1539477ed6f7eb11e2e6b
3
+ metadata.gz: 5ddf920adafa90b3c49ff86f3abd05d23bb22ed3be2b27786dc8f755b308b90e
4
+ data.tar.gz: 60758c308a9f298c54993c2118a8594ef3a56fd01ff5a7f0864821296f3d4a40
5
5
  SHA512:
6
- metadata.gz: 435b20217db356ac5d28450d92a5f96d44fef1ea3a2b909f8d9c713393f3dee3f9fea9e2be6737320280d1663dbab20fb19165d01b70d4842ea6f32978bb0465
7
- data.tar.gz: edab3df03d6a47681f9fff134d0fc5fa070fa5262d74092948aa76ade0dbba2977ef885120894ec0cb4a1e007b46454373c529239cb4fc1f002b2d8702dba17e
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
- - First major release
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2024 Andrew Kane, 2008-2014 Heroku (initial queries)
1
+ Copyright (c) 2014-2025 Andrew Kane, 2008-2014 Heroku (initial queries)
2
2
 
3
3
  MIT License
4
4
 
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
- [![Screenshot](https://pghero.dokkuapp.com/assets/pghero-ebb9c8e11434fd0e4ead81db88fe255b29cbbc845ec315b79e6c5e25015bc921.png)](https://pghero.dokkuapp.com/)
7
+ [![Screenshot](https://pghero.dokkuapp.com/assets/pghero-88a0d052.png)](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 %>
@@ -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.connection.adapter_name.match?(/postg/i)
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 defined?(Sprockets) && Sprockets::VERSION.to_i >= 4
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"
@@ -31,13 +31,18 @@ module PgHero
31
31
  end
32
32
 
33
33
  def quote_ident(value)
34
- connection.quote_column_name(value)
34
+ with_connection { |c| c.quote_column_name(value) }
35
35
  end
36
36
 
37
37
  private
38
38
 
39
- def select_all(sql, conn: nil, query_columns: [])
40
- conn ||= connection
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, conn: stats_connection)
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, conn: nil)
96
- select_all(sql, conn: conn).first.values.first
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
- connection.execute(add_source(sql))
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 stats_connection
112
- ::PgHero::Stats.connection
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
- connection.quote(value)
122
+ with_connection { |c| c.quote(value) }
125
123
  end
126
124
 
127
125
  def quote_table_name(value)
128
- connection.quote_table_name(value)
126
+ with_connection { |c| c.quote_table_name(value) }
129
127
  end
130
128
 
131
129
  def quote_column_name(value)
132
- connection.quote_column_name(value)
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
- stats_connection.table_exists?(table)
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
- sequences.select { |s| s[:readable] }.each_slice(1024) do |slice|
43
- sql = slice.map { |s| "SELECT last_value FROM #{quote_ident(s[:schema])}.#{quote_ident(s[:sequence])}" }.join(" UNION ALL ")
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[:last_value] = row[:last_value]
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
- connection.execute("CREATE INDEX CONCURRENTLY ON #{quote_table_name(index[:table])} (#{index[:columns].map { |c| quote_column_name(c) }.join(",")})")
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
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "3.6.0"
2
+ VERSION = "3.6.2"
3
3
  end
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?, :stats_connection, :suggested_indexes, :suggested_indexes_by_query,
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.0
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: 2024-07-11 00:00:00.000000000 Z
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.5.11
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: []