New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] foreman refresh: use object refs instead of ids #2473
Conversation
Checked commit kbrock@2053118 with rubocop 0.27.1 vmdb/app/models/ems_refresh/save_inventory_helper.rb
|
Can you show an example of the database queries (you can get them running through console). I think this is ok (after GregM explained to me), but I'm concerned about thrashing. Or perhaps, just run it twice in console and verify you don't have thrashing on records. |
@blomquisg had concern with storing ar_object in the hash. In the future, it would be nice if |
@blomquisg @Fryguy Does this meet your concerns? If not, just say so. (this PR is blocking 2440 that is blocking 1 or 2 others) I can rewrite 2440 to not leverage this and move on. |
Loading the locations and organizations over and over again is a form of thrashing. It should not be necessary if the save_inventory chain is done correctly. However those are not affected by the changes in this PR and so were there already. What might be affected by this PR is that configuration_script loading over and over again...that should not be happening. Did that happen when you were use ids? Was there a specific reason you didn't use ids like we do elsewhere? |
Thrashing is not from this PR. This thrashing is due to a record having a second habtm layer. Since this is loading at a second level habtm, each of the children loads the relationships. I'll look into |
See how we already handle habtm and just do the same thing. Essentially If you have N+1 at the rest layer that should not translate down to the
|
Is this problem related to this PR? I am looking into it, but wondering if that should be blocking this PR |
Going to return objects from |
Save inventory converts a hash to a collection of active record objects.
Sometimes one of these collections links to another.
pseudo code for linking records:
If it is a self reference:
New suggested code is to just store the active record reference in the hash instead of the id:
store_ids_for_new_records
which loops through all active record objects for lookup.Gave example how this affects foreman. We have another PR #2440 that leverages this
/cc @gmcculloug @brandondunne @Fryguy