Skip to content

Commit

Permalink
Merge pull request #66 from technicalpickles/call-caller-less
Browse files Browse the repository at this point in the history
Improve performance in sql.activerecord subscription callback
  • Loading branch information
charkost authored Aug 9, 2023
2 parents 94f2320 + aa3891b commit 1a1ef0c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/prosopite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,14 @@ def subscribe
sql, name = data[:sql], data[:name]

if scan? && name != "SCHEMA" && sql.include?('SELECT') && data[:cached].nil? && !ignore_query?(sql)
location_key = Digest::SHA1.hexdigest(caller.join)
query_caller = caller
location_key = Digest::SHA256.hexdigest(query_caller.join)

tc[:prosopite_query_counter][location_key] += 1
tc[:prosopite_query_holder][location_key] << sql

if tc[:prosopite_query_counter][location_key] > 1
tc[:prosopite_query_caller][location_key] = caller.dup
tc[:prosopite_query_caller][location_key] = query_caller.dup
end
end
end
Expand Down

0 comments on commit 1a1ef0c

Please sign in to comment.