perf(dashboard): project financial log summaries in PostgreSQL - #4481
Closed
TaprootFreak wants to merge 1 commit into
Closed
perf(dashboard): project financial log summaries in PostgreSQL#4481TaprootFreak wants to merge 1 commit into
TaprootFreak wants to merge 1 commit into
Conversation
TaprootFreak
force-pushed
the
agent/optimize-financial-dashboard-api
branch
from
July 29, 2026 21:28
7ec0667 to
3f2d583
Compare
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.
Summary
Replace the stale SQL Server-oriented approach from #3725 with a PostgreSQL-native fix for
GET /v1/dashboard/financial/log.The endpoint currently loads complete
FinancialDataLog.messagesnapshots for every minute in the requested range and parses them in Node, although the response only needs balance aggregates, one BTC price andbalancesByFinancialType. For the default three-day view that means roughly 4,320 large JSON documents per request.This PR adds a dashboard-specific PostgreSQL projection that returns only the fields required by the existing response contract. The API no longer transfers or parses the complete snapshot documents.
What changes
messagein PostgreSQLWhy this scope
Grafana traces showed the database fetch/transfer of full log snapshots dominating the request. The approximately 2 MB response itself is not the main problem, and the only observed caller refreshes once per minute, so compression or a 30-second in-process cache would not address the root cause. Five-minute sampling would also change the dashboard data contract.
Verification
npm run type-checknpm run lintnpm run format:checknpm run buildDeployment check
After deploying to DEV, compare endpoint latency and response equality for the default three-day request before promoting.