lib/pghero/methods/query_stats.rb in pghero-1.3.1 vs lib/pghero/methods/query_stats.rb in pghero-1.3.2

- old
+ new

@@ -146,11 +146,11 @@ sort = options[:sort] || "total_minutes" database = options[:database] ? quote(options[:database]) : "current_database()" select_all <<-SQL WITH query_stats AS ( SELECT - query, + LEFT(query, 10000) AS query, #{supports_query_hash? ? "queryid" : "md5(query)"} AS query_hash, (total_time / 1000 / 60) AS total_minutes, (total_time / calls) AS average_time, calls FROM @@ -184,11 +184,11 @@ sort = options[:sort] || "total_minutes" stats_connection.select_all squish <<-SQL WITH query_stats AS ( SELECT #{supports_query_hash? ? "query_hash" : "md5(query)"} AS query_hash, - MAX(query) AS query, + array_agg(LEFT(query, 10000)) AS query, (SUM(total_time) / 1000 / 60) AS total_minutes, (SUM(total_time) / SUM(calls)) AS average_time, SUM(calls) AS calls FROM pghero_query_stats @@ -200,10 +200,10 @@ GROUP BY 1 ) SELECT query_hash, - query, + query[1], total_minutes, average_time, calls, total_minutes * 100.0 / (SELECT SUM(total_minutes) FROM query_stats) AS total_percent, (SELECT SUM(total_minutes) FROM query_stats) AS all_queries_total_minutes