Skip to content

Commit

Permalink
NIP-45: Fix cost estimation extraction from EXPLAIN query
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorvsk committed Nov 23, 2023
1 parent 0c87e8c commit 8fe6739
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/jobs/count_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def perform(connection_id, subscription_id, filters)
unless RELAY_CONFIG.count_cost_threshold.zero?
explain = ActiveRecord::Base.connection.execute("EXPLAIN #{union}").first.to_s
rows = explain[/rows=(\d+)/, 1].to_i
cost = explain[/cost=(\d+)/, 1].to_i
cost = explain[/cost=\d+\.\d+\.\.(\d+)/, 1].to_i
should_count_approximate = RELAY_CONFIG.count_cost_threshold.positive? && cost > RELAY_CONFIG.count_cost_threshold
end

Expand Down

0 comments on commit 8fe6739

Please sign in to comment.