pghero 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pghero might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/app/assets/stylesheets/pghero/application.css +6 -0
- data/app/controllers/pg_hero/home_controller.rb +1 -0
- data/app/views/pg_hero/home/index.html.erb +8 -1
- data/app/views/pg_hero/home/tune.html.erb +30 -0
- data/lib/pghero.rb +1 -0
- data/lib/pghero/database.rb +1 -0
- data/lib/pghero/methods/basic.rb +0 -18
- data/lib/pghero/methods/maintenance.rb +1 -1
- data/lib/pghero/methods/replication.rb +23 -8
- data/lib/pghero/methods/sequences.rb +1 -1
- data/lib/pghero/methods/settings.rb +37 -0
- data/lib/pghero/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35e051862227173af7785b2c94c18e8adb212c7b
|
4
|
+
data.tar.gz: e59c139875040a33db54c06263569792cae6901c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01bf19bcaadab5a8cc039cc15bd0934ddb9d77b45c8b0cbabbf05aca2f0445ae1f0191907ee92f7f9a67a1ed7ad22bdeb4ded66285aa6f4662d41a9e77238e19
|
7
|
+
data.tar.gz: f8662218394eafdf740aa70f7e32fce9bb32b9f7412e41b50bd8ca063bef778b51b4b3abe360df96289b81327e9b0a7a6949b8b234d847dbe2461074a1fd7711
|
data/CHANGELOG.md
CHANGED
@@ -137,6 +137,10 @@
|
|
137
137
|
<%= button_to "Kill All", kill_long_running_queries_path, class: "btn btn-danger", style: "float: right;" %>
|
138
138
|
<h1>Long Running Queries</h1>
|
139
139
|
|
140
|
+
<p>We recommend setting a statement timeout on all non-superusers with:</p>
|
141
|
+
|
142
|
+
<pre><code>ALTER ROLE <user> SET statement_timeout TO '60s';</code></pre>
|
143
|
+
|
140
144
|
<%= render partial: "live_queries_table", locals: {queries: @long_running_queries} %>
|
141
145
|
</div>
|
142
146
|
<% end %>
|
@@ -173,7 +177,10 @@
|
|
173
177
|
<div class="content">
|
174
178
|
<h2>Vacuuming Needed</h2>
|
175
179
|
<p>The database <strong>will shutdown</strong> when there are fewer than 1,000,000 transactions left. <%= link_to "Read more", "http://www.postgresql.org/docs/9.1/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND", target: "_blank" %>.</p>
|
176
|
-
|
180
|
+
|
181
|
+
<p>Try <%= link_to "tuning autovacuum", "https://blog.2ndquadrant.com/autovacuum-tuning-basics/", target: "_blank" %> - specifically autovacuum_vacuum_cost_limit.</p>
|
182
|
+
|
183
|
+
<p>If that doesn’t work, for each table, run:</p>
|
177
184
|
<pre><code>VACUUM FREEZE VERBOSE table;</code></pre>
|
178
185
|
<table class="table">
|
179
186
|
<thead>
|
@@ -20,3 +20,33 @@
|
|
20
20
|
|
21
21
|
<p>Check out <%= link_to "PgTune", "http://pgtune.leopard.in.ua", target: "_blank" %> for recommendations. DB version is <%= @database.server_version.split(".").first(2).join(".") %>.</p>
|
22
22
|
</div>
|
23
|
+
|
24
|
+
<% if @autovacuum_settings %>
|
25
|
+
<div class="content">
|
26
|
+
<h1>Autovacuum</h1>
|
27
|
+
|
28
|
+
<table class="table">
|
29
|
+
<thead>
|
30
|
+
<tr>
|
31
|
+
<th>Setting</th>
|
32
|
+
<th style="width: 20%;">Value</th>
|
33
|
+
</tr>
|
34
|
+
</thead>
|
35
|
+
<tbody>
|
36
|
+
<% @autovacuum_settings.each do |setting, value| %>
|
37
|
+
<tr>
|
38
|
+
<td><%= setting %></td>
|
39
|
+
<td>
|
40
|
+
<%= value %>
|
41
|
+
<% if setting == :autovacuum_vacuum_cost_limit && value == "-1" %>
|
42
|
+
<span class="text-muted"><%= @database.vacuum_settings[:vacuum_cost_limit] %></span>
|
43
|
+
<% end %>
|
44
|
+
</td>
|
45
|
+
</tr>
|
46
|
+
<% end %>
|
47
|
+
</tbody>
|
48
|
+
</table>
|
49
|
+
|
50
|
+
<p>Check out <%= link_to "Autovacuum Tuning Basics", "https://blog.2ndquadrant.com/autovacuum-tuning-basics/", target: "_blank" %> for recommendations.</p>
|
51
|
+
</div>
|
52
|
+
<% end %>
|
data/lib/pghero.rb
CHANGED
@@ -12,6 +12,7 @@ require "pghero/methods/queries"
|
|
12
12
|
require "pghero/methods/query_stats"
|
13
13
|
require "pghero/methods/replication"
|
14
14
|
require "pghero/methods/sequences"
|
15
|
+
require "pghero/methods/settings"
|
15
16
|
require "pghero/methods/space"
|
16
17
|
require "pghero/methods/suggested_indexes"
|
17
18
|
require "pghero/methods/system"
|
data/lib/pghero/database.rb
CHANGED
data/lib/pghero/methods/basic.rb
CHANGED
@@ -1,24 +1,6 @@
|
|
1
1
|
module PgHero
|
2
2
|
module Methods
|
3
3
|
module Basic
|
4
|
-
def settings
|
5
|
-
names =
|
6
|
-
if server_version_num >= 90500
|
7
|
-
%i(
|
8
|
-
max_connections shared_buffers effective_cache_size work_mem
|
9
|
-
maintenance_work_mem min_wal_size max_wal_size checkpoint_completion_target
|
10
|
-
wal_buffers default_statistics_target
|
11
|
-
)
|
12
|
-
else
|
13
|
-
%i(
|
14
|
-
max_connections shared_buffers effective_cache_size work_mem
|
15
|
-
maintenance_work_mem checkpoint_segments checkpoint_completion_target
|
16
|
-
wal_buffers default_statistics_target
|
17
|
-
)
|
18
|
-
end
|
19
|
-
Hash[names.map { |name| [name, select_one("SHOW #{name}")] }]
|
20
|
-
end
|
21
|
-
|
22
4
|
def ssl_used?
|
23
5
|
ssl_used = nil
|
24
6
|
with_transaction(rollback: true) do
|
@@ -22,20 +22,35 @@ module PgHero
|
|
22
22
|
|
23
23
|
def replication_slots
|
24
24
|
if server_version_num >= 90400
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
with_feature_support([]) do
|
26
|
+
select_all <<-SQL
|
27
|
+
SELECT
|
28
|
+
slot_name,
|
29
|
+
database,
|
30
|
+
active
|
31
|
+
FROM pg_replication_slots
|
32
|
+
SQL
|
33
|
+
end
|
32
34
|
else
|
33
35
|
[]
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
37
39
|
def replicating?
|
38
|
-
|
40
|
+
with_feature_support(false) do
|
41
|
+
select_all("SELECT state FROM pg_stat_replication").any?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def with_feature_support(default)
|
48
|
+
begin
|
49
|
+
yield
|
50
|
+
rescue ActiveRecord::StatementInvalid => e
|
51
|
+
raise unless e.message.start_with?("PG::FeatureNotSupported:")
|
52
|
+
default
|
53
|
+
end
|
39
54
|
end
|
40
55
|
end
|
41
56
|
end
|
@@ -29,7 +29,7 @@ module PgHero
|
|
29
29
|
s.relname ASC
|
30
30
|
SQL
|
31
31
|
|
32
|
-
select_all(sequences.map { |s| "SELECT last_value FROM #{s[:sequence]}" }.join(" UNION ALL ")).each_with_index do |row, i|
|
32
|
+
select_all(sequences.map { |s| "SELECT last_value FROM #{quote_ident(s[:schema])}.#{quote_ident(s[:sequence])}" }.join(" UNION ALL ")).each_with_index do |row, i|
|
33
33
|
sequences[i][:last_value] = row[:last_value]
|
34
34
|
end
|
35
35
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module PgHero
|
2
|
+
module Methods
|
3
|
+
module Settings
|
4
|
+
def settings
|
5
|
+
names =
|
6
|
+
if server_version_num >= 90500
|
7
|
+
%i(
|
8
|
+
max_connections shared_buffers effective_cache_size work_mem
|
9
|
+
maintenance_work_mem min_wal_size max_wal_size checkpoint_completion_target
|
10
|
+
wal_buffers default_statistics_target
|
11
|
+
)
|
12
|
+
else
|
13
|
+
%i(
|
14
|
+
max_connections shared_buffers effective_cache_size work_mem
|
15
|
+
maintenance_work_mem checkpoint_segments checkpoint_completion_target
|
16
|
+
wal_buffers default_statistics_target
|
17
|
+
)
|
18
|
+
end
|
19
|
+
fetch_settings(names)
|
20
|
+
end
|
21
|
+
|
22
|
+
def autovacuum_settings
|
23
|
+
fetch_settings %i(autovacuum autovacuum_max_workers autovacuum_vacuum_cost_limit autovacuum_vacuum_scale_factor autovacuum_analyze_scale_factor)
|
24
|
+
end
|
25
|
+
|
26
|
+
def vacuum_settings
|
27
|
+
fetch_settings %i(vacuum_cost_limit)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def fetch_settings(names)
|
33
|
+
Hash[names.map { |name| [name, select_one("SHOW #{name}")] }]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/pghero/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pghero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/pghero/methods/query_stats.rb
|
181
181
|
- lib/pghero/methods/replication.rb
|
182
182
|
- lib/pghero/methods/sequences.rb
|
183
|
+
- lib/pghero/methods/settings.rb
|
183
184
|
- lib/pghero/methods/space.rb
|
184
185
|
- lib/pghero/methods/suggested_indexes.rb
|
185
186
|
- lib/pghero/methods/system.rb
|
@@ -215,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
216
|
version: '0'
|
216
217
|
requirements: []
|
217
218
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.6.
|
219
|
+
rubygems_version: 2.6.13
|
219
220
|
signing_key:
|
220
221
|
specification_version: 4
|
221
222
|
summary: A performance dashboard for Postgres
|