Skip to content

Fix Convex read limit errors for large star counts#4

Open
natea wants to merge 3 commits intoadambkovacs:mainfrom
natea:fix/upsert-repo-catalog-read-limit
Open

Fix Convex read limit errors for large star counts#4
natea wants to merge 3 commits intoadambkovacs:mainfrom
natea:fix/upsert-repo-catalog-read-limit

Conversation

@natea
Copy link
Copy Markdown

@natea natea commented Apr 15, 2026

Summary

  • findRepoByFullName: Remove case-insensitive .collect() fallback that caused O(n²) document reads during import
  • listUserRepoStates: Denormalize repoFullName onto userRepoStates schema to eliminate N+1 db.get() joins
  • listPortfolioEvents / listUserNotes: Replace N individual db.get() calls with single repoCatalog .collect() + in-memory map

Accounts with 500+ starred repos were hitting Convex's 32k document and 4096 read operation limits across four different queries.

Fixes #5
Fixes #3

Test plan

  • Import starred repos on an account with 500+ stars — no Convex errors
  • Dashboard loads after import without read limit errors
  • Search page loads without errors
  • Re-import (idempotent upsert) works correctly
  • bun run typecheck and bun run lint pass

🤖 Generated with Claude Code

Remove the case-insensitive fallback that called .collect() on the
entire repoCatalog table. During first import, every repo triggered
this fallback since no existing match was found, causing O(n²) document
reads that exceeded Convex's 32k limit around ~600 repos.

The indexed lookup via by_fullName is sufficient — GitHub returns
consistently-cased fullName values.

Fixes adambkovacs#3

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 2026

@natea is attempting to deploy a commit to the AI Enablement Academy's projects Team on Vercel.

A member of the Team first needs to authorize it.

Replace N+1 db.get() join patterns with efficient alternatives:
- listUserRepoStates: denormalize repoFullName onto userRepoStates
  to eliminate joins entirely (with fallback for existing rows)
- listPortfolioEvents: single repoCatalog .collect() + map lookup
  instead of per-event db.get()
- listUserNotes: same .collect() approach with early return for empty

These queries previously did Promise.all(ids.map(id => db.get(id)))
which counted as N separate read operations, exceeding Convex's 4096
read limit for accounts with 500+ starred repos.

Fixes adambkovacs#5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@natea natea changed the title Fix full-table scan in findRepoByFullName causing import failure Fix Convex read limit errors for large star counts Apr 15, 2026
- listRepoSnapshotsByFullNames: replace N indexed queries with single
  .collect() + in-memory grouping (was exceeding 4096 read limit)
- listPortfolioEvents: cap at .take(8192) to stay within Convex max
  array return size (was returning 9560 events)
- DriftChart: replace Math.max(...spread) with iterative loop to avoid
  stack overflow with large datasets

Fixes adambkovacs#6

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Convex read limits exceeded for accounts with many starred repos upsertRepoCatalogs hits Convex 32k document read limit during import

1 participant