palkan / n_plus_one_control

RSpec and Minitest matchers to prevent N+1 queries problem
MIT License
555 stars 20 forks source link

Cached queries #59

Closed gagalago closed 3 months ago

gagalago commented 3 months ago

What is the purpose of this pull request?

sometimes Rails cache queries, so even if they are performed many times, in practice, they go only once to the database other stay in the Rails process. In that case, we can ignore to count them as they are close to free.

we can configure the cache of queries that way in rails: https://guides.rubyonrails.org/configuring.html#configuring-query-cache

What changes did you make? (overview)

I added an option to ignore cached queries (false by default).

corresponding code in rails that generate these events: ActiveRecord::QueryCache

Is there anything you'd like reviewers to focus on?

Naming of variables is always hard.

Checklist

palkan commented 3 months ago

Looks good. Thanks!

palkan commented 3 months ago

Released in 0.7.2

gagalago commented 3 months ago

thanks a lot