-
Notifications
You must be signed in to change notification settings - Fork 14k
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
perf(sqla): avoid unnecessary type check on adhoc column #23491
perf(sqla): avoid unnecessary type check on adhoc column #23491
Conversation
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.
The change LGTM, code logic is the same as before but improves performance. I remember that there are UT covered this part, so this change is safe as well.
2f32401
to
de0c2bf
Compare
Codecov Report
@@ Coverage Diff @@
## master #23491 +/- ##
==========================================
- Coverage 67.66% 67.53% -0.14%
==========================================
Files 1914 1914
Lines 73936 73962 +26
Branches 8022 8029 +7
==========================================
- Hits 50028 49949 -79
- Misses 21864 21967 +103
- Partials 2044 2046 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 9 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
ec6fa0f
to
3a8b4db
Compare
sqla_col = self.adhoc_column_to_sqla( | ||
col=flt_col, | ||
force_type_check=True, | ||
template_processor=template_processor, |
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.
bycatch - the template processor was missing here
@@ -28,7 +28,7 @@ | |||
|
|||
|
|||
@validate_column_args("index", "columns") | |||
def pivot( # pylint: disable=too-many-arguments,too-many-locals | |||
def pivot( # pylint: disable=too-many-arguments |
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.
bycatch: a warning that pylint picked up but wasn't regarded as an error
SUMMARY
PR #21163 introduced support for time grains to the base axis for both regular and adhoc columns. This caused a performance regression that executes a query to the analytical database for every adhoc column to check if it's a temporal expression or not.
This PR changes the logic slightly so that the query is executed only if needed, i.e. the base column is adhoc and has a time grain, or if the adhoc column is part of an adhoc filter. To review the PR, please use "Hide whitespace" to see the real changes more clearly.
AFTER
On a chart with two normal adhoc columns, the query now executes in 7 seconds with only a single query being sent to the database:
The same chart previously executed in 22 seconds (rougly 3 x 7 seconds with 3 queries sent to the database):
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION