Skip to content

Optimize net deposit raw balance query#1014

Merged
emmazzz merged 1 commit into
mainfrom
emma/optimize-net-deposits-query
May 18, 2026
Merged

Optimize net deposit raw balance query#1014
emmazzz merged 1 commit into
mainfrom
emma/optimize-net-deposits-query

Conversation

@emmazzz

@emmazzz emmazzz commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Make the /get_net_deposits raw balance query start from requested asset cutoffs and use a lateral lookup into balances.
  • Avoid the planner shape that sequentially scans the entire balances table before filtering to the requested assets.

Key decisions

  • Keep the endpoint semantics unchanged: materialized view totals are combined with raw balance rows from each asset cutoff to the requested timestamp.
  • Use LEFT JOIN LATERAL so assets with no raw rows still remain in the result and contribute zero via COALESCE.

Test plan

  • cargo fmt -p deepbook-server
  • cargo build -p deepbook-server
  • git diff --check origin/main..HEAD

@emmazzz emmazzz marked this pull request as ready for review May 15, 2026 00:31
@emmazzz

emmazzz commented May 15, 2026

Copy link
Copy Markdown
Collaborator Author

@claude review this

@emmazzz emmazzz merged commit 0cf2f5a into main May 18, 2026
5 checks passed
@emmazzz emmazzz deleted the emma/optimize-net-deposits-query branch May 18, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants