Skip to content
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

Conversation

Ladas
Copy link
Contributor

@Ladas Ladas commented Feb 22, 2017

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

@Ladas
Copy link
Contributor Author

Ladas commented Feb 22, 2017

@miq-bot assign @agrare

@Ladas
Copy link
Contributor Author

Ladas commented Feb 22, 2017

@kbrock first step for tracking attribute references, it's not used now to .select(), first I need to build specs around it :-)

@miq-bot
Copy link
Member

miq-bot commented Feb 22, 2017

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
@Ladas Ladas force-pushed the scanning_for_used_attributes_for_query_optimizations branch from a07cb9d to 0eaa8a3 Compare February 22, 2017 18:34
@Ladas Ladas changed the title [WIP](Depends on #13995) Scanning for used attributes for query optimizations Scanning for used attributes for query optimizations Feb 22, 2017
Autofix rubocop issues
@miq-bot miq-bot removed the wip label Feb 22, 2017
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
Copy link
Member

@kbrock kbrock left a 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.
@miq-bot
Copy link
Member

miq-bot commented Feb 23, 2017

Checked commits Ladas/manageiq@d9be0c2~...19e7dcc with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
6 files checked, 11 offenses detected

spec/models/manager_refresh/save_inventory/strategies_and_references_spec.rb

@kbrock kbrock added this to the Sprint 55 Ending Feb 27, 2017 milestone Feb 23, 2017
@kbrock kbrock merged commit 8773af5 into ManageIQ:master Feb 23, 2017
@kbrock kbrock assigned kbrock and unassigned agrare Feb 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants