I’ve been testing Firestore queries from Unity and noticed a discrepancy between documented and observed behavior regarding charges for queries that return no results.
According to Firestore documentation:
There is a minimum charge of one document read for each query that you perform, even if the query returns no results.
I noticed that wasn’t always the case and to confirm it, I did some tests. According to these tests, my conclusions are:
- Multiple queries returning no results are not reflected in the Usage panel, at least not within the next 30 minutes.
- Only queries that return documents are being counted as reads.
- This behavior persists even for first-time queries that couldn’t have been cached server-side.
Note: I’m querying from the Unity Editor (Windows PC). The Unity SDK doesn’t allow setting Source Options. My understanding is that this uses Firestore’s default behavior: attempting to fetch the latest document snapshot from the database, only using offline cache if the network is unavailable or the request times out.
Is this undocumented behavior or am I missing something? Has anyone else observed similar results?
Test details:
- Ran 6 no-result queries and 1 query returning one single document. These were queries that I run normally.
- I waited 30 minutes: only 1 read was reflected in either Firestore or Google Cloud usage panel.
- I did a subsequent test with a new, never-before-run no-result query, to check if Firestore is doing some caching server-side, and only charges a read the first time a query with no results is run. But after waiting another 30min, the usage panels also showed 0 reads.
Any insights or explanations would be greatly appreciated.