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

Relationships filter_by_resource_type scope #10288

Merged
merged 3 commits into from Aug 5, 2016

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Aug 5, 2016

These are prep steps for #10160 - only save 1 record coming back from vm.parent_blue_folders
They allow the other PR to avoid many queries (from 8 -> 3)

before

ms objects queries query (ms) rows comments
89.7 23,359 8 19.0 14 no name-1
5.0 0.3 2 .SELECT "relationships".*
0.3 0.2 1 .SELECT "relationships".*
0.3 0.2 1 .SELECT "relationships".*
0.5 0.4 1 .SELECT "ems_folders".*
0.4 0.3 1 .SELECT "relationships".*
0.3 0.2 1 .SELECT "relationships".*
0.5 0.4 4 .SELECT "relationships".*
11.7 0.3 3 .SELECT "ems_folders".*

after

ms objects queries query (ms) rows comments
90.0 23,557 8 19.6 13 no name-1
4.9 0.3 2 .SELECT "relationships".*
0.4 0.3 1 .SELECT "relationships".*
0.3 0.2 1 .SELECT "relationships".*
0.5 0.4 1 .SELECT "ems_folders".*
0.3 0.2 1 .SELECT "relationships".*
0.3 0.2 1 .SELECT "relationships".*
0.6 0.5 3 .SELECT "relationships".*
12.3 0.3 3 .SELECT "ems_folders".*

for cap&u run, it brings back 5% fewer rows but the real gain is
this query is kept as a scope. So it can be used as an inner query
and the total # queries, objects, are reduced.

This is just a building block

This slows the query down (less than margin of error).
We will make up for it by
reducing the total number of run
@miq-bot
Copy link
Member

miq-bot commented Aug 5, 2016

Checked commits kbrock/manageiq@ce9dd2b~...f44bc55 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
3 files checked, 0 offenses detected
Everything looks good. 🍰

expect(Relationship.filter_by_resource_type(vms, {})).to eq(vms)
end

it "scopes" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically this should move to a separate method-centric test on .filtered

@Fryguy Fryguy merged commit 8b85794 into ManageIQ:master Aug 5, 2016
@Fryguy Fryguy added this to the Sprint 45 Ending Aug 22, 2016 milestone Aug 5, 2016
@kbrock kbrock deleted the relationships_prune_a branch August 5, 2016 21:11
chessbyte pushed a commit that referenced this pull request Aug 23, 2016
Relationships filter_by_resource_type scope
(cherry picked from commit 8b85794)
@chessbyte
Copy link
Member

Darga backport details:

commit 809b49837e451f1404edb25ae42748fab41118cc
Author: Jason Frey <fryguy9@gmail.com>
Date:   Fri Aug 5 17:11:02 2016 -0400

    Merge pull request #10288 from kbrock/relationships_prune_a

    Relationships filter_by_resource_type scope
    (cherry picked from commit 8b85794bd1263c132d9f98d9090c8f72b24236ce)

@JPrause
Copy link
Member

JPrause commented Sep 12, 2016

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