Repository navigation
perf(api): find private PR prefixes from the attachment index - #1398
Conversation
listPrefixIdsForTarget range-scanned every gh/private/ file_metadata row in the workspace (~10.5k rows per call on the largest workspace, ~15k calls a week from comment syncs). It now reads the distinct prefix ids from the target's github_attachments rows, pinned to github_attachments_target_idx (at most ~30 rows in production). The index row's repo is server-resolved, so the separate ownership lookup goes away. Sentinel and head-branch lookups are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeLbkis33mPMcBF5kRguaM
|
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 2
🚫 Excluded labels (none allowed): 1
Please check the settings in the CodeRabbit UI or the
|
What
listPrefixIdsForTarget(managed comment sync and the CLI private-prefix route) used to range-scan everygh/private/file_metadatarow in the workspace to find which private prefixes hold a PR or issue's files. On the largest workspace that is about 10.5k rows per call.It now reads the distinct
prefix_idvalues from that target'sgithub_attachmentsrows. The query is pinned withINDEXED BY github_attachments_target_idx, because without stats SQLite picksgithub_attachments_prefix_idxand walks every private row in the workspace. In production the biggest target reads 29 rows in about 0.5 ms.The index row's repo is resolved on the server, so the second query that checked prefix ownership is no longer needed. The sentinel and head-branch lookups are unchanged.
Coverage
Every
putObjectwrites an index row for managed keys. In production, every private attachment key with metadata written since Sep 4 has a row. 168 older keys (Aug 18 to Sep 4, on 48 PRs) have no row; their objects are still in R2. Those rows need a one-off backfill before this deploys, or those old PRs could drop private images on their next comment sync.Tests
github_attachments_target_idx, and the result covers indexed ids, detached rows, other repos, the sentinel and the head branch.Generated by Claude Code