Skip to content

perf(sync): bulk upsert synced reviews - #10

Merged
thomasorgeval merged 2 commits into
mainfrom
bolt-optimizer/bulk-upsert-synced-reviews
Jun 21, 2026
Merged

perf(sync): bulk upsert synced reviews#10
thomasorgeval merged 2 commits into
mainfrom
bolt-optimizer/bulk-upsert-synced-reviews

Conversation

@thomasorgeval

Copy link
Copy Markdown
Member

Summary

  • Replaces per-review upserts during store sync with one bulk insert ... on conflict do update, while keeping returned storedCount and newReviewIds semantics for normal unique store review payloads.
  • Deduplicates repeated external review IDs before the bulk upsert so a malformed page cannot make Postgres reject the statement for touching the same conflict target twice.
  • Internal Postgres benchmark for 500 synced reviews improved median insert/upsert time from 547.5ms to 120.9ms over 5 iterations.

Expected impact

  • Store sync review persistence should issue far fewer database round trips for each fetched page, reducing sync latency and database overhead as review batches grow.
  • Duplicate external IDs in one fetched batch are collapsed to the last occurrence instead of being written repeatedly. This avoids a bulk-upsert conflict failure and should not affect normal store API payloads.

Verification

  • NX_DAEMON=false /home/thomas/.local/bin/mise exec node@24 -- pnpm nx typecheck sync --skip-nx-cache --tui=false
  • NX_DAEMON=false /home/thomas/.local/bin/mise exec node@24 -- pnpm nx test sync --skip-nx-cache --tui=false
  • NX_DAEMON=false /home/thomas/.local/bin/mise exec node@24 -- pnpm exec biome lint packages/sync/src/review-storage.ts
  • Benchmark command: NODE_PATH=/home/thomas/projects/reviewinbox/node_modules DATABASE_URL=<local postgres> /home/thomas/.local/bin/mise exec node@24 -- pnpm tsx /home/thomas/.hermes/autonomous-coding/runs/20260621T060050Z/benchmarks/sync-review-storage/bench.ts

@thomasorgeval
thomasorgeval marked this pull request as ready for review June 21, 2026 09:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67a853fc6e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/sync/src/review-storage.ts Outdated
@thomasorgeval
thomasorgeval merged commit b18d48c into main Jun 21, 2026
1 check passed
@thomasorgeval
thomasorgeval deleted the bolt-optimizer/bulk-upsert-synced-reviews branch June 21, 2026 11:16
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