Skip to content

⚡ Bolt: Batch tag insertions in D1 to eliminate N+1 latency - #626

Closed
schmug wants to merge 1 commit into
mainfrom
bolt-batch-d1-tag-inserts-13689963474459812018
Closed

schmug wants to merge 1 commit into
mainfrom
bolt-batch-d1-tag-inserts-13689963474459812018

Conversation

@schmug

@schmug schmug commented Jul 16, 2026

Copy link
Copy Markdown
Owner

💡 What: Replaced sequential db.prepare().run() calls inside for...of loops with a single concurrent db.batch() execution for tags and event_tags insertions in hub/src/routes/events.ts and hub/src/agent/triage.ts.
🎯 Why: Iterating over multiple tags and firing individual D1 mutations causes an N+1 query problem, injecting substantial round-trip network latency per tag and blocking the request/consumer thread.
📊 Impact: Expected to reduce tag ingestion latency from O(N) database round-trips to O(1) for both the synchronous REST API path and the asynchronous LLM consumer path.
🔬 Measurement: Verify using trace analytics or the dashboard "events pulled in last 24h" latency when importing payloads with large arrays of MISP taxonomy tags.


PR created automatically by Jules for task 13689963474459812018 started by @schmug

Co-authored-by: schmug <38227427+schmug@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 16, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
🔵 In progress
View logs
ais-hub b9e0c55 Commit Preview URL

Branch Preview URL
Jul 16 2026, 05:40 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 16, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
agentic-inbox b9e0c55 Jul 16 2026, 05:41 AM

@schmug

schmug commented Jul 20, 2026

Copy link
Copy Markdown
Owner Author

Duplicate: same D1 tag-insert batching as #614, re-filed daily. Consolidating on #614, which makes the same change without ~200 lines of unrelated Prettier churn. The extra hub/src/agent/triage.ts batching here is worth a separate focused PR if you want it.

@schmug schmug closed this Jul 20, 2026
@schmug
schmug deleted the bolt-batch-d1-tag-inserts-13689963474459812018 branch July 20, 2026 11:36
@google-labs-jules

Copy link
Copy Markdown

Duplicate: same D1 tag-insert batching as #614, re-filed daily. Consolidating on #614, which makes the same change without ~200 lines of unrelated Prettier churn. The extra hub/src/agent/triage.ts batching here is worth a separate focused PR if you want it.

Acknowledged. I'll stop working on this PR, since #614 already addresses this optimization without the extra formatting changes.

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