pghero 1.3.1 → 1.3.2

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: 33902e779edd42795e8f3c48d51a8f0abf4edf6c
4
- data.tar.gz: b16a37597ad809d2aefe83fd0ff6f6478319c655
3
+ metadata.gz: 8fe1e7db4a7b8d0181a485cf8239903d2d8bb8c3
4
+ data.tar.gz: c2cda0f71c0e04d0fe345d86d114bbf49862b9c0
5
5
  SHA512:
6
- metadata.gz: 65850829e7cd4071748b03b453f1ee91e0739048001802d5d8ecc290bb0f3e137d7c08bfa2f51cb0bc76ced94087865c6e8d276ed98b5b86c88916fea56e52a6
7
- data.tar.gz: 1cf67bd24d6e2780b63b44466f8e964ea10be8ef6bfbf4286e636a3b0f7baee16e20ab5e25bf3092ece33095ea22e7688596e7227b19c1093ea1243c41612b1d
6
+ metadata.gz: b0989fe3df1db33256d9cbc4affe14ea52ec44542827821deadc809eac6fe163d8aa48a6ec8573c9ea350644c235c9e7e57c2e085921e4db85ec6aae6290c8e7
7
+ data.tar.gz: cd101a030b03c7b5adf8f73e88b850ab071f2c358564810a857995d877b3267014dafe226dd84b85b1f0e3a1b36bc6352b24912256e81e5c6ebe2b78a805273d
@@ -1,3 +1,7 @@
1
+ ## 1.3.2
2
+
3
+ - Improved performance of query stats
4
+
1
5
  ## 1.3.1
2
6
 
3
7
  - Improved grouping of query stats
@@ -20,7 +20,7 @@ module PgHero
20
20
  end
21
21
 
22
22
  def current_database=(database)
23
- raise "Database not found" unless databases[database]
23
+ raise "Database not found" unless databases[database.to_s]
24
24
  Thread.current[:pghero_current_database] = database.to_s
25
25
  database
26
26
  end
@@ -148,7 +148,7 @@ module PgHero
148
148
  select_all <<-SQL
149
149
  WITH query_stats AS (
150
150
  SELECT
151
- query,
151
+ LEFT(query, 10000) AS query,
152
152
  #{supports_query_hash? ? "queryid" : "md5(query)"} AS query_hash,
153
153
  (total_time / 1000 / 60) AS total_minutes,
154
154
  (total_time / calls) AS average_time,
@@ -186,7 +186,7 @@ module PgHero
186
186
  WITH query_stats AS (
187
187
  SELECT
188
188
  #{supports_query_hash? ? "query_hash" : "md5(query)"} AS query_hash,
189
- MAX(query) AS query,
189
+ array_agg(LEFT(query, 10000)) AS query,
190
190
  (SUM(total_time) / 1000 / 60) AS total_minutes,
191
191
  (SUM(total_time) / SUM(calls)) AS average_time,
192
192
  SUM(calls) AS calls
@@ -202,7 +202,7 @@ module PgHero
202
202
  )
203
203
  SELECT
204
204
  query_hash,
205
- query,
205
+ query[1],
206
206
  total_minutes,
207
207
  average_time,
208
208
  calls,
@@ -185,6 +185,8 @@ module PgHero
185
185
  end
186
186
 
187
187
  def best_index_structure(statement)
188
+ return {error: "Too large"} if statement.to_s.length > 10000
189
+
188
190
  begin
189
191
  tree = PgQuery.parse(statement).parsetree
190
192
  rescue PgQuery::ParseError
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
3
3
  end
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.3.1
4
+ version: 1.3.2
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-07-11 00:00:00.000000000 Z
11
+ date: 2016-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord