Skip to content

Optimize search index upsert performance#93

Merged
d-oit merged 3 commits intomainfrom
perf/search-optimize-upsert-5819970794072882130
May 2, 2026
Merged

Optimize search index upsert performance#93
d-oit merged 3 commits intomainfrom
perf/search-optimize-upsert-5819970794072882130

Conversation

@d-oit
Copy link
Copy Markdown
Owner

@d-oit d-oit commented May 2, 2026

Identified a performance bottleneck in the search indexing logic where upsertToSearchIndex would fetch all entities from the database to find a single one by ID.

Implemented getEntityById in the Repository class to allow for direct O(1) lookups via SQL. Updated the search service to use this new method, significantly reducing I/O and memory overhead during incremental indexing of entities and claims.

Verified with 99 passing tests and successful linting.


PR created automatically by Jules for task 5819970794072882130 started by @d-oit

Replaced inefficient in-memory filtering of all entities with a targeted
database query in `upsertToSearchIndex`. This improves performance from
O(N) to O(1) for incremental search index updates.

Co-authored-by: d-oit <6849456+d-oit@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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.

@github-actions github-actions Bot added the config label May 2, 2026
@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented May 2, 2026

DeepSource Code Review

We reviewed changes in 76ede91...a315863 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript May 2, 2026 4:28p.m. Review ↗
Python May 2, 2026 4:28p.m. Review ↗
Shell May 2, 2026 4:28p.m. Review ↗
SQL May 2, 2026 4:28p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread src/db/repository.ts
async getEntityById(id: string): Promise<Entity | null> {
try {
const results = await this.db.exec({
sql: `SELECT * FROM entities WHERE id = ?`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Template string can be replaced with regular string literal


Template literals are useful when you need: 1. Interpolated strings.

@d-oit d-oit marked this pull request as ready for review May 2, 2026 16:17
google-labs-jules Bot and others added 2 commits May 2, 2026 16:24
- Implemented getEntityById in Repository for O(1) database retrieval
- Replaced O(N) in-memory filtering with targeted DB query in upsertToSearchIndex
- Reduces I/O and memory overhead for incremental search index updates

Repair Agent: Verified all local quality gates (lint, typecheck, test).

Co-authored-by: d-oit <6849456+d-oit@users.noreply.github.com>
@d-oit d-oit merged commit 5df6e1a into main May 2, 2026
12 of 16 checks passed
@d-oit d-oit deleted the perf/search-optimize-upsert-5819970794072882130 branch May 2, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant