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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b86a04757fce4dfc91177eb7794c20ae289ec2d5
4
- data.tar.gz: ba8f9f333064208ea84fd6a4c222cd531f18637b
3
+ metadata.gz: d77eb8abd5e212bfd047e51833fb060f70db7025
4
+ data.tar.gz: 37615f251c48027095056c84e3d14654fb2a9b57
5
5
  SHA512:
6
- metadata.gz: d97627eb0174decf527ea8ca4554fcb8d45bc95c28eeb4fc250b7921c544f685af741ec85c5cfd1815a7749af36b4f75a4e90ef2b261adae873a9718ded34de3
7
- data.tar.gz: e8fedfa37a433af1d4c2b647242b06bc6cc8ba1697f45e564123d3d77a8db599e722322a047d7c51b4c528805324df5db1f5f08b7bda5ae62ffda093d7f4a718
6
+ metadata.gz: 773cb04370074357513902e3a707d292e3c67efe2e4b0d2df30cd93d828d1ac104e34f1695cc4a4b63015f9dd8d01c4d0e1264fd32e3f1ebbd3a307e1b900ab9
7
+ data.tar.gz: fb72f6b6ccc15dce99eee4a68200ad4b0d7a17dbc470362d1ab0aa2c570a7ec574ad22f8c300b0be251137154274ac0fbe900fee3e453753fcfca108b1834e94
@@ -1,3 +1,7 @@
1
+ ## 1.6.1
2
+
3
+ - Suggest GIN over GiST for `LIKE` queries
4
+
1
5
  ## 1.6.0
2
6
 
3
7
  - Removed mostly inactionable items (cache hit rate and index usage)
@@ -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] == "gist" %>
270
- connection.execute("CREATE INDEX CONCURRENTLY ON <%= index[:table] %><% if index[:using] %> USING <%= index[:using] %><% end %> (<%= index[:columns].join(", ") %>)")
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>
@@ -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, :capture_query_stats, :connection_sources, :connection_stats,
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]} gist_trgm_ops"], using: "gist"}
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
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
@@ -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 gist_trgm_ops"], using: "gist"}), "SELECT * FROM users WHERE email LIKE ?"
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 gist_trgm_ops"], using: "gist"}), "SELECT * FROM users WHERE email LIKE ? AND active = ?"
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 gist_trgm_ops"], using: "gist"}), "SELECT * FROM users WHERE email ILIKE ?"
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.0
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-21 00:00:00.000000000 Z
11
+ date: 2016-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord