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

[FINE] Faster report result index pages #4208

Merged
merged 3 commits into from Jun 26, 2018

Conversation

NickLaMuro
Copy link
Member

This is the Fine port of #4143. Original PR message below.


Merge after ManageIQ/manageiq#17590 (NOTE: Not relavent, this is already backported)

This makes both the ChargebackController and ReportController::SavedReports actions for viewing reports signficantly faster by:

Benchmarks

This is displaying a MiqReportResult index page that has 23k+ rows associated with it. Showing the first page, paginated by 20 records.

Before

ms queries query (ms) rows
5701 20 178.9 47523
4475 20 161.2 47523
5070 20 151.8 47523
4976 20 140.1 47523
5189 20 141.4 47523

After

ms queries query (ms) rows
462 19 55.8 30
234 19 53.5 30
272 19 51.0 30
234 19 46.2 30
283 19 55.8 30

Links

QA Steps

I tested the did the following when running the Before/After benchmarks:

  • Log in as an admin and go to Cloud Intel -> Reports
  • Find a report that has a large number of report results, chargeback with some subtotals is prefered
  • Select that report on the tree view, and select one of the report results table that is loaded in
  • After the first paginated page has been returned, change the size of the page to 200 or something. Make sure the switch between is also snappy. (I toggled between page sizes with little to no wait time with all of the fixes in place).
  • Make sure you can download using the Download toolbar button as well.

…rtResult

https://bugzilla.redhat.com/show_bug.cgi?id=1594387

Gaprindashvili Backport commit from:

    ManageIQ#4143

Original SHA:

   ff7ee24

Rest of original message below...

* * *

These are new methods added in:

ManageIQ/manageiq#17590

And are far more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
https://bugzilla.redhat.com/show_bug.cgi?id=1594387

Gaprindashvili Backport commit from:

    ManageIQ#4143

Original SHA:

   cb118f0

Rest of original message below...

* * *

Calls to `.length` will fetch the entire record set or rows for the
MiqReportResult, and in the current case of these button helpers, throw
them all away without using any of the data fetched.  In most cases, the
`html_details` relation is probably what was is being used, so even
caching these ahead of time is wasteful.

By using `.exists?` as an alternative, we basically do a:

  SELECT 1 as one
  FROM miq_report_result_details
  WHERE "miq_report_result_details"."miq_report_result_id" = ?
  LIMIT 1

Which only returns a single digit from the database if it has at least
one record and nothing if it doesn't.  This will also be cached in a
controller action by the ActiveRecord query cache, so it will also
require zero queries the second time around.
…ng mixin

https://bugzilla.redhat.com/show_bug.cgi?id=1594387

Gaprindashvili Backport commit from:

    ManageIQ#4143

Original SHA:

   b5260fd

Rest of original message below...

* * *

This not only makes it so we are consistent between the main controller
and the mixin, but this is also much faster to use this over
`MiqReportResult#report_results` when there is a large `binary_blob`
associated with the `MiqReportResult` record.
@NickLaMuro
Copy link
Member Author

@miq-bot assign @simaishi
@miq-bot add_labels cloud intel/chargeback, blocker

@miq-bot
Copy link
Member

miq-bot commented Jun 25, 2018

Some comments on commits NickLaMuro/manageiq-ui-classic@64f8b1f~...02fd904

spec/controllers/miq_report_controller/trees_spec.rb

  • ⚠️ - 42 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented Jun 25, 2018

Checked commits NickLaMuro/manageiq-ui-classic@64f8b1f~...02fd904 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
7 files checked, 2 offenses detected

app/controllers/chargeback_controller.rb

app/controllers/report_controller/saved_reports.rb

  • ❗ - Line 30, Col 9 - Style/UnlessElse - Do not use unless with else. Rewrite these with the positive case first.

@simaishi simaishi requested a review from mzazrivec June 26, 2018 01:03
@simaishi simaishi merged commit 99d3049 into ManageIQ:fine Jun 26, 2018
@simaishi simaishi added this to the Sprint 89 Ending Jul 2, 2018 milestone Jun 26, 2018
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

4 participants