-
Notifications
You must be signed in to change notification settings - Fork 514
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
Fact Table Query Optimization #1923
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If multiple metrics from the same Fact Table are added to an experiment, combine them into a single SQL query
Your preview environment pr-1923-bttf has been deployed. Preview environment endpoints are available at: |
jdorn
changed the title
Fact Table Query Optimization [WIP]
Fact Table Query Optimization
Dec 9, 2023
…ove unnecessary length check
* first attempt * Second attempt * Notebook generating * lint * Typo * pyright and finish migration * Update version, fix notebook * Reformat * Fix manual * Add jstat declaration * Fix manual snapshot issue; remove manual snapshot preview * Fix var_id_map in notebook * Create return types * Remove unused import
…ion, show optimized badge in View Queries modal
Deploy preview for docs ready! ✅ Preview Built with commit 9f7b36b. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
If multiple metrics from the same Fact Table are added to an experiment, combine them into a single SQL query for increased performance.
Instead of the query returning columns for a single metric (e.g.
main_sum
,main_sum_squares
), it will return multiple sets of columns with a separate prefix for each metric (e.g.m0_main_sum
,m0_main_sum_squares
,m1_main_sum
, etc.). In addition, each prefix will also have anid
column so we can identify which fact metric it belongs to.Before calling the stats engine with the query result, we split it back into multiple metrics. This avoids needing to update the Python code.
Current State: Happy path works end-to-end. Need lots of testing, review, and error handling.
Changes
getExperimentFactMetricsQuery
. Very similar to existing experiment metric query method, but accepts an array of fact metrics and returns back a wide table with prefixed columns for each metricExperimentResultsQueryRunner
to group related fact metrics together and call the new Integration method when applicable. Respects aMAX_METRICS_PER_QUERY
setting.stats.ts
to break grouped results back into multiple separate metrics before calling stats engineTODO:
Research
Some of the engines have strict limits on the number of columns, as low as 1000. A single metric may have up to 10 columns (regression adjustment, denominator, capping, etc.), so we need to do some chunking to limit how many metrics are included in a single query.