Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore query costs

On Firestore I have a social app that stores each user as a document, and queries based on users within a certain distance.

If a user launched the app and had 1,000 users within 50 miles for example, would I be charged for 1000 reads for downloading all nearby profiles? That seems like it would be hyper expensive if I got charged that much every time a user queried nearby users. Is there a cheaper way to do this?

like image 332
Tipper Avatar asked Apr 09 '18 01:04

Tipper


Video Answer


2 Answers

As far as I know, if your query returns 1 document, you'll be charged 1 read. If your query returns 1000 documents, you'll be charged 1000 reads.

I'm not sure how your app might look like, I'd rather re-structure fetching process. For instance, I'd rather not fetch the entire 1000 users at once. Instead, the way of getting a fresh set of 10 or 20 group of nearby users whenever a person wants to see new users seems much better to me.

Hope this helps you.

Note: Be aware that your queries won't get any extra charges for having supplementary documents in a collection that are unread.

Have a look at Managing large result sets which help you manage queries that return a large number of results.

like image 63
JeffMinsungKim Avatar answered Nov 15 '22 12:11

JeffMinsungKim


You can use Realtime Database as an alternative. It seems cheaper than Firestore. No document read. 10 GB is free and it means 200 million chat messages.

I use Blaze plan and i only pay for Firestore Reads. I plan to migrate some tables to old Realtime Database. I have 10.000+ users. I just show a calendar & dining menu to them from Firestore. I don't want to pay for such simple things.

like image 43
LacOniC Avatar answered Nov 15 '22 10:11

LacOniC