Skip to content

Commit

Permalink
Ignore walsender type queries (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
bheemreddy181 committed Feb 3, 2021
1 parent 9db4211 commit 9eaa22c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/pg_hero/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def index
@inactive_replication_slots = @database.replication_slots.select { |r| !r[:active] }
end

@autovacuum_queries, @long_running_queries = @database.long_running_queries.partition { |q| q[:query].starts_with?("autovacuum:") }
@walsender_queries, @long_running_queries_array = @database.long_running_queries.partition { |q| q[:backend_type]=="walsender"}
@autovacuum_queries, @long_running_queries = @long_running_queries_array.partition { |q| q[:query].starts_with?("autovacuum:") }

connection_states = @database.connection_states
@total_connections = connection_states.values.sum
Expand Down
3 changes: 3 additions & 0 deletions app/views/pg_hero/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<% if @autovacuum_queries.any? %>
<span class="tiny"><%= @autovacuum_queries.size %> autovacuum</span>
<% end %>
<% if @walsender_queries.any? %>
<span class="tiny"><%= @walsender_queries.size %> walsender</span>
<% end %>
</div>
<% if @extended %>
<div class="alert alert-<%= @good_cache_rate ? "success" : "warning" %>">
Expand Down
3 changes: 2 additions & 1 deletion lib/pghero/methods/queries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def running_queries(min_duration: nil, all: false)
query,
COALESCE(query_start, xact_start) AS started_at,
EXTRACT(EPOCH FROM NOW() - COALESCE(query_start, xact_start)) * 1000.0 AS duration_ms,
usename AS user
usename AS user,
#{server_version_num >= 100000 ? "backend_type" : "NULL AS backend_type"}
FROM
pg_stat_activity
WHERE
Expand Down

0 comments on commit 9eaa22c

Please sign in to comment.