Skip to content

fix(svm): optimize holders query for split database schema#465

Merged
DenisCarriere merged 2 commits intomainfrom
fix/svm-holders-timeout
Apr 8, 2026
Merged

fix(svm): optimize holders query for split database schema#465
DenisCarriere merged 2 commits intomainfrom
fix/svm-holders-timeout

Conversation

@0237h
Copy link
Copy Markdown
Collaborator

@0237h 0237h commented Apr 8, 2026

Summary

Fixes SVM holders endpoint timeout (>10s) when running against the new split databases (svm-balances@v0.3.2, svm-accounts@v0.3.1, svm-metadata@v0.3.2).

/v1/svm/holders

  • Pre-filter amount > 0 in WHERE instead of HAVING — halves the aggregation set
  • Simplify GROUP BY to single column (account) using any() for per-mint constant fields
  • Scope owner lookup to LIMIT'd result set via duplicated subquery
  • Replace unscoped metadata_view JOIN with independent CTE filtered to single mint

/v1/svm/holders/native

  • Scope owner lookup to LIMIT'd result set (same pattern)

🤖 Generated with Claude Code

- Pre-filter amount > 0 in WHERE instead of HAVING to halve aggregation set
- Simplify GROUP BY to single column (account) using any() for constant fields
- Scope owner lookup to LIMIT'd result set to avoid materializing full owner_state
- Replace unscoped metadata_view JOIN with independent CTE filtered to single mint

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Same pattern as svm.sql — replace unscoped owner_view JOIN with
duplicated subquery scoped to the LIMIT'd result set.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@YaroShkvorets YaroShkvorets temporarily deployed to fix/svm-holders-timeout - token-api PR #465 April 8, 2026 22:21 — with Render Destroyed
@DenisCarriere DenisCarriere merged commit e0bc966 into main Apr 8, 2026
2 of 4 checks passed
@DenisCarriere DenisCarriere deleted the fix/svm-holders-timeout branch April 8, 2026 23:41
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.

3 participants