Skip to content

perf: cap PoolEffort lookback window to 30 days - #8

Merged
colneech-dev merged 1 commit into
mainfrom
perf/cap-effort-query-lookback
Nov 24, 2026
Merged

colneech-dev merged 1 commit into
mainfrom
perf/cap-effort-query-lookback

Conversation

@colneech-dev

Copy link
Copy Markdown
Owner

Summary

  • GetEffortBetweenCreatedAsync aggregates SUM() over the shares table from a pool's last block to now. For long-dormant pools this is an unbounded full-table scan.
  • Confirmed via EXPLAIN ANALYZE to cost ~800ms for a pool with no block since 2026-08-08 (3.15M matching rows) — this was the dominant remaining latency in /api/pools after the earlier query-collapsing work (perf: parallelize and merge /api/pools queries #6, perf: collapse per-pool /api/pools queries into one round trip #7).
  • PoolEffort is a display-only ratio stat (not used in payouts), so this caps the lookback at 30 days and simply omits the value beyond that instead of computing it exactly.

Test plan

  • Builds clean (dotnet build, 0 errors)
  • Applied to all three call sites: Get(), GetPoolInfoAsync(), GetSummaryAsync()
  • Deploy to .100 and confirm /api/pools latency drop for dormant pools (e.g. dgb-odo-solo)

🤖 Generated with Claude Code

GetEffortBetweenCreatedAsync aggregates SUM() over the shares table since
a pool's last block. For pools idle for months, that's an unbounded
full-table scan — confirmed via EXPLAIN ANALYZE to cost ~800ms for a pool
with no block since 2026-08-08 and 3.15M matching rows, accounting for
most of /api/pools' remaining latency after the earlier query-collapsing
work. PoolEffort is a display-only ratio stat, so capping the lookback
at 30 days (omitting it entirely beyond that) is an acceptable trade-off
with no payout impact.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@colneech-dev
colneech-dev merged commit f1ac4bc into main Nov 24, 2026
1 check passed
@colneech-dev
colneech-dev deleted the perf/cap-effort-query-lookback branch November 24, 2026 08:00
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.

1 participant