Avoid scope query when preloading #23277
Merged
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.
MiqPreloader.preload(...,...,scope) correctly identifies the scope coming in and passes off to the preloader
This prevents an extra (big) query from being performed
When we upgraded from rails 6.1 to 7.0, the preloader interface changed. We spent most of our efforts on how that affected virtual attributes, but there was one change here.
We only use preload with a scope in one spot - for preloading
VimPerformanceState
.Joe had documented all the places in the preloader test where the number of records loaded were different.
The very name of the variable
scope
suggests that this code change is correct and should not point torecords
This change gets those test values back to where they need to be for all but one (?) of the cases.
But of interest, we have a lot of tests talking about arrays instead of scopes.
Now in use, we only ever pass scopes.
But the tests were (probably) introduced when I was trying to treat that scope as a preloaded records implementation. Never got it working correctly and ended up reverting to
preload_with_array
instead.I'm thinking we should remove these preload with an array tests since this method was only ever written for passing a scope that was later applied to the records
EDIT:
Performance Testing
With a small database with 328 Vms and 380,000 vim performance states, passing a vim performance states scope to
MiqPreloader.preload
:Before
After