feat: optimize SQL balance calculation #1152
No reviewers
Labels
No labels
DB & Storage
Deployment
Error Handling & Logging
Maintenance
Payment Backend
backport
backport v0.13.x
backport v0.14.x
backport v0.15.x
bindings
blocked
bug
cdk-sql
ci
cli
deps
documentation
duplicate
enhancement
good first issue
help wanted
invalid
keep-open
ldk-node-ui
migrations
mint
mutation-testing
needs rebase
needs review
new nut
nut change
question
ready
rust-version
rustfmt
stacked hold
stale
testing
wallet
weekly-report
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cashubtc/cdk!1152
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "optimize_get_balance_2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
replace proof-fetching approach with SUM aggregation
Description
Hashpool produces and consumes mint quotes at a rapid pace. I recently implemented a dashboard that queries for the wallet balance every three seconds. I noticed this message in the logs:
This query, which scans the entire proof table, was being called every time the wallet balance was requested. This PR speeds up this process by performing the sum operation in db logic instead of application logic.
Here are some log messages demonstrating the 100x speedup of the balance query:
Notes to the reviewers
No test changes were needed because integration tests already cover balance calculations.
Suggested CHANGELOG Updates
CHANGED
ADDED
REMOVED
FIXED
Checklist
just final-checkbefore committingBTW final check is broken because it depends on a running postgres db, which leads
just final-checkto return false negative results for the following tests:Backport failed for
v0.13.x, because it was unable to cherry-pick the commit(s).Please cherry-pick the changes locally and resolve any conflicts.
Backport failed for
v0.13.x, because it was unable to cherry-pick the commit(s).Please cherry-pick the changes locally and resolve any conflicts.