Bug 1375348

Summary: ArVirtual - Ownership uses virtual attributes / delegates
Product: Red Hat CloudForms Management Engine Reporter: John Prause <jprause>
Component: PerformanceAssignee: Keenan Brock <kbrock>
Status: CLOSED CURRENTRELEASE QA Contact: Pradeep Kumar Surisetty <psuriset>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.6.0CC: arcsharm, jhardy, obarenbo, simaishi
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.7.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1376175 (view as bug list) Environment:
Last Closed: 2016-12-21 11:31:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1376175    

Description John Prause 2016-09-12 18:51:36 UTC
Speeds up "VMs & Instances I Own" index and ajax calls in the /vm_or_template (Services -> Workload) section of the application.

Followup to #10290 and alternative to #10525
This is more similar to the #10290 approach. Further PRs will leverage virtual_delegates.
@NickLaMuro found where to optimize, wrote up the description, an was gracious enough to let me throw my hat into the ring.
How

This adds virtual_attribute on to the ownership_mixin, which is used by a few classes and makes it so that MiqExpressions will evaluate filter in SQL instead of pulling down all matching records to then iterate over and filter in Ruby (causes a Massive N+1 on large datasets).

Comment 2 John Prause 2016-09-12 18:52:24 UTC
https://github.com/ManageIQ/manageiq/pull/10704

Comment 5 Archit Sharma 2016-12-21 11:15:48 UTC
This BZ talks about PR 10704 which was implemented within the same context as PR 10685 (as per my discussion with ui perf dev team) 

..and the corresponding BZ https://bugzilla.redhat.com/show_bug.cgi?id=1375346 has been verified. 


That said, pasting the numbers from #1375346 for reference:

Quantifier Data: {
  "pages": {
      "vm_or_template/explorer": {
      "navigations": 6, 
      "200": 6, 
      "timings": [
        { "200": 9.11 }, 
        { "200": 1.67 }, 
        { "200": 2.75 }, 
        { "200": 2.01 }, 
        { "200": 1.15 }, 
        { "200": 1.8 }
      ]
    }
  }, 
  "number of requests": 6
}

an explicit test using curl against the POST route for the filter is not straight-forward at the moment, but the improvements from the fix have been confirmed by the team.