问题
What is the read cost at point A, B and C? Is it always 1 read no matter what, or are there circumstances under which no read is incurred?
dsnap, err := docRef.Get(ctx)
if status.Code(err) == codes.NotFound {
return nil, ErrNotFound // Point A
}
if err != nil {
return nil, err // Point B
}
// Point C
回答1:
According to the documentation on pricing:
Minimum charge for queries
There is a minimum charge of one document read for each query that you perform, even if the query returns no results.
This suggests that every time you call Get, it will cost 1 read if the request hits the server. This is essentially the cost of using the massively scalable Firestore indexes.
来源:https://stackoverflow.com/questions/61641099/what-is-the-read-cost-of-a-not-found-docref-getctx-in-firestore