pghero 1.6.0 → 1.6.1
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 +4 -0
- data/app/views/pg_hero/home/index.html.erb +3 -2
- data/lib/pghero.rb +1 -1
- data/lib/pghero/methods/query_stats.rb +2 -2
- data/lib/pghero/methods/suggested_indexes.rb +1 -1
- data/lib/pghero/version.rb +1 -1
- data/test/best_index_test.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d77eb8abd5e212bfd047e51833fb060f70db7025
|
4
|
+
data.tar.gz: 37615f251c48027095056c84e3d14654fb2a9b57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 773cb04370074357513902e3a707d292e3c67efe2e4b0d2df30cd93d828d1ac104e34f1695cc4a4b63015f9dd8d01c4d0e1264fd32e3f1ebbd3a307e1b900ab9
|
7
|
+
data.tar.gz: fb72f6b6ccc15dce99eee4a68200ad4b0d7a17dbc470362d1ab0aa2c570a7ec574ad22f8c300b0be251137154274ac0fbe900fee3e453753fcfca108b1834e94
|
data/CHANGELOG.md
CHANGED
@@ -266,8 +266,9 @@ remove_index <%= query["unneeded_index"]["table"].to_sym.inspect %>, name: <%= q
|
|
266
266
|
<p>And paste</p>
|
267
267
|
<pre style="overflow: scroll; white-space: pre; word-break: normal;">commit_db_transaction
|
268
268
|
<% @suggested_indexes.each do |index| %>
|
269
|
-
<% if index[:using]
|
270
|
-
|
269
|
+
<% if index[:using] && index[:using] != "btree" %>
|
270
|
+
# run directly on production database - Rails has trouble with GIN indexes
|
271
|
+
# connection.execute("CREATE INDEX CONCURRENTLY ON <%= index[:table] %><% if index[:using] %> USING <%= index[:using] %><% end %> (<%= index[:columns].join(", ") %>)")
|
271
272
|
<% else %>
|
272
273
|
add_index <%= index[:table].to_sym.inspect %>, [<%= index[:columns].map(&:to_sym).map(&:inspect).join(", ") %>], algorithm: :concurrently<% end %>
|
273
274
|
<% end %></pre>
|
data/lib/pghero.rb
CHANGED
@@ -41,7 +41,7 @@ module PgHero
|
|
41
41
|
class << self
|
42
42
|
extend Forwardable
|
43
43
|
def_delegators :current_database, :access_key_id, :autoindex, :autoindex_all, :autovacuum_danger,
|
44
|
-
:best_index, :blocked_queries, :
|
44
|
+
:best_index, :blocked_queries, :connection_sources, :connection_stats,
|
45
45
|
:cpu_usage, :create_user, :database_size, :db_instance_identifier, :disable_query_stats, :drop_user,
|
46
46
|
:duplicate_indexes, :enable_query_stats, :explain, :historical_query_stats_enabled?, :index_caching,
|
47
47
|
:index_hit_rate, :index_usage, :indexes, :invalid_indexes, :kill, :kill_all, :kill_long_running_queries,
|
@@ -165,7 +165,7 @@ module PgHero
|
|
165
165
|
SELECT
|
166
166
|
LEFT(query, 10000) AS query,
|
167
167
|
#{supports_query_hash? ? "queryid" : "md5(query)"} AS query_hash,
|
168
|
-
#{supports_query_stats_user? ? "rolname" : "NULL"} AS user,
|
168
|
+
#{supports_query_stats_user? ? "rolname" : "NULL::text"} AS user,
|
169
169
|
(total_time / 1000 / 60) AS total_minutes,
|
170
170
|
(total_time / calls) AS average_time,
|
171
171
|
calls
|
@@ -205,7 +205,7 @@ module PgHero
|
|
205
205
|
WITH query_stats AS (
|
206
206
|
SELECT
|
207
207
|
#{supports_query_hash? ? "query_hash" : "md5(query)"} AS query_hash,
|
208
|
-
#{supports_query_stats_user? ? "pghero_query_stats.user" : "NULL"} AS user,
|
208
|
+
#{supports_query_stats_user? ? "pghero_query_stats.user" : "NULL::text"} AS user,
|
209
209
|
array_agg(LEFT(query, 10000)) AS query,
|
210
210
|
(SUM(total_time) / 1000 / 60) AS total_minutes,
|
211
211
|
(SUM(total_time) / SUM(calls)) AS average_time,
|
@@ -134,7 +134,7 @@ module PgHero
|
|
134
134
|
if ["~~", "~~*"].include?(where.first[:op])
|
135
135
|
index[:found] = true
|
136
136
|
index[:row_progression] = [total_rows, index[:row_estimates].values.first]
|
137
|
-
index[:index] = {table: table, columns: ["#{where.first[:column]}
|
137
|
+
index[:index] = {table: table, columns: ["#{where.first[:column]} gin_trgm_ops"], using: "gin"}
|
138
138
|
else
|
139
139
|
# if most values are unique, no need to index others
|
140
140
|
rows_left = total_rows
|
data/lib/pghero/version.rb
CHANGED
data/test/best_index_test.rb
CHANGED
@@ -59,7 +59,7 @@ class BestIndexTest < Minitest::Test
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_like
|
62
|
-
assert_best_index ({table: "users", columns: ["email
|
62
|
+
assert_best_index ({table: "users", columns: ["email gin_trgm_ops"], using: "gin"}), "SELECT * FROM users WHERE email LIKE ?"
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_like_where
|
@@ -67,11 +67,11 @@ class BestIndexTest < Minitest::Test
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_like_where2
|
70
|
-
assert_best_index ({table: "users", columns: ["email
|
70
|
+
assert_best_index ({table: "users", columns: ["email gin_trgm_ops"], using: "gin"}), "SELECT * FROM users WHERE email LIKE ? AND active = ?"
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_ilike
|
74
|
-
assert_best_index ({table: "users", columns: ["email
|
74
|
+
assert_best_index ({table: "users", columns: ["email gin_trgm_ops"], using: "gin"}), "SELECT * FROM users WHERE email ILIKE ?"
|
75
75
|
end
|
76
76
|
|
77
77
|
def test_not_equals
|
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: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|