1

I want to make an online QuizGame using Android Studio and Firebase. First step will be a game mode for one Player where he gets Questions from the server. The code itself is not a big problem but I have a question about the reads/pricing of Firestore.

The gameplay will look like this: One Round, 5 questions. I want to make a Database looking like this:

Project: Category(Collection) -> generatedID(Document) -> custom Object (My custom Object has an Arraylist of Question, Correct AnswerA, AnswerB, C and D).

My general question is, lets say I am looking for an ID. I have for example 50 IDs in my Category Collection. If I start a query it will check every entry if the saved ID == my searched ID. Will that be a total of 50 reads or only one?

J. Lo
  • 179
  • 1
  • 3
  • 12

1 Answers1

6

Firestore pricing is based on document reads, writes and deletes. If you run a query, you will be charged for any documents returned by that query, not the total number of documents in the collection. You can avoid un-necessary cost by the use of cursors and pagination, if you need to return large datasets. If you are only searching for a single ID, then it is likely that'll only return one document and, therefore, it'll only cost you for one document read.

If your query returns no results, you will be charged for one document read.

You can get more details from the Cloud Firestore pricing page

Jason Berryman
  • 4,760
  • 1
  • 26
  • 42