summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-07-17 17:15:23 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-07-17 17:15:23 +0000
commit9c70d98eefa9e306171158a5e1aaca17b6e47917 (patch)
tree391a8a38989c071cc4af650843903a3c8a86a67b
parent48257533274019eb46f9144e2d90befe1f8e4bca (diff)
parent32eaf46ead7d704e7f740e3e793281134239b328 (diff)
downloadgitlab-ce-9c70d98eefa9e306171158a5e1aaca17b6e47917.tar.gz
Merge branch '34940-peek-performance-bar-doesn-t-count-cached-queries-but-shows-them' into 'master'
Resolve "Peek performance bar doesn't count cached queries, but shows them" Closes #34940 See merge request !12915
-rw-r--r--lib/gitlab/performance_bar/peek_query_tracker.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/gitlab/performance_bar/peek_query_tracker.rb b/lib/gitlab/performance_bar/peek_query_tracker.rb
index 574ae8731a5..f97e895dbd0 100644
--- a/lib/gitlab/performance_bar/peek_query_tracker.rb
+++ b/lib/gitlab/performance_bar/peek_query_tracker.rb
@@ -1,4 +1,5 @@
# Inspired by https://github.com/peek/peek-pg/blob/master/lib/peek/views/pg.rb
+# PEEK_DB_CLIENT is a constant set in config/initializers/peek.rb
module Gitlab
module PerformanceBar
module PeekQueryTracker
@@ -23,7 +24,13 @@ module Gitlab
subscribe('sql.active_record') do |_, start, finish, _, data|
if RequestStore.active? && RequestStore.store[:peek_enabled]
- track_query(data[:sql].strip, data[:binds], start, finish)
+ # data[:cached] is only available starting from Rails 5.1.0
+ # https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb#L113
+ # Before that, data[:name] was set to 'CACHE'
+ # https://github.com/rails/rails/blob/v4.2.9/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb#L80
+ unless data.fetch(:cached, data[:name] == 'CACHE')
+ track_query(data[:sql].strip, data[:binds], start, finish)
+ end
end
end
end