Follow up usage pagination SQL pushdown#166
Closed
zly2006 wants to merge 1 commit into
Closed
Conversation
38abc2c to
d58d36f
Compare
Author
|
Benchmark result on real off data: closing this PR. I tested the branch on a snapshot of the live off Usage Service SQLite database, copied from Dataset:
Average latency comparison:
Conclusion: on the current real production-sized dataset, this SQL pushdown does not improve performance. Normal sorts are slower by about 1.4-1.6x, and |
Author
|
Closing based on the real off-data benchmark above: this branch is slower than the in-memory path on the current dataset. |
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.
This is a follow-up to #138.
#138 introduced the paged usage monitoring endpoints and documented that accounts/api-keys pagination was still a phase-one optimization. This PR implements the two follow-up items from that review:
Behavior note:
The SQL pushdown intentionally normalizes cached-token sorting at the event row level with
sum(max(cached_tokens, cache_tokens)). The previous Go path grouped details first and then effectively summedmax(sum(cached_tokens), sum(cache_tokens))per detail group. The new row-level normalization is a small behavior difference forcachedTokensordering when both fields are populated differently, but it matches the intended meaning of treatingcached_tokensandcache_tokensas alternate sources for the same per-event cached-token metric.Validation:
go test ./...fromusage-servicenpm run build