Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It makes sense to short-circuit Chewy's
update_proc
when current strategy isbypass
.Currently, even when current strategy is to bypass ES, Chewy still takes time to evaluate the backreference (which is an AR relation, usually).
It's better to skip it as it affects the performance of an application.
Why not put
next if ...
in the beginning of the proc?Because
Chewy.derive_type
may cause some chewy types to load, if Rails'eager_load
isfalse
. If we stop callingChewy.derive_type
, this can cause undesired behavior and bugs, which actually happened in one of the applications I work on. So, in order to preserve existing behavior, we callderive_type
beforenext if
, and the remaining part after thenext if ...
. The remaining part is the heaviest one performance-wise, anyway.