Optimizations for missing one implementation #942
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.
Background
Queries to the new
/v1/stats/features/browsers/{browser}/missing_one_implementation_counts
take too long. (~53 seconds just in the database layer)Upon looking at the Query Insights for the endpoint, we can see that it has a very high latency and high number of rows scanned.
This change aims to fix these problems.
Summary of changes
BrowserFeatureSupportEvents_FeatureStatusOnBrowserRelease
andBrowserFeatureSupportEvents_AllFeatureStatusesOnBrowserRelease
Change 1: Modified the existing query template
These are the changes in the variable:
gcpMissingOneImplCountRawTemplate
Removed join with web features table
Before:
Now:
We actually do not need to join with the Web Features table for the IDs since BrowserFeatureSupportEvents has a foreign key on the WebFeatures.
Do better joins
< CURRENT_TIMESTAMP()
Change 2: Add new indexes:
BrowserFeatureSupportEvents_FeatureStatusOnBrowserRelease
andBrowserFeatureSupportEvents_AllFeatureStatusesOnBrowserRelease
These indexes help with quicker matching. More comments on the indexes themselves
Change 3: Create a separate query for local environments
This is similar to what we do for features search [1]. The gcp query is super fast in GCP but takes more than 1 minute in the emulator. And the only way to solve it is to add some CTEs. If we try the same CTE query used locally in GCP, it takes forever too:
As a result, we will maintain two versions. I also modified the tests to assert that both versions work.
Change 4: Modified the fake data script
The precalcuation step for the BrowserFeatureSupportEvents table was not being called. Now it is. And now, we can get data. It only looks at a year of release data to limit the data loaded into the database.
Also, I added new logic in a method called: generateMissingOneImplementations. This method actually makes it so that we get nice graph-able results. useful for the screenshots in #838
Summary
Now the call takes less than 2 seconds