Change trace-level iterators to push predicates down for all queries#3920
Merged
mdisibio merged 2 commits intografana:mainfrom Jul 30, 2024
Merged
Change trace-level iterators to push predicates down for all queries#3920mdisibio merged 2 commits intografana:mainfrom
mdisibio merged 2 commits intografana:mainfrom
Conversation
…even when AllConditions=false, by making metadata second pass more specific
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.
What this PR does:
This PR updates the trace-level iterators to push down predicates for all queries, even where AllConditions=false. An example query is
{ rootServiceName = "tempo-gateway" && (status = error || span.http.status_code = 500)}. This wasn't actually filtering for "tempo-gateway" at the fetch layer.The reason this wasn't done before was interaction with metadata on search responses. If the query was already using a metadata column (i.e root service name), we didn't want to read it again. But this meant that queries like above had to be reverted to do no filtering in the fetch layer, and pass everything up to the engine.
By updating the metadata second pass to be a bit more precise and splitting it out better, we can let those predicates be pushed down, and then read the column a second time (only for the search hits). This gains a lot of cpu/mem improvement, for a little bit more i/o. I think it's a worthwhile tradeoff.
This PR has a little improvement for other query types too, because the join in
createTraceIteratorwas changed. Previously it was pulling the first page of each column before checking for hits on the inner iterator, because it was a Join and not a LeftJoin.Query_range is unaffected in the current benchmarks because none of them have a metadata column in the second pass. But this will be important for #3824
BenchmarkTraceQL
BenchmarkQueryRange
Which issue(s) this PR fixes:
Fixes n/a
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]