-
Notifications
You must be signed in to change notification settings - Fork 897
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
Scanning for used attributes for query optimizations #14023
Scanning for used attributes for query optimizations #14023
Conversation
@kbrock first step for tracking attribute references, it's not used now to |
This pull request is not mergeable. Please rebase and repush. |
We want to allow setting references as public
The constant is written as O(1) not O(C)
Calling .include? on Set is O(1)
Not relevant comment, attributes is callable multiple times now
Add ApplicationRecordLite that is for holding is and class of AR. ActiveRecord object are to huge and we need a query to obtain them, in most cases we have a class and id, which is just enough to fil la relation. No need to go to db.
Collect attribute_references and use them for db strategy. So we are able to load a relation fro ma db without making a sql query, wrapping it to ApplicationRecordLite.
Extract InitDataHelper so it's reusable in other specs
Spec testing a db_find_strategy with :key poiting to relation
a07cb9d
to
0eaa8a3
Compare
Autofix rubocop issues
Fix a polymorphic relation loading
Test a polymorphic relation is obtained via :key
Clean up a spec to only use a needed ICs
Look for foreign_key only in belongs_to relations, we would get a confusing trying to assign to another relation.
Check for allowed strategies and raise exception with a list of allowed
A complex interconnection spec
Enhance specs and run them for both DB strategies
Autofix rubocop issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good. The ApplicationRecordLite
will reduce the number of (useless) queries significantly (thought I'm a little sad about that).
Like how the lazy is morphing / simplifying.
Rename ApplicationRecordLite to ApplicationRecordReference, as it shows the purpose much better.
Checked commits Ladas/manageiq@d9be0c2~...19e7dcc with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 spec/models/manager_refresh/save_inventory/strategies_and_references_spec.rb
|
Scans for AR attributes referred by :key and uses that to populate a a DB loaded InventoryCollection. + Specs
Partially implements:
https://www.pivotaltracker.com/story/show/138129875
We first need solid specs, before the optimizattions