Repository navigation
perf(observations): count identical tag lists before sorting scopes (#6328) - #6404
Merged
Merged
Conversation
…6328) GET /observations/scopes sorted every observation's tags twice (once for the total, once for the page). Count identical tag lists first, sort only the distinct ones, and read page + total from one materialized result. 287 ms -> 33 ms at 100k observations, 3.2 s -> 0.1 s at 1M. Review fixes on top of the reporter's patch: dropped the kept old-query branch for Oracle (Oracle cannot run unnest, so it was dead code) and commented why the query is shaped this way. Closes #6328 Co-authored-by: Harshit Gupta <[email protected]>
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.
Closes #6328. Based on @harshitgupta31415's patch.
GET /observations/scopessorted every observation's tags twice — once for the total, once for the page. Most observations share the same few tag lists, so this now counts identical lists first, sorts only the distinct ones, and reads both the page and the total from one result.Output is identical (scopes, counts, order, total — including an empty page past the end).
Changes on top of the reporter's patch: dropped the old-query fallback for non-Postgres backends (Oracle cannot run
unnest, so it never worked there), and added a comment explaining the query shape.