u/DrummerPotential8108

Why does a single limit(1) search trigger 4,500 reads?

Hello everyone, to clarify, I am totally new to Firebase and I am encountering this problem.

I have a collection with about 50,000 documents. I built a simple search page where a user enters an ID and it fetches that one document.

The Problem: Every time I do ONE search, my Google Cloud billing shows a spike of 2,000 to 6,000 reads. It’s like it’s scanning my entire collection every time I click search.

My Setup:

  • I am using the Web SDK (v11/12).
  • My code uses a hard limit(1) and a specific where clause on a unique field.
  • I am using getDocs (one-time fetch), NOT a real-time listener.
  • I have memoryLocalCache enabled to stop background syncing.
  • My UI tracks the results, and it confirms the query only returns 1 document.

Could it be my Security Rules? Or something with the hosting environment (Cloud Run)? Or could it be because I didn't set the Indexes yet?

Any help would be huge. Thanks!

reddit.com
u/DrummerPotential8108 — 5 days ago