Skip to content

Conversation

@xRahul
Copy link
Owner

@xRahul xRahul commented Jan 30, 2026

πŸ’‘ What:
Replaced the loop-based PhoneLookup query mechanism in ExternalContentBridge.getContactNames with a batched query against ContactsContract.CommonDataKinds.Phone.

🎯 Why:
The previous implementation performed one IPC/database query per phone number (N+1 problem). For a list of 50 SMS messages, this meant 50 separate IPC calls, causing significant UI lag or processing delay.

πŸ“Š Measured Improvement:

  • Baseline: N queries for N phone numbers.
  • Optimized: ceil(N/50) queries. For typical use cases (e.g., inbox list), this reduces queries from ~20-50 to 1.
  • Verification: Added ExternalContentBridgeTest.java using Robolectric and a mock ContentProvider to confirm that looking up 3 contacts results in exactly 1 query instead of 3.

PR created automatically by Jules for task 17496235591141227007 started by @xRahul

- Replaced N+1 ContentProvider queries with batched `IN` clause queries.
- Added normalization logic to match fuzzy lookup behavior.
- Added Robolectric test to verify query count and logic.

Co-authored-by: xRahul <1639945+xRahul@users.noreply.github.com>
@google-labs-jules
Copy link
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.

@xRahul xRahul merged commit b6e66bc into master Jan 31, 2026
3 checks passed
@xRahul xRahul deleted the perf/batch-contact-queries-17496235591141227007 branch January 31, 2026 03:00
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.

2 participants