Skip reading engagements when not necessary#6137
Closed
Conversation
|
Contributor
Author
|
Trying to check if it has some effect on queries on preview env but getting "DB::Exception: Received from localhost:9000. DB::Exception: Too many simultaneous queries. Maximum: 150. (TOO_MANY_SIMULTANEOUS_QUERIES) (version 25.11.5.8 (official build))" @cnkk do we have too many preview environments at the same time? |
Merged
This file contains hidden or 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
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.
Adds
WHERE name != 'engagement'all events_v2 queries that don't need engagement data. That is queries withouttime_on_pageorscroll_depthmetrics, or scroll goals included in dimensions/filters.Since the
namefield is included in the events_v2 sort key, engagement events cluster together in storage, allowing ClickHouse to efficiently skip granules that contain only engagement rows when they are not needed.I don't like that the most natural place for this was in the
where_builder.exmodule. But I didn't find a much better place for this either. Naturally I'd like it to be in theQueryOptimizergiven the name of that module. But it only operates on theQuerystruct and I didn't want to add another field to that struct.IMO the query pipeline is overdue for a refactoring where the
Querystruct is stripped down to represent user intent and site context. And all hints about SQL generation, which tables to query, JOIN types, and optimizations like this would be added to an intermediateExecutionPlanstruct. But this is a separate topic from the optimization itself.