-
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
Cache MiqExpression.get_col_type in MiqReport::Formatting #17195
Cache MiqExpression.get_col_type in MiqReport::Formatting #17195
Conversation
f20a3aa
to
3862d36
Compare
This call will make the same call to the DB over and over again on certain attributes, and is incredibly "N+1y" on large reports. This adds a simple cache for the data return from the DB calls to make sure they are only executed once per column. Moved into a separate method to break up the bulk of the current method. Note: An extra `to_sym` was removed when in the new method since it would always get executed on the next line if the value existed. Probably could remove the `unless` as well since at that point, as we should be clear of any `nil` errors... 🤷
@miq-bot assign @gtanzillo Gregg, figured I would assign this to you since the git history has your fingerprints all over it ;) Feel free to re-assign if you have someone better in mind to look at this. Thanks. |
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.
in a report, the same columns will be used over and over again. so the premise is to just cache the types for the duration of the report
Checked commit NickLaMuro@3862d36 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
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.
Looks goos. Nice find @NickLaMuro!
@gtanzillo Thanks! Based on the BZ that this is for, I think we want to backport this to the G release. That seem reasonable? |
👍 I added the necessary labels |
Thanks! |
…umn_type_lookup Cache MiqExpression.get_col_type in MiqReport::Formatting (cherry picked from commit 1b18fb1) https://bugzilla.redhat.com/show_bug.cgi?id=1565677
Gaprindashvili backport details:
|
…umn_type_lookup Cache MiqExpression.get_col_type in MiqReport::Formatting (cherry picked from commit 1b18fb1) https://bugzilla.redhat.com/show_bug.cgi?id=1565678
Fine backport details:
|
…rmat_column_type_lookup Cache MiqExpression.get_col_type in MiqReport::Formatting (cherry picked from commit 1b18fb1) https://bugzilla.redhat.com/show_bug.cgi?id=1565678
I noticed while running a report that there were a lot of
0 row
queries being executed against the DB when running a report. Turns out that when a report is building thehtml
data, theMiqReport::Formatting
code is checking for every column in every row what the format should be, even though it shouldn't change on a row by row basis.Specifically, this becomes a problem when it uses
MiqExpression.get_col_type
to determine the format as it will fetch from the DB what the column type is to help determine the format. This query does not get cached, so it is duplicated for every column in each row of the report dataset.The query in my tests (from the report described in #17141 ) that was being repeated in the logs was as follows:
Benchmarks
Using the same dataset and report from #17141 , the difference before and after this change is as follows:
Of note: The changes from #17141 were in place in both runs of the above.
Links