Praveena
Praveena

Reputation: 6941

How read count is calculated across different queries with partially same result set?

Consider I have a Firestore query query1 which returns 10 documents and another query query2 which returns 15 documents, but this time out of 15, 5 documents are common for both query1 and query2. So for the second query, is the read count 10 or 15 in a persistence enabled platform?

Upvotes: 1

Views: 67

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317362

Persistence doesn't change anything while the app is online. Each query bills reads according to the number of documents that were retrieved from the server. It doesn't matter if previously queried documents are in the cache -- all results from an online query always come from the server.

When the app is offline, queries will not bill reads, and only read from the cache. But your app doesn't know if this is the case.

The only way you can force a query not to bill document reads is if you instruct the query to only using a source option to force the query to use the local cache and not consult the server at all.

Also read:

Upvotes: 1

Related Questions