DEV Community

Discussion on: Surprisingly simple method to increase Firestore performance & reduce cost

Collapse
 
johncarroll profile image
John Carroll • Edited

Are you still using this solution as of today?

Yup. Though I've found that any impact on cost is limited (at least compared to enabling Firestore persistence). It's mainly a performance improvement. I also added the ability to configure the HOLD_CACHED_QUERIES_DURATION on a query by query basis. For my app, there are a few queries that make sense to hold for the lifetime of the application since they are used so often.

Collapse
 
maslow profile image
Maslow

I've recently jumped back into this code again and it's interesting because in the end it didn't reduce the cost that much. But now I understand something a little bit better. Keeping a query in cache reduces the cost if this query is called several times from several different places or if you do a lot of back and forth in the app. But when you leave a page which needs a query results, you'll still get charged for every update to this query for 3min (or the duration you chose) even if you don't need them anymore. Does that sound right @johncarroll ?

Thread Thread
 
johncarroll profile image
John Carroll

But when you leave a page which needs a query results, you'll still get charged for every update to this query for 3min (or the duration you chose) even if you don't need them anymore. Does that sound right @johncarroll ?

Yes

Collapse
 
maslow profile image
Maslow

I haven't pushed to prod yet but for what I've tested I'm expecting a huge cost reduction. If not then it means that Firebase already agregates those queries in the SDK. I'm expecting ~70% less reads. (Fyi I'm not using persistence since I had huge performance issues with it).